Created
September 17, 2010 13:58
-
-
Save outerim/584275 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "for raw data" | |
describe "when unserialized data was already provided" do | |
before do | |
@object.data = { :some => :data } | |
end | |
it "should reset unserialized forms when stored" do | |
@object.raw_data = value = '{ "raw": "json" }' | |
@object.raw_data.should == value | |
@object.data.should == { "raw" => "json" } | |
end | |
it "should lazily serialize when read" do | |
@object.raw_data.should == '{"some":"data"}' | |
end | |
end | |
it "should not unnecessarily marshal/demarshal" do | |
@object.should_not_receive(:serialize) | |
@object.should_not_receive(:deserialize) | |
@object.raw_data = value = "{not even valid json!}}" | |
@object.raw_data.should == value | |
end | |
end | |
describe "for unserialized data" do | |
describe "when raw data was already provided" do | |
before do | |
@object.raw_data = '{"some":"data"}' | |
end | |
it "should reset previously stored raw data" do | |
@object.data = value = { "new" => "data" } | |
@object.raw_data.should == '{"new":"data"}' | |
@object.data.should == value | |
end | |
it "should lazily deserialize when read" do | |
@object.data.should == { "some" => "data" } | |
end | |
end | |
it "should not unnecessarily marshal/demarshal" do | |
@object.should_not_receive(:serialize) | |
@object.should_not_receive(:deserialize) | |
@object.data = value = { "some" => "data" } | |
@object.data.should == value | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment