module RSpec::Rails::ControllerExampleGroup::ClassMethods
def controller(base_class = ApplicationController, &body)
defined in +ApplicationController+, however, are accessible from within
+controller+ method. Any instance methods, filters, etc, that are
ApplicationController::AccessDenied) in the block passed to the
defined in +ApplicationController+ must be fully qualified (e.g.
NOTICE: Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
end
# ....
controller(ApplicationControllerSubclass) do
controller like so:
If you would like to spec a subclass of ApplicationController, call
end
end
end
response.should redirect_to("/401.html")
get :index
it "redirects to the /401.html page" do
describe "handling AccessDenied exceptions" do
end
end
raise ApplicationController::AccessDenied
def index
controller do
describe ApplicationController do
== Examples
defined in config/routes.rb.
up implicit routes for this controller, that are separate from those
ApplicationController and evals the +body+ in that context. Also sets
ApplicationController. Creates an anonymous subclass of
Supports a simple DSL for specifying behaviour of
def controller(base_class = ApplicationController, &body) metadata[:example_group][:describes] = Class.new(base_class, &body) metadata[:example_group][:describes].singleton_class.class_eval do def name "StubResourcesController" end end before do @orig_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new @routes.draw { resources :stub_resources } end after do @routes = @orig_routes end end