[rspec-users] Named routes problem... more rails than rspec

David Chelimsky dchelimsky at gmail.com
Sun Jan 30 09:09:21 EST 2011


On Jan 30, 2011, at 3:48 AM, Jason Nah wrote:

> Howdy,
> 
> I have emailed before about the inconsistencies I'm spotting when using named routes/resource, but I think I've narrowed down the issue. It would seem this has nothing to do with rspec per se, but more with how routing works with rails.
> 
> If you have an object instance, that isn't saved and you attempt to generate a path for that item, even though the item may have an ID, you get a "No route matches" exception.
> 
> If the item is saved, then a valid route can be generated for that item.
> 
> Two things seem odd:
> The exception raised isn't very informative
> Why is this a constraint? And can it be turned off for testing purposes?
If that's how the framework works and it's an internal thing like this, turning it off for testing purposes would just lead to confusion.
> Is there a way around this? Or do I need to use rspec mock objects?

You can either use mock_model or mock_stub (which each act like saved objects unless you tell them otherwise), or use real objects saved to the db.

HTH,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110130/2330258b/attachment.html>


More information about the rspec-users mailing list