spec/property_spec.rb in langalex-couch_potato-0.1.1 vs spec/property_spec.rb in langalex-couch_potato-0.2.0

- old
+ new

@@ -1,34 +1,48 @@ require File.dirname(__FILE__) + '/spec_helper' +class Watch + include CouchPotato::Persistence + + property :time, :type => Time +end + + describe 'properties' do before(:all) do - CouchPotato::Persistence.Db! + recreate_db end it "should return the property names" do - Comment.property_names.should == [:title, :commenter] + Comment.property_names.should == [:created_at, :updated_at, :title, :commenter] end it "should persist a string" do c = Comment.new :title => 'my title' - c.save! - c = Comment.find c.id + CouchPotato.database.save_document! c + c = CouchPotato.database.load_document c.id c.title.should == 'my title' end it "should persist a number" do c = Comment.new :title => 3 - c.save! - c = Comment.find c.id + CouchPotato.database.save_document! c + c = CouchPotato.database.load_document c.id c.title.should == 3 end it "should persist a hash" do c = Comment.new :title => {'key' => 'value'} - c.save! - c = Comment.find c.id + CouchPotato.database.save_document! c + c = CouchPotato.database.load_document c.id c.title.should == {'key' => 'value'} + end + + it "should persist a Time object" do + w = Watch.new :time => Time.now + CouchPotato.database.save_document! w + w = CouchPotato.database.load_document w.id + w.time.year.should == Time.now.year end describe "predicate" do it "should return true if property set" do Comment.new(:title => 'title').title?.should be_true \ No newline at end of file