Class: Spec::Matchers::Has
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected, *args, &block) ⇒ Has
constructor
A new instance of Has.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected, *args, &block) ⇒ Has
Returns a new instance of Has.
6 7 8 |
# File 'lib/spec/matchers/has.rb', line 6 def initialize(expected, *args, &block) @expected, @args, @block = expected, args, block end |
Instance Method Details
#description ⇒ Object
22 23 24 |
# File 'lib/spec/matchers/has.rb', line 22 def description "have key #{@args[0].inspect}" end |
#failure_message_for_should ⇒ Object
14 15 16 |
# File 'lib/spec/matchers/has.rb', line 14 def "expected ##{predicate(@expected)}(#{@args[0].inspect}) to return true, got false" end |
#failure_message_for_should_not ⇒ Object
18 19 20 |
# File 'lib/spec/matchers/has.rb', line 18 def "expected ##{predicate(@expected)}(#{@args[0].inspect}) to return false, got true" end |
#matches?(actual) ⇒ Boolean
10 11 12 |
# File 'lib/spec/matchers/has.rb', line 10 def matches?(actual) actual.__send__(predicate(@expected), *@args, &@block) end |