Class: RSpec::Matchers::Has

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

Instance Method Summary collapse

Constructor Details

#initialize(expected, *args) ⇒ Has

Returns a new instance of Has.



4
5
6
# File 'lib/rspec/matchers/has.rb', line 4

def initialize(expected, *args)
  @expected, @args = expected, args
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/rspec/matchers/has.rb', line 20

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

#failure_message_for_shouldObject



12
13
14
# File 'lib/rspec/matchers/has.rb', line 12

def failure_message_for_should
  "expected ##{predicate(@expected)}#{failure_message_args_description} to return true, got false"
end

#failure_message_for_should_notObject



16
17
18
# File 'lib/rspec/matchers/has.rb', line 16

def failure_message_for_should_not
  "expected ##{predicate(@expected)}#{failure_message_args_description} to return false, got true"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rspec/matchers/has.rb', line 8

def matches?(actual)
  actual.__send__(predicate(@expected), *@args)
end