m = mock("blah") m.should_receive(:foo).and_return([1, 2, 3]) When foo() is called on the mock it returns the first elements of the array, 1. Shouldn''t it return the whole array? Micah Martin 8th Light, Inc. www.8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061027/60d8fce9/attachment.html
On 10/27/06, Micah Martin <micah at 8thlight.com> wrote:> > m = mock("blah") > m.should_receive(:foo).and_return([1, 2, 3]) > > When foo() is called on the mock it returns the first elements of the array, > 1. Shouldn''t it return the whole array?Yes it should. And it does in 0.7. The "feature" that you are experiencing was an early attempt to support consecutive return values. For 0.6, if you want it to return an Array you have to wrap it in an array: m.should_receive(:foo).and_return([[1, 2, 3]]) 0.7 is coming up very soon though! David> > Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >
On 10/27/06, Micah Martin <micah at 8thlight.com> wrote:> > m = mock("blah") > m.should_receive(:foo).and_return([1, 2, 3]) > > When foo() is called on the mock it returns the first elements of the array, > 1. Shouldn''t it return the whole array? >rspec version? the semantics of and_return have recently changed on trunk. see changelog.> Micah Martin > 8th Light, Inc. > www.8thlight.com > > > > > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >