Class: Concern::ModelGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Concern::ModelGenerator
- Defined in:
- lib/generators/concern/model/model_generator.rb
Instance Method Summary collapse
Instance Method Details
#copy_rspec_helper ⇒ Object
10 11 12 |
# File 'lib/generators/concern/model/model_generator.rb', line 10 def copy_rspec_helper copy_file("mock_table_helper.rb", "spec/support/mock_table_helper.rb") if invoke? end |
#create_concerns ⇒ Object
4 5 6 7 8 |
# File 'lib/generators/concern/model/model_generator.rb', line 4 def create_concerns setting_path = "models/concerns" template "concern.erb", File.join("app", setting_path, class_path, "#{file_name}.rb") template "model_spec.erb", File.join("spec", setting_path, class_path, "#{file_name}_spec.rb") end |
#inject_code ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/generators/concern/model/model_generator.rb', line 14 def inject_code rspec_helper = Rails.root.join(*%w[spec rails_helper.rb]) inject_into_file rspec_helper, before: /^ActiveRecord::Migration\.maintain_test_schema!/ do <<-'CODE' Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } CODE end if injectable?(rspec_helper) end |