spec/object_spec.rb in strong_json-2.1.1 vs spec/object_spec.rb in strong_json-2.1.2

- old
+ new

@@ -10,11 +10,11 @@ }, on_unknown: :reject, exceptions: Set.new ) - expect(type.coerce(a: 123, b: "test")).to eq(a: 123, b: "test") + expect(type.coerce({ a: 123, b: "test" })).to eq(a: 123, b: "test") end it "rejects objects with missing fields" do type = StrongJSON::Type::Object.new( { @@ -22,11 +22,11 @@ }, on_unknown: :reject, exceptions: Set.new ) - expect{ type.coerce(a: 123, b: "test") }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|e| + expect{ type.coerce({ a: 123, b: "test" }) }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|e| expect(e.path.to_s).to eq("$") expect(e.attribute).to eq(:b) } end @@ -40,16 +40,16 @@ exceptions: Set[:x] ) } it "ignores field with any value" do - expect(type.coerce(a: 123, b: true)).to eq(a: 123) + expect(type.coerce({ a: 123, b: true })).to eq(a: 123) end it "raises error on attributes listed in exceptions" do expect { - type.coerce(a: 123, x: false) + type.coerce({ a: 123, x: false }) }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|error| expect(error.attribute).to eq(:x) } end end @@ -65,17 +65,17 @@ ) } it "raises with unknown attribute" do expect { - type.coerce(a: 123, b: true) + type.coerce({ a: 123, b: true }) }.to raise_error(StrongJSON::Type::UnexpectedAttributeError) {|error| expect(error.attribute).to eq(:b) } end it "ignores attributes listed in exceptions" do - expect(type.coerce(a: 123, c: false)).to eq(a:123) + expect(type.coerce({ a: 123, c: false })).to eq(a:123) end end end describe "optional" do