class RSpec::JsonExpectations::MatcherFactory

Public Class Methods

new(matcher_name) click to toggle source
# File lib/rspec/json_expectations/matcher_factory.rb, line 4
def initialize(matcher_name)
  @matcher_name = matcher_name
end

Public Instance Methods

define_matcher() { || ... } click to toggle source
# File lib/rspec/json_expectations/matcher_factory.rb, line 8
def define_matcher(&block)
  RSpec::Matchers.define(@matcher_name) do |expected|
    yield

    match do |actual|
      traverse(expected, actual, false)
    end

    match_when_negated do |actual|
      traverse(expected, actual, true)
    end

    failure_message do |actual|
      RSpec::JsonExpectations::FailurePresenter.render(@include_json_errors)
    end

    failure_message_when_negated do |actual|
      RSpec::JsonExpectations::FailurePresenter.render(@include_json_errors)
    end
  end
end