Sha256: d027a4b92a2bff78f8199e81a0ca689b4e829f0894f163ce1f2eaf1f36561d04

Contents?: true

Size: 551 Bytes

Versions: 5

Compression:

Stored size: 551 Bytes

Contents

module JsonSpec
  module Matchers
    class HaveJsonPath
      include JsonSpec::Helpers

      def initialize(path)
        @path = path
      end

      def matches?(json)
        parse_json(json, @path)
        true
      rescue JsonSpec::MissingPath
        false
      end

      def failure_message_for_should
        %(Expected JSON path "#{@path}")
      end

      def failure_message_for_should_not
        %(Expected no JSON path "#{@path}")
      end

      def description
        %(have JSON path "#{@path}")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_spec-1.1.1 lib/json_spec/matchers/have_json_path.rb
json_spec-1.1.0 lib/json_spec/matchers/have_json_path.rb
json_spec-1.0.3 lib/json_spec/matchers/have_json_path.rb
json_spec-1.0.2 lib/json_spec/matchers/have_json_path.rb
json_spec-1.0.0 lib/json_spec/matchers/have_json_path.rb