class Templater::Spec::Helpers::InvokeMatcher

Public Class Methods

new(expected) click to toggle source
# File lib/templater/spec/helpers.rb, line 6
def initialize(expected)
  @expected = expected
end

Public Instance Methods

failure_message() click to toggle source
# File lib/templater/spec/helpers.rb, line 28
def failure_message
  "expected #{@actual.inspect} to invoke #{@expected.inspect} with #{@with}, but it didn't"
end
matches?(actual) click to toggle source
# 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() click to toggle source
# File lib/templater/spec/helpers.rb, line 32
def negative_failure_message
  "expected #{@actual.inspect} not to invoke #{@expected.inspect} with #{@with}, but it did"
end
with(*arguments) click to toggle source
# File lib/templater/spec/helpers.rb, line 23
def with(*arguments)
  @with = arguments
  return self
end