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

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

181
182
183
184
185
# File 'lib/rspec/matchers/built_in/be.rb', line 181
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)
213
214
215
# File 'lib/rspec/matchers/built_in/be.rb', line 213
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)
193
194
195
196
197
# File 'lib/rspec/matchers/built_in/be.rb', line 193
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)
201
202
203
# File 'lib/rspec/matchers/built_in/be.rb', line 201
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)
207
208
209
# File 'lib/rspec/matchers/built_in/be.rb', line 207
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)
187
188
189
190
191
# File 'lib/rspec/matchers/built_in/be.rb', line 187
def matches?(actual, &block)
  @actual  = actual
  @block ||= block
  predicate_accessible? && predicate_matches?
end