Created
December 30, 2009 22:27
-
-
Save zef/266457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "new?" do | |
setup do | |
@document.class_eval do | |
key :foo, Address | |
end | |
end | |
should "be new until document is saved" do | |
address = Address.new(:city => 'South Bend', :state => 'IN') | |
doc = @document.new(:foo => address) | |
doc.foo.new?.should == true | |
address.new?.should == true | |
end | |
should "not be new after document is saved" do | |
address = Address.new(:city => 'South Bend', :state => 'IN') | |
doc = @document.new(:foo => address) | |
doc.save | |
doc.foo.new?.should == false | |
address.new?.should == false | |
end | |
should "not be new when document is read back" do | |
address = Address.new(:city => 'South Bend', :state => 'IN') | |
doc = @document.new(:foo => address) | |
doc.save | |
doc = doc.reload | |
doc.foo.new?.should == false | |
address.new?.should == false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment