On 31 Dec 2008, at 16:11, aslak hellesoy wrote:

On Wed, Dec 31, 2008 at 5:02 PM, David Chelimsky <dchelim...@gmail.com> wrote:
> So do you recommend never doing helper specs?

I never said never :-) Here is my manifesto styled take on this:

"I favour testing directly accessible APIs over indirectly accessible ones."

In Rails, I usually try to write a spec against a controller or view before I resort to a helper spec.

Aslak


Interesting. I've ended up going in the other direction. I started out writing tests for UI code at the view level, treating helper methods as implementation details, just as you're describing. This seemed to result in view specs that were fragile, with lots of mocks to set up, and duplicated spec logic where helper code was re-used in different views. I now prefer to put all the interesting stuff in the helpers, unit test that, use Cucumber to make sure the view doesn't blow up, and do very little testing of the view itself.

I guess in the context of your little manifesto, I've started to think of the methods you put in helpers as being the API that's used by the designer who hacks on the views.


Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to