Method: WithModel#with_model

Defined in:
lib/with_model.rb

#with_model(name, scope: nil, **options, &block) ⇒ Object

Parameters:

  • name (Symbol)

    The constant name to assign the model class to.

  • scope (defaults to: nil)

    Passed to before/after in the test context. RSpec only.

  • options
  • block

    Yielded an instance of WithModel::Model::DSL.



39
40
41
42
43
44
45
46
# File 'lib/with_model.rb', line 39

def with_model(name, scope: nil, **options, &block)
  runner = options.delete(:runner)
  model = Model.new name, **options
  dsl = Model::DSL.new model
  dsl.instance_exec(&block) if block

  setup_object(model, scope: scope, runner: runner)
end