I have the following files.

# application_controller_spec.rb

require 'spec_helper'

describe ApplicationController do
  controller do
    def index       
      raise CanCan::AccessDenied.new("Not authorized!", :read, Order)
    end
  end

  describe "rescue from AccessDenied" do
    it "should rescue from CanCan::AccessDenied" do
      get :index
      response.should redirect_to("/")
    end
  end

end

# application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery

  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end
end

But when I run the spec get the following error:

Failure/Error: response.should redirect_to("/")
 Expected response to be a <:redirect>, but was <200>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to