[rspec-users] Stubs and contract tests

David Chelimsky dchelimsky at gmail.com
Fri May 11 16:48:54 UTC 2012


On Fri, May 11, 2012 at 9:24 AM, Alexandre de Oliveira <
chavedomundo at gmail.com> wrote:

> 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?
>

See https://github.com/rspec/rspec-mocks/issues/15
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120511/d13f1ff1/attachment.html>


More information about the rspec-users mailing list