Sha256: fac44aa305384cddc96557e3888c5f46a4a8db91537acf16c0d46906c2b50bff
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require "spec_helper" describe JsonSpec::Matchers::HaveJsonSize do it "counts array entries" do %([1,2,3]).should have_json_size(3) end it "counts null array entries" do %([1,null,3]).should have_json_size(3) end it "counts hash key/value pairs" do %({"one":1,"two":2,"three":3}).should have_json_size(3) end it "counts null hash values" do %({"one":1,"two":null,"three":3}).should have_json_size(3) end it "matches at a path" do %({"one":[1,2,3]}).should have_json_size(3).at_path("one") end it "provides a failure message for should" do matcher = have_json_size(3) matcher.matches?(%([1,2])) matcher.failure_message_for_should.should == "Expected JSON value size to be 3, got 2" end it "provides a failure message for should not" do matcher = have_json_size(3) matcher.matches?(%([1,2,3])) matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3" end it "provides a description message" do matcher = have_json_size(1) matcher.matches?(%({"id":1,"json":["spec"]})) matcher.description.should == %(have JSON size "1") end it "provides a description message with path" do matcher = have_json_size(1).at_path("json") matcher.matches?(%({"id":1,"json":["spec"]})) matcher.description.should == %(have JSON size "1" at path "json") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json_spec-1.1.1 | spec/json_spec/matchers/have_json_size_spec.rb |
json_spec-1.1.0 | spec/json_spec/matchers/have_json_size_spec.rb |