Module: WithModel

Defined in:
lib/with_model.rb,
lib/with_model/model.rb,
lib/with_model/table.rb,
lib/with_model/methods.rb,
lib/with_model/version.rb,
lib/with_model/model/dsl.rb,
lib/with_model/constant_stubber.rb

Defined Under Namespace

Modules: Methods Classes: Model, Table

Constant Summary collapse

VERSION =
'2.1.2'

Instance Method Summary collapse

Instance Method Details

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


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/with_model.rb', line 13

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

  before(*scope) do
    model.create
  end

  after(*scope) do
    model.destroy
  end
end

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


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/with_model.rb', line 31

def with_table(name, scope: nil, **options, &block)
  table = Table.new name, options, &block

  before(*scope) do
    table.create
  end

  after(*scope) do
    table.destroy
  end
end