Added 'application' configuration setting to set a Rack app to allow changing routes in controller specs #471

Closed
wants to merge 1 commit into
from
@@ -1,5 +1,6 @@
RSpec.configure do |config|
config.add_setting :infer_base_class_for_anonymous_controllers, :default => false
+ config.add_setting :application, :default => ::Rails.application
end
module RSpec::Rails
@@ -122,7 +123,7 @@ def method_missing(method, *args, &block)
metadata[:type] = :controller
before do
- @routes = ::Rails.application.routes
+ @routes = RSpec.configuration.application.routes
ActionController::Base.allow_forgery_protection = false
end
end
@@ -3,10 +3,12 @@
describe "configuration" do
before do
@orig_render_views = RSpec.configuration.render_views?
+ @orig_application = RSpec.configuration.application
end
after do
RSpec.configuration.render_views = @orig_render_views
+ RSpec.configuration.application = @orig_application
end
describe "#render_views?" do
@@ -23,4 +25,10 @@
RSpec.configuration.render_views?.should be_true
end
end
+
+ describe "#application" do
+ it "is Rails.application by default" do
+ RSpec.configuration.application.should eq(::Rails.application)
+ end
+ end
end