From 511ad01c79bd688b6bee17522c8d7ba916f04998 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Thu, 17 Nov 2011 12:12:33 +0800 Subject: [PATCH 1/2] request.path_parameters 'controller' and 'action' keys should be symbols, since they are symbols in the real Rails environment. --- lib/rspec/rails/example/view_example_group.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rspec/rails/example/view_example_group.rb b/lib/rspec/rails/example/view_example_group.rb index f78d3878d5..f33a648c97 100644 --- a/lib/rspec/rails/example/view_example_group.rb +++ b/lib/rspec/rails/example/view_example_group.rb @@ -133,8 +133,8 @@ def _include_controller_helpers # rails 3.0 controller.controller_path = _controller_path end - controller.request.path_parameters["controller"] = _controller_path - controller.request.path_parameters["action"] = _inferred_action unless _inferred_action =~ /^_/ + controller.request.path_parameters[:controller] = _controller_path + controller.request.path_parameters[:action] = _inferred_action unless _inferred_action =~ /^_/ end end end From bc987266b8b3aa2e0dd24fbb3510e70be613a165 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 11 Jan 2012 17:09:02 +0800 Subject: [PATCH 2/2] Added cucumber test to ensure that controller.request.path_parameters contains symbols for keys --- features/view_specs/view_spec.feature | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/view_specs/view_spec.feature b/features/view_specs/view_spec.feature index f668a0bbfc..cbdeb50bf7 100644 --- a/features/view_specs/view_spec.feature +++ b/features/view_specs/view_spec.feature @@ -158,3 +158,17 @@ Feature: view spec """ When I run `rspec spec/views/secrets` Then the examples should all pass + + Scenario: request.path_parameters should match Rails by using symbols for keys + Given a file named "spec/views/widgets/index.html.erb_spec.rb" with: + """ + require "spec_helper" + + describe "controller.request.path_parameters" do + it "matches the Rails environment by using symbols for keys" do + [:controller, :action].each { |k| controller.request.path_parameters.keys.should include(k) } + end + end + """ + When I run `rspec spec/views` + Then the examples should all pass