spec/undo/serializer/primitive_spec.rb in undo-serializer-primitive-0.0.2 vs spec/undo/serializer/primitive_spec.rb in undo-serializer-primitive-0.1.0

- old
+ new

@@ -20,6 +20,36 @@ data = storage.call subject.serialize(input) expect(subject.deserialize data).to eq input end end end + + describe ".serialize?" do + it "is true for primitives" do + [true, nil, 1, 1.0, "hello", :hello].each do |primitive| + expect(subject.serialize? primitive).to be true + end + end + + it "is true for empty array and hash" do + [[], {}].each do |primitive| + expect(subject.serialize? primitive).to be true + end + end + + it "is false for objects" do + expect(subject.serialize? Object.new).to be false + end + end + + describe ".deserialize?" do + it "is true when was serialized by subject" do + data = subject.serialize "hello" + expect(subject.deserialize? data).to be true + end + + it "is false otherwise" do + data = "hello".to_json + expect(subject.deserialize? data).to be false + end + end end