using mocha, is there a way to stub with many parameters? using mocha, is there a way to stub with many parameters? ruby ruby

using mocha, is there a way to stub with many parameters?


If I got you right it can be something like:

class Foo  def bar(param1=nil, param2=nil, param3=nil)     :bar1 if param1     :bar2 if param2     :bar3 if param3  endenddescribe Foo do  it "returns 0 for all gutter game" do    foo = Foo.new    foo.stub(:bar).with { |*args| args[0] }.and_return(:bar1)    foo.stub(:bar).with { |*args| args[1] }.and_return(:bar2)    foo.stub(:bar).with { |*args| args[2] }.and_return(:bar3)    foo.bar(true).should == :bar1    foo.bar('blah', true).should == :bar2    foo.bar('blah', 'blah', true).should == :bar3  endend