Sha256: 33534f65da8c77f6ba7d80a348e95721e2b337a9ded475b34c1d9982200ad1b3
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require_relative 'spec_helper' require 'ixtlan/datamapper/optimistic_get' class A include DataMapper::Resource property :id, Serial property :name, String timestamps :at end DataMapper.finalize DataMapper.auto_migrate! describe Ixtlan::DataMapper::OptimisticGet do subject { A.create :name => 'huffalump' } describe "#optimistic_get" do it 'should load' do A.optimistic_get(subject.updated_at.to_s, subject.id).must_equal subject end it 'should fail with stale exception' do lambda { A.optimistic_get((subject.updated_at - 1000).to_s, subject.id) }.must_raise Ixtlan::DataMapper::StaleObjectException end it 'should fail with nil' do A.optimistic_get(subject.updated_at.to_s, subject.id + 987).must_be_nil end end describe "#optimistic_get!" do it 'should load' do A.optimistic_get!(subject.updated_at.to_s, subject.id).must_equal subject end it 'should fail with not-found exception' do lambda { A.optimistic_get!(subject.updated_at.to_s, subject.id + 987) }.must_raise DataMapper::ObjectNotFoundError end it 'should fail with stale exception' do lambda { A.optimistic_get!((subject.updated_at - 1000).to_s, subject.id) }.must_raise Ixtlan::DataMapper::StaleObjectException end it 'should fail with stale exception updated being nil' do lambda { A.optimistic_get!(nil, subject.id) }.must_raise Ixtlan::DataMapper::StaleObjectException end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ixtlan-datamapper-0.1.0 | spec/optimistic_get_spec.rb |