Class: FactoryBotRails::Generator
- Inherits:
-
Object
- Object
- FactoryBotRails::Generator
- Defined in:
- lib/factory_bot_rails/generator.rb
Instance Method Summary collapse
- #factory_bot_disabled? ⇒ Boolean
- #generator ⇒ Object
-
#initialize(config) ⇒ Generator
constructor
A new instance of Generator.
- #rails_options ⇒ Object
- #run ⇒ Object
- #test_framework ⇒ Object
Constructor Details
#initialize(config) ⇒ Generator
Returns a new instance of Generator.
7 8 9 10 11 12 13 |
# File 'lib/factory_bot_rails/generator.rb', line 7 def initialize(config) @generators = if config.respond_to?(:app_generators) config.app_generators else config.generators end end |
Instance Method Details
#factory_bot_disabled? ⇒ Boolean
35 36 37 |
# File 'lib/factory_bot_rails/generator.rb', line 35 def factory_bot_disabled? [:factory_bot] == false end |
#generator ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/factory_bot_rails/generator.rb', line 19 def generator if factory_bot_disabled? Generators::NullGenerator else if test_framework == :rspec Generators::RSpecGenerator else Generators::NonRSpecGenerator end end end |
#rails_options ⇒ Object
39 40 41 |
# File 'lib/factory_bot_rails/generator.rb', line 39 def @generators.[:rails] end |
#run ⇒ Object
15 16 17 |
# File 'lib/factory_bot_rails/generator.rb', line 15 def run generator.new(@generators).run end |
#test_framework ⇒ Object
31 32 33 |
# File 'lib/factory_bot_rails/generator.rb', line 31 def test_framework [:test_framework] end |