After completing listing Listing 10.40 and running rspec /spec/controllers/users_controller_spec.rb, I got 1 failure for section (all other tests in 'destroy' section are passed)
describe "DELETE 'destroy'" do
before(:each) do
@user = Factory(:user)
end
describe "as a non-signed-in user" do
it "should deny access" do
delete :destroy, :id => @user
response.should redirect_to(signin_path)
end
end
end
Here is the console output:
Failures:
1) UsersController DELETE 'destroy' as a non-signed-in user should deny access
Failure/Error: delete :destroy, :id => @user
undefined method `admin?' for nil:NilClass
# ./app/controllers/users_controller.rb:66:in `admin_user'
# ./spec/controllers/users_controller_spec.rb:282:in `block (4 levels) in <top (required)>'
I can't figure out whether there is an error in the tutorial's code or I made a mistake somewhere.
I believe that readers who run into this problem are simply missing the :destroy method in the :authenticate before filter introduced in Listing 10.11. (Note: I am the author of the book.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With