module SuperDiff::RSpec::AugmentedMatcher

Public Instance Methods

description() click to toggle source

Update to use expected_for_description instead of @expected TODO: Test

# File lib/super_diff/rspec/augmented_matcher.rb, line 6
def description
  matcher_text_builder.matcher_description
end
diffable?() click to toggle source

Always be diffable (we have the logic of whether to show a diff or not in SuperDiff::RSpec::Differ)

# File lib/super_diff/rspec/augmented_matcher.rb, line 22
def diffable?
  true
end
failure_message() click to toggle source

Colorize the 'actual' value

# File lib/super_diff/rspec/augmented_matcher.rb, line 11
def failure_message
  build_failure_message(negated: false)
end
failure_message_when_negated() click to toggle source

Colorize the 'actual' value

# File lib/super_diff/rspec/augmented_matcher.rb, line 16
def failure_message_when_negated
  build_failure_message(negated: true)
end

Protected Instance Methods

actual_for_matcher_text() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 51
def actual_for_matcher_text
  description_of(actual)
end
build_failure_message(negated:) click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 28
def build_failure_message(negated:)
  matcher_text_builder.call(negated: negated)
end
expected_for_description() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 63
def expected_for_description
  expected_for_matcher_text
end
expected_for_failure_message() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 59
def expected_for_failure_message
  expected_for_matcher_text
end
expected_for_matcher_text() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 55
def expected_for_matcher_text
  description_of(expected)
end
matcher_text_builder() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 32
def matcher_text_builder
  @_matcher_text_builder ||=
    matcher_text_builder_class.new(**matcher_text_builder_args)
end
matcher_text_builder_args() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 41
def matcher_text_builder_args
  {
    actual: actual_for_matcher_text,
    expected_for_failure_message: expected_for_failure_message,
    expected_for_description: expected_for_description,
    expected_action_for_failure_message: expected_action_for_failure_message,
    expected_action_for_description: expected_action_for_description,
  }
end
matcher_text_builder_class() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 37
def matcher_text_builder_class
  RSpec::MatcherTextBuilders::Base
end

Private Instance Methods

colorizer() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 93
def colorizer
  ::RSpec::Core::Formatters::ConsoleCodes
end
expected_action_for_description() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 77
def expected_action_for_description
  expected_action_for_matcher_text
end
expected_action_for_failure_message() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 73
def expected_action_for_failure_message
  expected_action_for_matcher_text
end
expected_action_for_matcher_text() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 69
def expected_action_for_matcher_text
  ::RSpec::Matchers::EnglishPhrasing.split_words(self.class.matcher_name)
end
matchers() click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 85
def matchers
  Object.new.tap do |object|
    object.singleton_class.class_eval do
      include ::RSpec::Matchers
    end
  end
end
readable_list_of(things) click to toggle source
# File lib/super_diff/rspec/augmented_matcher.rb, line 81
def readable_list_of(things)
  ::RSpec::Matchers::EnglishPhrasing.list(things)
end