Created
October 26, 2009 11:48
-
-
Save floehopper/28c2100fa7b1a7f2071c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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