spec/model_spec.rb in blendris-0.0.2 vs spec/model_spec.rb in blendris-0.0.3

- old
+ new

@@ -46,10 +46,25 @@ fav.key.should == "person:Billy_Bob_Thorton:food:onion" fav.person.should == "Billy Bob Thorton" fav.food.should == @onion end + it "should have a valid list of fields" do + + fields = %w( name foods ) + + @vegetable.fields.should == fields + + end + + it "should use its on_change field correctly" do + @apple.calories.should == 0 + @apple.description = "good" + @apple.description = "bad" + @apple.calories.should == 2 + end + context "with single reference" do it "should reverse to a single reference" do @apple.sibling.should be_nil @lemon.sibling.should be_nil @@ -173,8 +188,31 @@ site1.sister_sites.should_not be_include site2 site2.sister_sites.should_not be_include site1 end + end + + it "should enumerable all foods" do + Food.count.should == 5 + + count = 0 + + Food.each do |food| + count += 1 + food.should be_a(Food) + end + + count.should == 5 + end + + it "should call its on_change method for all fields" do + o = OnChangeTestModel.create + lambda { o.string = "test" }.should raise_exception TestEx + lambda { o.integer = 123 }.should raise_exception TestEx + lambda { o.set = [1,2,3] }.should raise_exception TestEx + lambda { o.list = [1,5,8] }.should raise_exception TestEx + lambda { o.ref = o }.should raise_exception TestEx + lambda { o.refs << o }.should raise_exception TestEx end end