[mocha-developer] Need some help in reducing my repetions in tests with Mocha

Jonathan Stott jonathan.stott at gmail.com
Sat May 3 16:40:46 EDT 2008

On Sat, 3 May 2008 10:31:31 -0400
"John D. Hume" <duelin.markers at gmail.com> wrote:

> That object could also potentially expose the bits its composed to keep you
> from having to do something as unreadable as
>   url.split('?', 2).last =~ /token=#{@token}/
> for every parameter.

Well, that is mostly because I don't want to implement a full URL params parser for testing, really :)

I guess it would help the clarity of the tests though.  (it's just unneeded for the library as a whole, which only ever has to construct urls)

> Maybe one object's job is to bring together the elements of the todoist
> request and another's is to format requests into URLs (or with slightly
> broader scope, to use them to interact with Net::HTTP), so you can spec the
> former with lines like
>   url.params['token'].should == @token
> and the other can be specified without the details of the todoist API
> getting in the way.

I think I will take your and Jay's suggestion to split my method apart a little at least, even if I don't go for full on 'HttpQuery' object.  


More information about the mocha-developer mailing list