[rspec-users] restful named routes

Jonathan Linowes jonathan at parkerhill.com
Wed Aug 15 16:02:31 EDT 2007


Hi,
revisiting this issue, I feel I'm getting closer:

describe CommentsController, "named routes" do
   before do
     @post = mock_model(Post, :id => 22)
   end

   it "should generate post_comments_path" do
     controller.post_comments_path(@post).should == "/posts/22/comments"
   end
end

results in:

NoMethodError in 'CommentsController named routes should generate  
post_comments_path'
protected method `post_comments_path' called for #<CommentsController: 
0x34ab3cc>

Is there a way around this?
Or how are other testing named routes?

thanks
linoj




On May 29, 2007, at 7:52 AM, Scott Taylor wrote:

>
> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote:
>
>>
>> - Is there a way to test named routes?
>
> I don't think there is a very clean & direct way (hopefully the
> others on the list can correct me).  The rspec rest generator
> generates some code to check the routes, so you could use something
> like that.
>
> Scott
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list