Skip to content

Commit

Permalink
Move the "application swapping" to an around filter in the spec_hel…
Browse files Browse the repository at this point in the history
…per.
  • Loading branch information
justinko committed Jun 24, 2012
1 parent 1a9d160 commit cf11980
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
13 changes: 2 additions & 11 deletions spec/rspec/rails/example/controller_example_group_spec.rb
Expand Up @@ -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')

Expand Down
11 changes: 1 addition & 10 deletions spec/rspec/rails/example/mailer_example_group_spec.rb
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions spec/rspec/rails/example/routing_example_group_spec.rb
Expand Up @@ -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
Expand All @@ -50,7 +41,6 @@ module RSpec::Rails
example.stub(:routes => RSpec.configuration.application.routes)
example.bars_path.should == "/bars"
end

end
end
end
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -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
Expand Down

0 comments on commit cf11980

Please sign in to comment.