spec/public/to_json_spec.rb in dm-serializer-1.0.2 vs spec/public/to_json_spec.rb in dm-serializer-1.1.0.rc1

- old
+ new

@@ -55,6 +55,21 @@ it "supports :include option for more than one level depth" it "has :repository option to override used repository" + it "can be serialized within a Hash" do + hash = { 'cows' => Cow.all } + JSON.parse(hash.to_json).should == hash + end + +end + +describe DataMapper::Serialize, '#as_json' do + it "handles nil for options" do + expect { Cow.new.as_json(nil) }.to_not raise_error + end + + it "serializes Discriminator types as strings" do + Motorcycle.new.as_json[:type].should == "Motorcycle" + end end