Sha256: 1390c4e3166d839bd1acbf669d795350f7a3a5bf920a931b02d58d793491354f

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 Bytes

Contents

module ModelHelpers
  def build_model(&blk)
    let(:model) do
      Class.new(ActiveRecord::Base) do
        def self.name
          "TestModel"
        end

        def self.primary_key
          "id"
        end

        def self.columns
          @columns ||= []
        end

        def self.column(name, sql_type = nil, default = nil, null = true)
          columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
        end

        instance_eval(&blk)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
warp-1.1.0 spec/support/model_helpers.rb