Class: RSpec::Matchers::BuiltIn::PositiveOperatorMatcher

Inherits:
OperatorMatcher show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/operators.rb

Overview

Handles operator matcher for ‘should`.

Instance Method Summary collapse

Methods inherited from OperatorMatcher

#description, #fail_with_message, get, #initialize, register, registry, unregister, use_custom_matcher_or_delegate

Constructor Details

This class inherits a constructor from RSpec::Matchers::BuiltIn::OperatorMatcher

Instance Method Details

#__delegate_operator(actual, operator, expected) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/operators.rb', line 98

def __delegate_operator(actual, operator, expected)
  if actual.__send__(operator, expected)
    true
  else
    expected_formatted = RSpec::Support::ObjectFormatter.format(expected)
    actual_formatted   = RSpec::Support::ObjectFormatter.format(actual)

    if ['==', '===', '=~'].include?(operator)
      fail_with_message("expected: #{expected_formatted}\n     got: #{actual_formatted} (using #{operator})")
    else
      fail_with_message("expected: #{operator} #{expected_formatted}\n     got: #{operator.gsub(/./, ' ')} #{actual_formatted}")
    end
  end
end