Sha256: 8aa9186b0e0030a05eaea79c1c8152a6f36e2a903c789da99f57bb1e0c110bcc

Contents?: true

Size: 743 Bytes

Versions: 1

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: '#{response_body}'. 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

1 entries across 1 versions & 1 rubygems

Version Path
api_matchers-0.5.0 lib/api_matchers/response_body/have_json.rb