Sha256: f243cdd7ac9780d3677b0903fef5f680bf784cebe382a9ef78fc7663bc89afc9
Contents?: true
Size: 716 Bytes
Versions: 1
Compression:
Stored size: 716 Bytes
Contents
# encoding: utf-8 module SpecHelper def mock_model(*attributes, &block) model = Class.new { include Equalizer.new(*attributes) const_set(:ATTRIBUTES, attributes) attributes.each { |name| attr_accessor name } def initialize(attrs = {}, &block) attrs.each { |name, value| send("#{name}=", value) } instance_eval(&block) if block end def update(tuple) self.class.new(to_h.update(tuple)) end def attribute_names self.class.const_get(:ATTRIBUTES) end def to_h attribute_names.each_with_object({}) { |name, h| h[name] = send(name) } end } model.class_eval(&block) if block model end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-0.2.0 | spec/support/helper.rb |