class Grasshopper::Stub
Public Class Methods
like(stubs)
click to toggle source
# File lib/grasshopper/stub.rb, line 21 def self.like(stubs) stub = Stub.new stubs.each do |method, retval| Stub.when(stub.send(method)).then_return(retval) end stub end
new()
click to toggle source
# File lib/grasshopper/stub.rb, line 3 def initialize @stubs = {} end
when(whatever)
click to toggle source
# File lib/grasshopper/stub.rb, line 11 def self.when(whatever) StubHelper.new(@@stub, @@message) end
Public Instance Methods
add_a_stub(message, retval)
click to toggle source
# File lib/grasshopper/stub.rb, line 7 def add_a_stub(message, retval) @stubs[message] = retval end
method_missing(sym, *args)
click to toggle source
# File lib/grasshopper/stub.rb, line 15 def method_missing(sym, *args) @@stub = self @@message = [sym, args] @stubs[[sym, args]] end