module RSpec::Rails::ControllerExampleGroup::ClassMethods
def self.name; "AnonymousController"; end
def self.name; "AnonymousController"; end
def controller(base_class = nil, &body)
- Note: - Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
def controller(base_class = nil, &body) base_class ||= RSpec.configuration.infer_base_class_for_anonymous_controllers? ? controller_class : ApplicationController metadata[:example_group][:described_class] = Class.new(base_class) do def self.name; "AnonymousController"; end end metadata[:example_group][:described_class].class_eval(&body) before do @orig_routes = self.routes self.routes = ActionDispatch::Routing::RouteSet.new.tap { |r| r.draw { resources :anonymous } } end after do self.routes = @orig_routes @orig_routes = nil end end
def controller_class
- Private: -
def controller_class described_class end
def routes(&blk)
# ...
routes { MyEngine::Engine.routes }
describe MyEngine::PostsController do
@example
is most useful when testing Rails engines.
Specifies the routeset that will be used for the example group. This
def routes(&blk) before do self.routes = blk.call end end