spec/object_spec.rb in strong_json-0.1.2 vs spec/object_spec.rb in strong_json-0.2.0
- old
+ new
@@ -73,6 +73,18 @@
it "return object which ignores given fields but preserve others" do
ty2 = type.except(:a)
expect(ty2.coerce(b: "test")).to eq({ b: "test" })
end
end
+
+ describe "=~" do
+ let (:type) { StrongJSON::Type::Object.new(a: StrongJSON::Type::Base.new(:numeric), b: StrongJSON::Type::Base.new(:string)) }
+
+ it "returns true for valid object" do
+ expect(type =~ { a: 3, b: "foo" }).to be_truthy
+ end
+
+ it "returns false for invalid number" do
+ expect(type =~ {}).to be_falsey
+ end
+ end
end