Hello,
My comments are currently routed inside of my articles, so my routes
file looks like the following:
resources :articles do
resources :comments
end
I am trying to write an Rspec test that tests whether or not guests
(non-signed-in users) can comment on my articles with the following
inside of my comments controller test:
it "should deny access to 'create'" do
post :create
response.should redirect_to(signin_path)
end
I get an error when running the test:
No route matches {:controller=>“comments”, :action=>“create”}
I think this is because it is trying to test a route on
localhost/comments/create, but I need the test to take place within
localhost/articles/id/comments/create
Now, I have the following variable in the before(:each) part of my test
file:
@article = Factory(:article, :user => @user, :title => “Article
Title”, :content => “Article Content”)
I want to test if a guest can create a comment in @article, but I am
unsure of how to do that.