Class: RSpec::Matchers::BuiltIn::Has

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/matchers/built_in/has.rb

Instance Method Summary (collapse)

Constructor Details

- (Has) initialize(expected, *args)

A new instance of Has

5
6
7
# File 'lib/rspec/matchers/built_in/has.rb', line 5
def initialize(expected, *args)
  @expected, @args = expected, args
end

Instance Method Details

- (Object) description

22
23
24
# File 'lib/rspec/matchers/built_in/has.rb', line 22
def description
  [method_description(@expected), args_description].compact.join(' ')
end

- (Object) failure_message_for_should

14
15
16
# File 'lib/rspec/matchers/built_in/has.rb', line 14
def failure_message_for_should
  "expected ##{predicate(@expected)}#{failure_message_args_description} to return true, got false"
end

- (Object) failure_message_for_should_not

18
19
20
# File 'lib/rspec/matchers/built_in/has.rb', line 18
def failure_message_for_should_not
  "expected ##{predicate(@expected)}#{failure_message_args_description} to return false, got true"
end

- (Boolean) matches?(actual) Also known as: ==

Returns:

  • (Boolean)
9
10
11
# File 'lib/rspec/matchers/built_in/has.rb', line 9
def matches?(actual)
  actual.__send__(predicate(@expected), *@args)
end