spec/unit/attributes_spec.rb in langalex-couch_potato-0.2.8 vs spec/unit/attributes_spec.rb in langalex-couch_potato-0.2.9

- old
+ new

@@ -19,8 +19,23 @@ it "should return the attributes" do plant = Plant.new(:leaf_count => 1) plant.attributes.should == {:leaf_count => 1, :created_at => nil, :updated_at => nil} end end + + # useful when loading models from custom views + describe "accessing non-property attributes" do + it "should allow me to access attributes that are in the couchdb document " do + plant = Plant.json_create({"ruby_class" => "Plant", "color" => "red", "leaf_count" => 1}) + plant.color.should == 'red' + end + + it "should raise a no method error when trying to read attributes that are not in the document" do + plant = Plant.json_create({"ruby_class" => "Plant", "leaf_count" => 1}) + lambda do + plant.length + end.should raise_error(NoMethodError) + end + end end