Sha256: 83e701ec61f185772cf8926e376d2e1813bb353f5cb06a7de04686928cb05787
Contents?: true
Size: 997 Bytes
Versions: 1
Compression:
Stored size: 997 Bytes
Contents
require File.dirname(__FILE__) + '/spec_helper' module TriggerSpec class TriggeredObject < RedisObject int :raw_phone bool :mailed_flag bool :mail_was_sent_for_realz date :srsly_updated def track_phone_raw(k,v) set(:raw_phone, v.gsub(/[^0-9]/,'').to_i) end trigger_on_set :phone, :track_phone_raw def sent_mail(k,v) set(:mail_was_sent_for_realz, true) end def updated_redundant(k,v) set(:srsly_updated, Time.now) end trigger_on_set :mailed_flag, :sent_mail trigger_on_update :updated_redundant end describe Seabright::Triggers do before do SpecHelper.flushdb end it "triggers on a call" do obj = TriggeredObject.create("trig") obj.phone = "(970) 555-1212" obj.raw_phone.should eq(9705551212) success = obj.setnx(:mailed_flag,true) success.should eq(true) obj.mail_was_sent_for_realz.should eq(true) success = obj.setnx(:mailed_flag,true) success.should eq(false) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis_object-1.5.3 | spec/trigger_spec.rb |