Sha256: ffb1cf8ec58b6bb45ebf0c50fef8c79bb84226ae9f1db733e533ee8f3bab34fa

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

require "spec_helper"

describe JsonSpec::Matchers::HaveJsonPath do
  it "matches hash keys" do
    %({"one":{"two":{"three":4}}}).should have_json_path("one/two/three")
  end

  it "doesn't match values" do
    %({"one":{"two":{"three":4}}}).should_not have_json_path("one/two/three/4")
  end

  it "matches array indexes" do
    %([1,[1,2,[1,2,3,4]]]).should have_json_path("1/2/3")
  end

  it "respects null array values" do
    %([null,[null,null,[null,null,null,null]]]).should have_json_path("1/2/3")
  end

  it "matches hash keys and array indexes" do
    %({"one":[1,2,{"three":4}]}).should have_json_path("one/2/three")
  end

  it "provide a description message" do
    matcher = have_json_path("json")
    matcher.matches?(%({"id":1,"json":"spec"}))
    matcher.description.should == %(have JSON path "json")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_spec-1.0.3 spec/json_spec/matchers/have_json_path_spec.rb
json_spec-1.0.2 spec/json_spec/matchers/have_json_path_spec.rb
json_spec-1.0.0 spec/json_spec/matchers/have_json_path_spec.rb