[rspec-users] RESTful Routes

Raimond Garcia voodoorai2000 at gmail.com
Mon Feb 4 12:16:16 EST 2008

> On 4.2.2008, at 14.54, Raimond Garcia wrote:
>> Hi,
>> I'm trying to test the behavior of a route with a delete method.
>> Something like this:
>> When "the admin clicks on 'delete'" do
>>    delete admin_blog_path(@blog)
>>  end
>> which raises the following exception:
>> NoMethodError: You have a nil object when you didn't expect it!
>> The error occurred while evaluating nil.env
>> If I change the delete, for a get or a post it works like a charm.
>> What am I missing here?
> I would recommend against using the restful named routes in your
> stories. You want to test your full stack there, right, so just use
> the url. I also recommend using Webrat in conjunction with stories: http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
> That way you are much more testing the behaviour of the application
> rather than its implementation.
> If you only want to test that the route is working, it would imho
> belong to the controller specs, not to the stories.
> Cheers,
> //jarkko
> --
> Jarkko Laine
> http://jlaine.net
> http://dotherightthing.com
> http://www.railsecommerce.com
> http://odesign.fi

Interesting Jarkko...

The restful routes, seem clearer than using urls, maybe not so much  
for this case, but for very long urls, that include for example the  
title of a blog, I would rather use blog_path(@blog).

Yes, I want to test the full stack, for sure! However, I don't see how  
using named routes, stops you from doing this....

Webrat two thumbs up, I've been using selenium up to now, but would  
like to try other alternatives to see which one works better.


Raimond Garcia

P.S. This message is repeated with the wrong subject somewhere in the  
mailing list, sorry about that ;-|

More information about the rspec-users mailing list