spec/enum_spec.rb in strong_json-0.7.0 vs spec/enum_spec.rb in strong_json-0.7.1

- old
+ new

@@ -24,19 +24,29 @@ let (:type) { StrongJSON::Type::Enum.new([ StrongJSON::Type::Object.new(id: StrongJSON::Type::Literal.new("id1"), value: StrongJSON::Type::Base.new(:string)), StrongJSON::Type::Object.new(id: StrongJSON::Type::Base.new(:string), - value: StrongJSON::Type::Base.new(:symbol)) + value: StrongJSON::Type::Base.new(:symbol)), + StrongJSON::Type::Optional.new(StrongJSON::Type::Literal.new(3)), + StrongJSON::Type::Literal.new(false), ]) } it "returns object with string value" do expect(type.coerce({id: "id1", value: "foo" })).to eq({ id: "id1", value: "foo" }) end it "returns object with symbol value" do expect(type.coerce({id: "id2", value: "foo" })).to eq({ id: "id2", value: :foo }) + end + + it "accepts false" do + expect(type.coerce(false)).to eq(false) + end + + it "accepts nil" do + expect(type.coerce(nil)).to eq(nil) end it "raises error" do expect { type.coerce(3.14) }.to raise_error(StrongJSON::Type::Error) end