After completing Listing 10.40 and running rspec / spec / controllers / users_controller_spec.rb, I got 1 failure for the section (all other tests in the 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 understand if there is a mistake in the textbook code, or if I made a mistake somewhere.
source
share