# How to use Rspec to test Comments?

**URL:** <https://www.ruby-forum.com/t/how-to-use-rspec-to-test-comments/194435>\
**Category:** Rails\
**Created:** [September 6, 2010, 1:31am UTC](https://www.ruby-forum.com/t/how-to-use-rspec-to-test-comments/194435 "2010-09-06T01:31:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/90ced4/32.png) [@kelp](https://www.ruby-forum.com/u/kelp)\
**Post date:** [September 6, 2010, 1:31am UTC](https://www.ruby-forum.com/t/how-to-use-rspec-to-test-comments/194435/1 "2010-09-06T01:31:59Z")

</div>

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.
