Class: Boring::FactoryBot::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Boring::FactoryBot::InstallGenerator
- Defined in:
- lib/generators/boring/factory_bot/install/install_generator.rb
Instance Method Summary collapse
- #add_factory_bot_gem ⇒ Object
- #add_factory_bot_helper_method ⇒ Object
- #add_faker_gem ⇒ Object
- #add_sample_factory ⇒ Object
Instance Method Details
#add_factory_bot_gem ⇒ Object
14 15 16 17 18 19 |
# File 'lib/generators/boring/factory_bot/install/install_generator.rb', line 14 def add_factory_bot_gem log :adding, "FactoryBot" Bundler.with_unbundled_env do run "bundle add factory_bot_rails --group='development,test'" end end |
#add_factory_bot_helper_method ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/boring/factory_bot/install/install_generator.rb', line 28 def add_factory_bot_helper_method log :adding, "factory_bot helper" data = <<~RUBY include FactoryBot::Syntax::Methods RUBY inject_into_file "test/test_helper.rb", optimize_indentation(data, 2), after: /ActiveSupport::TestCase*\n/, verbose: false end |
#add_faker_gem ⇒ Object
39 40 41 42 43 |
# File 'lib/generators/boring/factory_bot/install/install_generator.rb', line 39 def add_faker_gem return if [:skip_faker] Rails::Command.invoke :generate, ["boring:faker:install"] end |
#add_sample_factory ⇒ Object
21 22 23 24 25 26 |
# File 'lib/generators/boring/factory_bot/install/install_generator.rb', line 21 def add_sample_factory return if [:skip_factory] log :adding, "Sample users factory" copy_file "users.rb", "test/factories/users.rb" end |