[rspec-users] Problem testing method
matt at mattwynne.net
Thu Sep 25 07:44:49 EDT 2008
On 25 Sep 2008, at 11:51, Carlos Rafael Belizón Ibáñez wrote:
> And I got this error:
> Spec::Mocks::MockExpectationError in 'Alineado.cambiar_por with the
> in play and sustitutions aviable should decrement in one the
> sustitutions aviables'
> Mock 'Partido_1004' received unexpected message :cambios_visitante=
> And I don't know how fix this error. It's possible test this?
> P.D.: Sorry for my english.
> rspec-users mailing list
> rspec-users at rubyforge.org
Have a look at this:
When you call foo -= 1, ruby does two things:
(1) asks foo for its value
(2) tells foo to have a new value, one less than the answer it got
back from the first question.
If you re-write more verbosely, you'll see what I mean:
foo = foo - 1
Two operations are being done to foo. So if you want to mock out foo,
you have to mock out both those operations.
In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.
More information about the rspec-users