Sha256: 00149c09394fb97e017fb51a5e9797aa40a5627d42be97f0cd59a2e1debce686
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require 'generators/upgrow' module TestUnit module Generators class InstallGenerator < Rails::Generators::Base include Upgrow::Generators::Helper 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 def create_test_directories directory('test') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upgrow-0.0.5 | lib/generators/test_unit/install/install_generator.rb |