Sha256: 0aa381dfdc3b88c58371a7e570f8e53d11f29b9bbe2e8a116fc406741352775c
Contents?: true
Size: 795 Bytes
Versions: 1
Compression:
Stored size: 795 Bytes
Contents
module ModelHelpers def build_model(&blk) let(:model) do Class.new(ActiveRecord::Base) do attr_accessor :id def self.name "TestModel" end def self.primary_key "id" end def self.columns @columns ||= [] end def self.attribute_names @columns.map(&:name) end def self.attribute_method?(method) method = method.to_s.sub("=", "") columns.any? {|c| c.name == method } 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) if blk end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
warp-1.3.0 | spec/support/model_helpers.rb |