Class: Spec::Matchers::Has
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(sym, *args) ⇒ Has
constructor
A new instance of Has.
- #matches?(target) ⇒ Boolean
- #negative_failure_message ⇒ Object
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
#description ⇒ Object
32 33 34 |
# File 'lib/spec/matchers/has.rb', line 32 def description "have key #{@args[0].inspect}" end |
#failure_message ⇒ Object
22 23 24 25 |
# File 'lib/spec/matchers/has.rb', line 22 def raise @error if @error "expected ##{predicate}(#{@args[0].inspect}) to return true, got false" end |
#matches?(target) ⇒ 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_message ⇒ Object
27 28 29 30 |
# File 'lib/spec/matchers/has.rb', line 27 def raise @error if @error "expected ##{predicate}(#{@args[0].inspect}) to return false, got true" end |