Hi,

I have a problem that got me stucks for hour now. I do not think that it's 
that hard. I'm just unable to find the correct documentation

Given this example.

it 'test' do
  obj = double()
  allow(obj).to receive(:a)

  obj.a(:arg_1)
  obj.a(:arg_2)

  expect(obj).to(
    have_received(:a).with(:arg_3)
  )
end

rspec will give me a nice error with the list of args received

#<Double (anonymous)> received :a with unexpected arguments
         expected: (:arg_3)
              got: (:arg_1) (1 time)
                      (:arg_2) (1 time)

whih is very nice. Now if I change a bit the test

it 'test' do
  obj = double()
  allow(obj).to receive(:a)

  obj.a(:arg_1)
  obj.a(:arg_2)

  expect(obj).to(
    have_received(:a).with(:arg_2).twice
  )
end

I have a new error message without the call list
  (Double (anonymous)).a(:arg_2)
           expected: 2 times with arguments: (:arg_2)
           received: 1 time with arguments: (:arg_2)

No problem I can choose my to make my own custom message

expect(obj).to(
have_received(:a).with(:arg_2).twice,
"#{??}"
)

But how can I retrieve the call list used un the first case? Do I have to 
call it from obj ? Or since I have acces to the matcher instance. I can 
call a method to retrieve it ?

If you can help me or point me in the right direction I would be really 
thankfull.




-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/582fac2b-4272-4a52-b086-0b2661da3f41n%40googlegroups.com.

Reply via email to