spec/unit/render/hash_attribute_spec.rb in render-0.0.3 vs spec/unit/render/hash_attribute_spec.rb in render-0.0.4
- old
+ new
@@ -84,15 +84,26 @@
title = "the title"
attribute.serialize({ title: title }).should == { film: { title: title } }
end
end
- it "uses faux data when offline" do
- type = [String, Integer].sample
- Render.stub({ live: false })
+ context "offline" do
+ before(:each) do
+ Render.stub({ live: false })
+ end
- data = HashAttribute.new({ title: { type: type } }).serialize(nil)
- data[:title].should be_a(type)
+ it "uses faux data when offline" do
+ type = [String, Integer].sample
+ data = HashAttribute.new({ title: { type: type } }).serialize(nil)
+ data[:title].should be_a(type)
+ end
+
+ it "maintains falsy-ie values when instructed" do
+ data = HashAttribute.new({ title: { type: Integer } }).serialize(nil, true)
+ data[:title].should == nil
+ data = HashAttribute.new({ title: { type: Integer } }).serialize(false, true)
+ data[:title].should == false
+ end
end
end
describe "#value" do
context "offline mode" do