Sha256: e558b86733f4b10ca38b5fab704aced0a2e9d0386d5cc1b09e954a12cb636d30
Contents?: true
Size: 1.36 KB
Versions: 55
Compression:
Stored size: 1.36 KB
Contents
module FactoryGirl module Strategy class Stub @@next_id = 1000 def association(runner) runner.run(Strategy::Stub) end def result(evaluation) evaluation.object.tap do |instance| stub_database_interaction_on_result(instance) evaluation.notify(:after_stub, instance) end end private def next_id @@next_id += 1 end def stub_database_interaction_on_result(result_instance) result_instance.id = next_id result_instance.instance_eval do def persisted? !new_record? end def created_at @created_at ||= Time.now end def new_record? id.nil? end def save(*args) raise "stubbed models are not allowed to access the database" end def destroy(*args) raise "stubbed models are not allowed to access the database" 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 def update_attribute(*args) raise "stubbed models are not allowed to access the database" end end end end end end
Version data entries
55 entries across 55 versions & 4 rubygems