rspec/rspec-rails — pull request #471 by szimek (2011-12-12 15:06:58+00:00)
Title: Added 'application' configuration setting to set a Rack app to allow changing routes in controller specs

Currently RSpec hardcodes `Rails.application.routes` in controller specs (https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/controller_example_group.rb#L125) This makes it hard to run controller specs for Rails engines that provide their own route set.

Currently I need to set routes manually in before block in every test - I can't do it in RSpec config, because before block of `ControllerExampleGroup` runs after before block in RSpec config and overwrites `@route` variable.

With this new setting one can just do:

```ruby
RSpec.configure do |config|
config.application = MyApp::Engine
end
```

in engine's spec_helper.rb and it will properly set routing for controller specs.

Additionally it would be great if it could also do:

```ruby
RSpec.configure do |config|
config.include MyApp::Engine.routes.url_helpers
end
```

but it's not included in this commit.

If you think that the whole idea makes sense, I can add some more detailed tests, because right now I only added tests for the new `application` setting.