[rspec-users] Spec'ing chained calls

Levy Carneiro Jr. levy at levycarneiro.com
Sat Mar 14 10:51:47 EDT 2009

Hello Scott,

On Fri, Mar 13, 2009 at 11:59 AM, Scott Taylor <scott at railsnewbie.com>wrote:

> http://c2.com/cgi/wiki?LawOfDemeter
> 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.

Actually, the method 'fetch_new_tweets' is the wrapper. There's another
method called 'process_new_tweets', which calls some methods from the Tweet
class, including fetch_new_tweets.

But I see your point. Testing only the output from this wrapper (integration
tests), and not testing the internal actions being done inside
Twitter::Search, which Tweet shouldn't know about.

So, the ideal would be the Twitter::Search class to provide some
ready-to-use wrappers for me, the way I want it. Like the postman and wallet
example [1]. But, since it clearly doesn't have all wrappers I need,
shouldn't my own class, Tweets, be doing the several wrappers and testing
them on my own? Or, there is a better design pattern in this case?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090314/a8ff179a/attachment.html>

More information about the rspec-users mailing list