Class: Spec::Matchers::Has

Inherits:
Object show all
Defined in:
lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(sym, *args) ⇒ Has

Returns a new instance of Has.



5
6
7
8
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb', line 5

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

Instance Method Details

#descriptionObject



22
23
24
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb', line 22

def description
  "have key #{@args[0].inspect}"
end

#failure_messageObject



14
15
16
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb', line 14

def failure_message
  "expected ##{predicate}(#{@args[0].inspect}) to return true, got false"
end

#matches?(given) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb', line 10

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

#negative_failure_messageObject



18
19
20
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb', line 18

def negative_failure_message
  "expected ##{predicate}(#{@args[0].inspect}) to return false, got true"
end