Sha256: 8a085eed15eee0c3d2a768d177f1044aac49576cdec86080cd895bc1a5d13ef6
Contents?: true
Size: 849 Bytes
Versions: 5
Compression:
Stored size: 849 Bytes
Contents
require "strong_json" describe StrongJSON::Type::Hash do let(:number) { StrongJSON::Type::Base.new(:number) } describe "#coerce" do it "returns a hash" do type = StrongJSON::Type::Hash.new(number) expect(type.coerce({ foo: 123, bar: 234 })).to eq({ foo: 123, bar: 234 }) end it "raises an error if number is given" do type = StrongJSON::Type::Hash.new(number) expect { type.coerce(1) }.to raise_error(StrongJSON::Type::TypeError) {|error| expect(error.path.to_s).to eq("$") } end it "raises an error if hash value is unexpected" do type = StrongJSON::Type::Hash.new(number) expect { type.coerce({ foo: "hello" }) }.to raise_error(StrongJSON::Type::TypeError) {|error| expect(error.path.to_s).to eq("$.foo") } end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
strong_json-2.1.2 | spec/hash_spec.rb |
strong_json-2.1.1 | spec/hash_spec.rb |
strong_json-2.1.0 | spec/hash_spec.rb |
strong_json-2.0.0 | spec/hash_spec.rb |
strong_json-1.1.0 | spec/hash_spec.rb |