[rspec-users] Stubs and contract tests

Alexandre de Oliveira
Fri, 11 May 2012 14:24:19 -0000

Hey guys, could you help me (in)validating an idea?

As you might know, Contract tests solve a problem stubs have: if the object
interface changes, the stubbed tests will continue passing.

In RSpec, it''s common to use a shared_context to describe contracts, so
both Posts and Comments tests would have PostsCommentsContract. If
Comment''s interface ever changed, Posts tests would present a failure
wherever we ran it. However, it won''t tell us which stubbed methods
were
invalid now; it just tell us the file that have invalid stubs.

If we had, for example, #stub_contract(:method), automatically raising
a failure if its reference (double) object''s interface changed, how
would
it be bad?

I''m trying to think the cons of it. Could you guys help me finding it?

--Alexandre
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20120511/85d2f4ab/attachment.html>