Class: RSpec::Matchers::BuiltIn::BeComparedTo Private

Inherits:
BaseMatcher show all
Includes:
BeHelpers
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.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 of ‘be <operator> value`. Not intended to be instantiated directly.

Constant Summary

Constants inherited from BaseMatcher

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected, #matcher_name, #rescued_exception

Instance Method Summary collapse

Methods inherited from BaseMatcher

#actual_formatted, #diffable?, #expected_formatted, #expects_call_stack_jump?, #match_unless_raises, matcher_name, #supports_block_expectations?, #supports_value_expectations?

Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages

has_default_failure_messages?

Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::HashFormatting

improve_hash_formatting

Methods included from Composable

#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?

Constructor Details

#initialize(operand, operator) ⇒ BeComparedTo

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 BeComparedTo.



139
140
141
142
143
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 139

def initialize(operand, operator)
  @expected = operand
  @operator = operator
  @args = []
end

Instance Method Details

#descriptionString

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:



178
179
180
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 178

def description
  "be #{@operator} #{expected_to_sentence}#{args_to_sentence}"
end

#does_not_match?(actual) ⇒ Boolean

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:

  • (Boolean)


151
152
153
154
155
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 151

def does_not_match?(actual)
  !perform_match(actual)
rescue ArgumentError, NoMethodError
  false
end

#failure_messageString

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:



159
160
161
162
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 159

def failure_message
  "expected: #{@operator} #{expected_formatted}\n" \
  "     got: #{@operator.to_s.gsub(/./, ' ')} #{actual_formatted}"
end

#failure_message_when_negatedString

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:



166
167
168
169
170
171
172
173
174
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 166

def failure_message_when_negated
  message = "`expect(#{actual_formatted}).not_to " \
            "be #{@operator} #{expected_formatted}`"
  if [:<, :>, :<=, :>=].include?(@operator)
    message + " not only FAILED, it is a bit confusing."
  else
    message
  end
end

#matches?(actual) ⇒ Boolean

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:

  • (Boolean)


145
146
147
148
149
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/matchers/built_in/be.rb', line 145

def matches?(actual)
  perform_match(actual)
rescue ArgumentError, NoMethodError
  false
end