[rspec-users] Spec'ing chained calls

Scott Taylor scott at railsnewbie.com
Fri Mar 13 10:59:14 EDT 2009

Levy Carneiro Jr. wrote:
> Hello!
> I'm trying to spec a method, that has several chained calls.
> http://gist.github.com/78562 (spec)
> http://gist.github.com/78563 (model)
> In the first spec, I'm trying to focus on the method calls that have 
> to be made, and the arguments they should receive.
> Is there a better way to spec the behaviour for these chained calls? 
> It just seems too many lines to me :)


Specs are as much of a design tool as a testing tool, and the use of 
mocks in your specs show just how ugly the current design is.

Either write a wrapper around the library which takes care of the method 
chaining, or write integration tests against it, stubbing out some low 
level detail of the library.


> Thanks a lot!
> Levy
> PS: I'm using my branch of the twitter gem, at 
> http://github.com/levycarneiro/twitter, which just adds this method 
> 'not_retweeted'.
> ------------------------------------------------------------------------
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list