How to use Rspec to test Comments?

My comments are currently routed inside of my articles, so my routes
file looks like the following:

resources :articles do
resources :comments

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)

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

Now, I have the following variable in the before(:each) part of my test
@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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs