Sha256: 5c6ddcbb925fead0b39db750d3b47446e74740a1deaa238e165fca317e704952
Contents?: true
Size: 753 Bytes
Versions: 3
Compression:
Stored size: 753 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.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) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
warp-1.2.3 | spec/support/model_helpers.rb |
warp-1.2.2 | spec/support/model_helpers.rb |
warp-1.2.1 | spec/support/model_helpers.rb |