Sha256: c8c2250ea7e49ffa0a35afe3b327ee85f3bf4f46371de197b4b88898e0533168
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
class Factory class Proxy class Stub < Proxy #:nodoc: @@next_id = 1000 def initialize(klass) super @instance = klass.new @instance.id = next_id @instance.instance_eval do def new_record? id.nil? end def connection raise "stubbed models are not allowed to access the database" end def reload raise "stubbed models are not allowed to access the database" end end end def next_id @@next_id += 1 end def get(attribute) @instance.send(attribute) end def set(attribute, value) @instance.send(:"#{attribute}=", value) end def associate(name, factory, attributes) set(name, Factory.stub(factory, attributes)) end def association(factory, overrides = {}) Factory.stub(factory, overrides) end def result run_callbacks(:after_stub) @instance end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vitalish-factory_girl-1.2.10 | lib/factory_girl/proxy/stub.rb |
vitalish-factory_girl-1.2.9 | lib/factory_girl/proxy/stub.rb |
vitalish-factory_girl-1.2.8 | lib/factory_girl/proxy/stub.rb |