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

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, enumerable?, #or, surface_descriptions_in, #values_match?

Methods included from Pretty

#name, split_words, #to_sentence, #to_word

Constructor Details

- (BePredicate) initialize(*args, &block)

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

179
180
181
182
183
# File 'lib/rspec/matchers/built_in/be.rb', line 179
def initialize(*args, &block)
  @expected = parse_expected(args.shift)
  @args = args
  @block = block
end

Instance Method Details

- (String) description

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)
211
212
213
# File 'lib/rspec/matchers/built_in/be.rb', line 211
def description
  "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
end

- (Boolean) does_not_match?(actual, &block)

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

- (String) failure_message

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)
199
200
201
# File 'lib/rspec/matchers/built_in/be.rb', line 199
def failure_message
  failure_message_expecting(true)
end

- (String) failure_message_when_negated

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)
205
206
207
# File 'lib/rspec/matchers/built_in/be.rb', line 205
def failure_message_when_negated
  failure_message_expecting(false)
end

- (Boolean) matches?(actual, &block)

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)
185
186
187
188
189
# File 'lib/rspec/matchers/built_in/be.rb', line 185
def matches?(actual, &block)
  @actual  = actual
  @block ||= block
  predicate_accessible? && predicate_matches?
end