Sha256: 529161cd3c320c4ce71be70a61f5352d3f2e91a5eb8309a1b3ac1a584469ed4d

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

require 'with_model/model'
require 'with_model/model/dsl'
require 'with_model/table'
require 'with_model/version'

module WithModel
  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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
with_model-2.1.0 lib/with_model.rb