-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #668 from rspec/routing_specs_can_set_routes
Allow routing specs to access engine routes
- Loading branch information
Showing
2 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Feature: engine routes | ||
|
||
Routing specs can specify the routeset that will be used for the example | ||
group. This is most useful when testing Rails engines. | ||
|
||
Scenario: specify engine route | ||
Given a file named "spec/routing/engine_routes_spec.rb" with: | ||
"""ruby | ||
require "spec_helper" | ||
# A very simple Rails engine | ||
module MyEngine | ||
class Engine < ::Rails::Engine | ||
isolate_namespace MyEngine | ||
end | ||
Engine.routes.draw do | ||
resources :widgets, only: [:index] | ||
end | ||
class WidgetsController < ::ActionController::Base | ||
def index | ||
end | ||
end | ||
end | ||
describe MyEngine::WidgetsController do | ||
routes { MyEngine::Engine.routes } | ||
it "routes to the list of all widgets" do | ||
expect(:get => widgets_path). | ||
to route_to(:controller => "my_engine/widgets", :action => "index") | ||
end | ||
end | ||
""" | ||
When I run `rspec spec` | ||
Then the examples should all pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters