Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2009 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/230814 to your computer and use it in GitHub Desktop.
Save anonymous/230814 to your computer and use it in GitHub Desktop.
RSpec that should pass, but does not.
# categories_controller_spec.rb
describe User::CategoriesController do
# ...
describe "GET assign" do
describe "with user having 0 categories" do
it "should redirect to action index" do
@login_user.stub_chain(:categories, :size).and_return(0)
response.should redirect_to(:action => 'index')
end
end
end
# ...
end
# categories_controller
def assign
if (current_user.categories.size <= 0)
redirect_to(:action => :index)
return
end
# ...
end
# autospec output
F................
1)
'User::CategoriesController GET assign with user having 0 categories should redirect to action index' FAILED
expected redirect to {:action=>"index"}, got no redirect
./spec/controllers/user/categories_controller_spec.rb:145:
Finished in 1.474359 seconds
17 examples, 1 failure
### Comments
# This test should pass, because the redirect takes place if @login_user.categories.size <= 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment