Sha256: 7167feae7efc2e71a7ce9218837525ab6f95201c15d573dc59522cca2a886fe9

Contents?: true

Size: 891 Bytes

Versions: 6

Compression:

Stored size: 891 Bytes

Contents

module InfinumJsonApiSetup
  module RSpec
    module Matchers
      class JsonBodyMatcher
        def initialize(parser)
          @parser = parser
        end

        # @param [ActionDispatch::TestResponse] response
        # @return [Boolean]
        def matches?(response)
          @response = response
          success, result = parser.process(response)

          if success
            process_parsing_result(result)
            body_matches?
          else
            @error_message = result
            false
          end
        end

        # @return [String]
        def failure_message
          @error_message || match_failure_message
        end

        private

        attr_reader :parser
        attr_reader :response

        def body_matches?; end

        def match_failure_message; end

        def process_parsing_result(_result); end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
infinum_json_api_setup-0.0.8 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb
infinum_json_api_setup-0.0.7 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb
infinum_json_api_setup-0.0.6 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb
infinum_json_api_setup-0.0.5 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb
infinum_json_api_setup-0.0.4 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb
infinum_json_api_setup-0.0.3 lib/infinum_json_api_setup/rspec/matchers/json_body_matcher.rb