Sha256: 6b1236c7e757107a39db6c57c09471e5de6294679f02245d2ed6731574a142c9

Contents?: true

Size: 743 Bytes

Versions: 4

Compression:

Stored size: 743 Bytes

Contents

module APIMatchers
  module ResponseBody
    class HaveJson
      include APIMatchers::Core::Parser
      attr_reader :expected_json, :response_body

      def initialize(expected_json)
        @expected_json = expected_json
      end

      def matches?(actual)
        @response_body = actual

        @expected_json == json
      end

      def failure_message
        "expect to have json: '#{expected_json}'. Got: '#{json}'."
      end

      def failure_message_when_negated
        "expect to NOT have json: '#{response_body}'."
      end

      # RSpec 2 compatibility:
      alias_method :failure_message_for_should, :failure_message
      alias_method :failure_message_for_should_not, :failure_message_when_negated
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_matchers-0.6.2 lib/api_matchers/response_body/have_json.rb
api_matchers-0.6.1 lib/api_matchers/response_body/have_json.rb
api_matchers-0.6.0 lib/api_matchers/response_body/have_json.rb
api_matchers-0.5.1 lib/api_matchers/response_body/have_json.rb