spec/structure_spec.rb in structure-0.4.0 vs spec/structure_spec.rb in structure-0.5.0

- old
+ new

@@ -35,11 +35,11 @@ end.to raise_error TypeError end end end - describe "#default_attributes" do + describe ".default_attributes" do it "returns the default attributes for the structure" do Person.send(:default_attributes).should == { :name => nil, :age => nil, :friends => [] } Book.send(:default_attributes).should == { :title => nil, @@ -141,13 +141,27 @@ context "when type is Hash" do before(:all) do Person.key :education, :type => Hash end - context "when setting to a value is not a Hash" do + context "when setting to a value that is not a Hash" do it "raises an error" do expect do person.education = 'foo' + end.to raise_error TypeError + end + end + end + + context "when type is Structure" do + before(:all) do + Person.key :father, :type => Structure + end + + context "when setting to a value that is not a Structure" do + it "raises an error" do + expect do + person.father = 'foo' end.to raise_error TypeError end end end