Created
November 10, 2009 11:29
-
-
Save anonymous/230814 to your computer and use it in GitHub Desktop.
RSpec that should pass, but does not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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