Permalink
Browse files

Move the "application swapping" to an `around` filter in the spec_hel…

…per.
  • Loading branch information...
1 parent 1a9d160 commit cf11980622f5f1d353234ade75efe2a7bab1da93 @justinko justinko committed Jun 24, 2012
@@ -97,17 +97,8 @@ module RSpec::Rails
end
end
- describe "#application", :at_least_rails_3_1 do
- before do
- @orig_application = RSpec.configuration.application
- RSpec.configuration.application = RSpec::EngineExample
- end
-
- after do
- RSpec.configuration.application = @orig_application
- end
-
- it "still delegates name routes to underlying controller" do
+ describe "custom application", :at_least_rails_3_1 do
+ it "delegates named routes to the underlying controller" do
controller = double('controller')
controller.stub(:bars_path).and_return('/foos')
@@ -19,16 +19,7 @@ module ::Rails; end
end
describe "custom application", :at_least_rails_3_1 do
- before do
- @orig_application = RSpec.configuration.application
- RSpec.configuration.application = RSpec::EngineExample
- end
-
- after do
- RSpec.configuration.application = @orig_application
- end
-
- it "should include custom application's url helpers" do
+ it "includes the custom application's url helpers" do
group = RSpec::Core::ExampleGroup.describe do
include MailerExampleGroup
end
@@ -29,17 +29,8 @@ module RSpec::Rails
end
end
- describe "custom application routes", :at_least_rails_3_1 do
- before do
- @orig_application = RSpec.configuration.application
- RSpec.configuration.application = RSpec::EngineExample
- end
-
- after do
- RSpec.configuration.application = @orig_application
- end
-
- it "provides routes of custom application" do
+ describe "custom application", :at_least_rails_3_1 do
+ it "provides routes of the custom application" do
group = RSpec::Core::ExampleGroup.describe do
include RoutingExampleGroup
end
@@ -50,7 +41,6 @@ module RSpec::Rails
example.stub(:routes => RSpec.configuration.application.routes)
example.bars_path.should == "/bars"
end
-
end
end
end
View
@@ -21,6 +21,12 @@ def self.run_all(reporter=nil)
config.filter_run :focus
if RSpec::Rails.at_least_rails_3_1?
config.filter_run_excluding :not_at_least_rails_3_1
+ config.around(:each, :at_least_rails_3_1) do |example|
+ orig_application = RSpec.configuration.application
+ RSpec.configuration.application = RSpec::EngineExample
+ example.run
+ RSpec.configuration.application = orig_application
+ end
else
config.filter_run_excluding :at_least_rails_3_1
end

0 comments on commit cf11980

Please sign in to comment.