David Chelimsky escribió: > On 10/8/07, Borja Martín <[EMAIL PROTECTED]> wrote: > >> Hi, >> I'm pretty new to all related to bdd and rspec and I have the following >> question. Is it possible to stub actions that return different objects >> depending on the parameteres they were called with?Something like this: >> >> MyClass.stub!(:method).with(1).and_return(@mock_object_1) >> MyClass.stub!(:method).with(2).and_return(@mock_object_2) >> > > What happened when you tried this? > > I become an error like this: ... undefined method `with' for #<Spec::Mocks::MethodStub:0xb6f20858> >> I know I could use MyClass.stub!(:method).and_return(@mock_object_1, >> @mock_object_2) so the first time the :method method is called, it would >> return the first object and then the second one, but the problem is that >> I cannot guarantee the order it will be called inside the model. >> >> Thanks in advance >> >> -- >> /** >> * dagi3d v4 | http://dagi3d.net >> */ >> >> _______________________________________________ >> rspec-users mailing list >> [email protected] >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users >
-- /** * dagi3d v4 | http://dagi3d.net */ _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
