danneu/symposium — Issue #6: PostsController tests not passing
Author: terenceponce
Created: 2012-01-17 03:03:39+00:00
State: open

I'm not sure why all the tests are passing on your machine, but on mine it's not. I tried imitating the tests you made for the ForumsController, but no dice. Here's the error that I've been getting:

Failures:

1) PostsController GET 'show' returns http success
Failure/Error: get :index
AbstractController::ActionNotFound:
The action 'index' could not be found for PostsController
# ./spec/controllers/posts_controller_spec.rb:7:in `block (3 levels) in '

2) PostsController GET 'new' returns http success
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:15:in `block (3 levels) in '

3) PostsController GET 'create' returns http success
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:22:in `block (3 levels) in '

4) PostsController GET 'edit' returns http success
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:29:in `block (3 levels) in '

5) PostsController GET 'update' returns http success
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:36:in `block (3 levels) in '

6) PostsController GET 'destroy' returns http success
Failure/Error: response.should be_success
expected success? to return true, got false
# ./spec/controllers/posts_controller_spec.rb:43:in `block (3 levels) in '

I did a bit of investigation and I figured that the cause of the failure is that it requires authentication for it to pass, so I tried following [this tutorial](https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29) on the Devise Wiki. I guess it kind of worked because the cause of the failure changed:

ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken

I think Ryan Bates mentioned something about [using sequences on Factory Girl](http://railscasts.com/episodes/158-factories-not-fixtures?view=asciicast#clippy_3425798) to solve that problem, but I can't seem to get it right. I think this is the best that I can do regarding this issue. I've been trying to fix this for almost 2 hours now, but I don't think I'll be able to fix this on my own.