Class: RSpec::Matchers::BuiltIn::OperatorMatcher Private
- 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
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides the implementation for operator matchers. Not intended to be instantiated directly. Only available for use with ‘should`.
Direct Known Subclasses
Class Method Summary collapse
- .get(klass, operator) ⇒ Object private
- .register(klass, operator, matcher) ⇒ Object private
- .registry ⇒ Object private
- .unregister(klass, operator) ⇒ Object private
- .use_custom_matcher_or_delegate(operator) ⇒ Object private
Instance Method Summary collapse
- #description ⇒ String private
- #fail_with_message(message) ⇒ Object private
-
#initialize(actual) ⇒ OperatorMatcher
constructor
private
A new instance of OperatorMatcher.
Constructor Details
#initialize(actual) ⇒ OperatorMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OperatorMatcher.
41 42 43 |
# 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 41 def initialize(actual) @actual = actual end |
Class Method Details
.get(klass, operator) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 |
# 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 29 def get(klass, operator) klass.ancestors.each do |ancestor| matcher = registry[ancestor] && registry[ancestor][operator] return matcher if matcher end nil end |
.register(klass, operator, matcher) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 |
# 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 18 def register(klass, operator, matcher) registry[klass] ||= {} registry[klass][operator] = matcher end |
.registry ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# 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 13 def registry @registry ||= {} end |
.unregister(klass, operator) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# 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 24 def unregister(klass, operator) registry[klass] && registry[klass].delete(operator) end |
.use_custom_matcher_or_delegate(operator) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 46 def self.use_custom_matcher_or_delegate(operator) define_method(operator) do |expected| if !has_non_generic_implementation_of?(operator) && (matcher = OperatorMatcher.get(@actual.class, operator)) @actual.__send__(::RSpec::Matchers.last_expectation_handler.should_method, matcher.new(expected)) else eval_match(@actual, operator, expected) end end negative_operator = operator.sub(/^=/, '!') if negative_operator != operator && respond_to?(negative_operator) define_method(negative_operator) do |_expected| opposite_should = ::RSpec::Matchers.last_expectation_handler.opposite_should_method raise "RSpec does not support `#{::RSpec::Matchers.last_expectation_handler.should_method} #{negative_operator} expected`. " \ "Use `#{opposite_should} #{operator} expected` instead." end end end |
Instance Method Details
#description ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# 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 76 def description "#{@operator} #{RSpec::Support::ObjectFormatter.format(@expected)}" end |
#fail_with_message(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# 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 70 def () RSpec::Expectations.fail_with(, @expected, @actual) end |