[rspec-users] chain argument expectations?
dchelimsky at gmail.com
Thu Jun 17 13:22:07 EDT 2010
On Jun 17, 2010, at 11:07 AM, Chuck Remes wrote:
> I'm trying to test some code that can loop once or multiple times and assign some values to another object. I want to test one of the values being assigned to the object in the loop.
> class Foo
> def bar
> values = returns_an_array_of_values
> baz = Baz.new
> values.each_with_index do |value, index|
> baz.field1 = Constant
> baz.field2 = index
> baz.field3 = value
> it "should assign increasing index values to field3" do
> quxxo = mock
> Baz.stub!(:new => quxxo)
> This doesn't work. I tried a few different variants.
> that doesn't work either.
> Any suggestions on how to set expectations for a single mock to receive the same message multiple time with different arguments with the express purpose of validating the arguments?
More information about the rspec-users