Class: TestUnit::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- TestUnit::Generators::InstallGenerator
show all
- Includes:
- Upgrow::Generators::Helper
- Defined in:
- lib/generators/test_unit/install/install_generator.rb
Instance Method Summary
collapse
#class_name, included, #module_namespacing, #move_file, #namespace_content
Instance Method Details
#create_test_directories ⇒ Object
43
44
45
|
# File 'lib/generators/test_unit/install/install_generator.rb', line 43
def create_test_directories
directory('test')
end
|
#move_existing_models ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/generators/test_unit/install/install_generator.rb', line 10
def move_existing_models
pattern = File.expand_path('test/models/**/*_test.rb', destination_root)
files = Dir.glob(pattern)
return if files.empty?
unless yes?('Would you like to convert existing model tests into '\
'Record tests?', :blue)
say(
'Please convert your model tests into Record tests manually by '\
'moving them to the test/records directory and adding the '\
'RecordTest suffix to their class names.',
:yellow
)
return
end
files.each do |original|
target = relative_to_original_destination_root(original)
.sub(%r{\Atest/models/}, 'test/records/')
.sub(/^(.+(?<!_record))_test\.rb\z/, '\1_record_test.rb')
move_file(original, target)
inject_into_file(
target, 'Record',
before: /(?<!Record)Test < /,
force: true,
verbose: false
)
end
end
|