class TestUnit::Generators::InstallGenerator
Public Instance Methods
create_test_directories()
click to toggle source
# File lib/generators/test_unit/install/install_generator.rb, line 43 def create_test_directories directory('test') end
move_existing_models()
click to toggle source
# 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