Class: Spec::Matchers::Has

Inherits:
Object show all
Defined in:
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/spec/matchers/has.rb', line 5

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

Instance Method Details

#descriptionObject



32
33
34
# File 'lib/spec/matchers/has.rb', line 32

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

#failure_messageObject

Raises:

  • (@error)


22
23
24
25
# File 'lib/spec/matchers/has.rb', line 22

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

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/spec/matchers/has.rb', line 10

def matches?(target)
  @target = target
  begin
    return target.send(predicate, *@args)
  rescue => @error
    # This clause should be empty, but rcov will not report it as covered
    # unless something (anything) is executed within the clause
    rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
  end
  return false
end

#negative_failure_messageObject

Raises:

  • (@error)


27
28
29
30
# File 'lib/spec/matchers/has.rb', line 27

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