Skip to content

Commit 724578d

Browse files
committed
Sets #controller_path in all versions of Rails
* Fixes #316
1 parent a77de85 commit 724578d

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Bug fixes
1111

1212
* Add `should` and `should_not` to `CollectionProxy` (Rails 3.1+) and
1313
`AssociationProxy` (Rails 3.0). (Myron Marston)
14+
* `controller.controller_path` is set correctly for view specs in Rails 3.1+.
15+
(Andy Lindeman)
1416

1517
### 2.11.0 / 2012-07-07
1618
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.10.1...v2.11.0)

features/view_specs/inferred_controller_path.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Feature: view spec infers controller path and action
88
describe "widgets/new" do
99
it "infers the controller path" do
1010
expect(controller.request.path_parameters[:controller]).to eq("widgets")
11+
expect(controller.controller_path).to eq("widgets")
1112
end
1213
end
1314
"""

lib/rspec/rails/example/view_example_group.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ def _include_controller_helpers
142142
if view.lookup_context.respond_to?(:prefixes)
143143
# rails 3.1
144144
view.lookup_context.prefixes << _controller_path
145-
else
146-
# rails 3.0
147-
controller.controller_path = _controller_path
148145
end
146+
147+
controller.controller_path = _controller_path
149148
controller.request.path_parameters[:controller] = _controller_path
150149
controller.request.path_parameters[:action] = _inferred_action unless _inferred_action =~ /^_/
151150
end

0 commit comments

Comments
 (0)