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

#initialize(expected, *args) ⇒ Has

Returns 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

#descriptionObject



22
23
24
# File 'lib/rspec/matchers/built_in/has.rb', line 22

def description
  [method_description(@expected), args_description].compact.join(' ')
end

#failure_message_for_shouldObject



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

#failure_message_for_should_notObject



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

#matches?(actual) ⇒ Boolean 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