1 # Records missing calls and dumps them at the end.
3 # -rmissing -e '$early = true' script.rb
4 # to have it raise NoMethodError, otherwise it continues,
5 # passing a mock down, gathering up missing behavior.
14 def initialize(recv, name, args)
15 @recv, @name = recv.inspect, name
19 @args = args.map { |i| i.inspect }.join(", ")
24 def method_missing(meth, *args)
28 args = args.map { |i| i.inspect }.join(", ")
31 @sub_calls << [meth, args]
36 print "#{@recv}.#{@name}"
43 @sub_calls.each do |meth, args|
55 def method_missing(meth, *args)
56 obj = MissedCall.new(self, meth, args)
59 raise NoMethodError, "Couldn't find a '#{meth}' on a #{self.inspect}"
66 print "\nDetected #{MissedCalls.size} missed calls.\n\n"
67 MissedCalls.each { |c| c.show }