Skip to content

Instantly share code, notes, and snippets.

@floehopper
Created October 26, 2009 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floehopper/28c2100fa7b1a7f2071c to your computer and use it in GitHub Desktop.
Save floehopper/28c2100fa7b1a7f2071c to your computer and use it in GitHub Desktop.
require 'mocha/parameter_matchers/base'
module Mocha
module ParameterMatchers
def integer_equivalent(value)
IntegerEquivalent.new(value)
end
class IntegerEquivalent < Base
def initialize(value)
@value = value
end
def matches?(available_parameters)
parameter = available_parameters.shift
return false unless parameter.respond_to?(:to_i)
parameter.to_i == @value
end
def mocha_inspect
"integer_equivalent(#{@value.mocha_inspect})"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment