1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
Elliot Winkler b695c2f978 Rename DelegateMatcher to DelegateMethodMatcher
Matcher classes are named after the matcher method itself.
2014-08-29 11:57:26 -06:00

37 lines
827 B
Ruby

module Shoulda
module Matchers
module Independent
class DelegateMethodMatcher
# @private
class StubbedTarget
def initialize(method)
@received_method = false
@received_arguments = []
stub_method(method)
end
def has_received_method?
received_method
end
def has_received_arguments?(*args)
args == received_arguments
end
protected
def stub_method(method)
class_eval do
define_method method do |*args|
@received_method = true
@received_arguments = args
end
end
end
attr_reader :received_method, :received_arguments
end
end
end
end
end