Class: RSpec::Matchers::BuiltIn::BePredicate Private

Inherits:
BaseMatcher
  • Object
show all
Defined in:
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_<predicate>. Not intended to be instantiated directly.

Constant Summary

Constants inherited from BaseMatcher

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

Instance Method Summary collapse

Methods inherited from BaseMatcher

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

Methods included from Composable

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

Constructor Details

#initialize(*args, &block) ⇒ BePredicate

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

184
185
186
187
188
# File 'lib/rspec/matchers/built_in/be.rb', line 184
def initialize(*args, &block)
  @expected = parse_expected(args.shift)
  @args = args
  @block = block
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:

  • (String)
216
217
218
# File 'lib/rspec/matchers/built_in/be.rb', line 216
def description
  "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
end

#does_not_match?(actual, &block) ⇒ 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)
196
197
198
199
200
# File 'lib/rspec/matchers/built_in/be.rb', line 196
def does_not_match?(actual, &block)
  @actual  = actual
  @block ||= block
  predicate_accessible? && !predicate_matches?
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:

  • (String)
204
205
206
# File 'lib/rspec/matchers/built_in/be.rb', line 204
def failure_message
  failure_message_expecting(true)
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:

  • (String)
210
211
212
# File 'lib/rspec/matchers/built_in/be.rb', line 210
def failure_message_when_negated
  failure_message_expecting(false)
end

#matches?(actual, &block) ⇒ 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)
190
191
192
193
194
# File 'lib/rspec/matchers/built_in/be.rb', line 190
def matches?(actual, &block)
  @actual  = actual
  @block ||= block
  predicate_accessible? && predicate_matches?
end