Class: CypressOnRails::SmartFactoryWrapper
- Inherits:
-
Object
- Object
- CypressOnRails::SmartFactoryWrapper
- Defined in:
- lib/cypress_on_rails/smart_factory_wrapper.rb
Defined Under Namespace
Modules: FactoryCleaner
Instance Attribute Summary collapse
-
#always_reload ⇒ Object
Returns the value of attribute always_reload.
- #factory ⇒ Array
Class Method Summary collapse
- .configure(files:, factory:, always_reload: true) ⇒ Object
- .create(*args) ⇒ Object
- .create_list(*args) ⇒ Object
- .instance ⇒ Object
Instance Method Summary collapse
- #create(*options) ⇒ Object
- #create_list(*args) ⇒ Object
-
#initialize(files:, factory:, always_reload: false, factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File, dir_system: Dir) ⇒ SmartFactoryWrapper
constructor
A new instance of SmartFactoryWrapper.
Constructor Details
#initialize(files:, factory:, always_reload: false, factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File, dir_system: Dir) ⇒ SmartFactoryWrapper
Returns a new instance of SmartFactoryWrapper.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 35 def initialize(files:, factory:, always_reload: false, factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File, dir_system: Dir) self.files = files self.factory = factory self.always_reload = always_reload @kernel = kernel @file_system = file_system @factory_cleaner = factory_cleaner @latest_mtime = nil @dir_system = dir_system end |
Instance Attribute Details
#always_reload ⇒ Object
Returns the value of attribute always_reload.
33 34 35 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 33 def always_reload @always_reload end |
#factory ⇒ Array
32 33 34 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 32 def factory @factory end |
Class Method Details
.configure(files:, factory:, always_reload: true) ⇒ Object
19 20 21 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 19 def self.configure(files:, factory:, always_reload: true) @instance = new(files: files, factory: factory, always_reload: always_reload) end |
.create(*args) ⇒ Object
23 24 25 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 23 def self.create(*args) instance.create(*args) end |
.create_list(*args) ⇒ Object
27 28 29 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 27 def self.create_list(*args) instance.create_list(*args) end |
.instance ⇒ Object
15 16 17 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 15 def self.instance @instance ||= new(files: [], factory: SimpleRailsFactory) end |
Instance Method Details
#create(*options) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 48 def create(*) load_files factory_name = .shift if .last.is_a?(Hash) args = .pop else args = {} end factory.create(factory_name,*.map(&:to_sym),args.symbolize_keys) end |
#create_list(*args) ⇒ Object
59 60 61 62 |
# File 'lib/cypress_on_rails/smart_factory_wrapper.rb', line 59 def create_list(*args) load_files factory.create_list(*args) end |