spec/gitmodel/persistable_spec.rb in gitmodel-0.0.6 vs spec/gitmodel/persistable_spec.rb in gitmodel-0.0.7

- old
+ new

@@ -116,9 +116,37 @@ o.attributes['one'].should == 1 o.blobs['blob1.txt'].should == 'This is blob 1' end end + describe'#reload' do + + it 'reloads persisted attributes' do + o = TestEntity.new(:id => 'foo') + o.attributes['A'] = 'A' + o.save + o.attributes['B'] = 'B' + + o.attributes['A'].should == 'A' + o.attributes['B'].should == 'B' + o.reload + o.attributes['A'].should == 'A' + o.attributes['B'].should == nil + end + + it 'returns the reloaded instance' do + o = TestEntity.create(:id => 'foo') + p = o.reload + o.should == p + end + + it 'raises an exception if the document is not found' do + lambda { TestEntity.new.reload }.should raise_error + lambda { TestEntity.new(:id => "foo").reload }.should raise_error + end + + end + describe '.create' do it 'creates a new instance with the given parameters and calls #save on it' do id = 'foo' attrs = {:one => 1, :two => 2}