Class: Templater::Spec::Helpers::InvokeMatcher
- Inherits:
-
Object
- Object
- Templater::Spec::Helpers::InvokeMatcher
- Defined in:
- lib/templater/spec/helpers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ InvokeMatcher
constructor
A new instance of InvokeMatcher.
- #matches?(actual) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #with(*arguments) ⇒ Object
Constructor Details
#initialize(expected) ⇒ InvokeMatcher
Returns a new instance of InvokeMatcher.
6 7 8 |
# File 'lib/templater/spec/helpers.rb', line 6 def initialize(expected) @expected = expected end |
Instance Method Details
#failure_message ⇒ Object
28 29 30 |
# File 'lib/templater/spec/helpers.rb', line 28 def "expected #{@actual.inspect} to invoke #{@expected.inspect} with #{@with}, but it didn't" end |
#matches?(actual) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/templater/spec/helpers.rb', line 10 def matches?(actual) @actual = actual # Satisfy expectation here. Return false or raise an error if it's not met. found = nil @actual.invocations.each { |i| found = i if i.class == @expected } if @with return found && (@with == found.arguments) else return found end end |
#negative_failure_message ⇒ Object
32 33 34 |
# File 'lib/templater/spec/helpers.rb', line 32 def "expected #{@actual.inspect} not to invoke #{@expected.inspect} with #{@with}, but it did" end |
#with(*arguments) ⇒ Object
23 24 25 26 |
# File 'lib/templater/spec/helpers.rb', line 23 def with(*arguments) @with = arguments return self end |