Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

request.path_parameters has strings as keys, while in real environment it's symbols #461

Closed
ndbroadbent opened this Issue Nov 11, 2011 · 6 comments

Comments

Projects
None yet
2 participants
Contributor

ndbroadbent commented Nov 11, 2011

Following on from this comment on issue #172.

I'm writing tests for code that uses controller.request.path_parameters, but I have to use symbolize_keys in order to stay 'compatible' with RSpec:

controller.request.path_parameters.symbolize_keys[:action]

symbolize_keys is an ok workaround, but I really think that the path_parameters should match those in the real Rails environment.

If you think it's a good idea, I'll change it to have symbols as keys, and send a pull request.

Owner

dchelimsky commented Nov 12, 2011

Can you show me an example of the spec and code? I'm not clear on what gets expressed where.

Contributor

ndbroadbent commented Nov 12, 2011

I'm not sure if an example spec & code will provide any more insight.

Debugger when running specs:

puts controller.request.path_parameters
# => {"controller" => "contacts", "action" => "new" }

Debugger on development environment:

puts controller.request.path_parameters
# => {:controller => "contacts", :action => "new" }

Rails has changed the keys to symbols, but RSpec is still using the old string keys.

Owner

dchelimsky commented Nov 12, 2011

I'm pretty sure that's coming from the rails test framework. Can you try the same in a rails functional test?

Sent from my iPhone

On Nov 12, 2011, at 10:54 AM, Nathan Breply@reply.github.com wrote:

I'm not sure if an example spec & code will provide any more insight.

Debugger when running specs:

puts controller.request.path_parameters
# => {"controller" => "contacts", "action" => "new" }

Debugger on development environment:

puts controller.request.path_parameters
# => {:controller => "contacts", :action => "new" }

Rails has changed the keys to symbols, but RSpec is still using the old string keys.


Reply to this email directly or view it on GitHub:
#461 (comment)

Contributor

ndbroadbent commented Nov 12, 2011

It can be fixed by changing the following lines in rspec-rails:

https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example/view_example_group.rb#L150

I can change this, update the tests, and send a pull request, if you think it's ok. I'm being very hesitant because RSpec is such a huge project, and small changes like this can sometimes break other things in unforeseen ways. It seems safe enough to me, though.

Owner

dchelimsky commented Nov 12, 2011

Go for it.

Owner

dchelimsky commented Apr 22, 2012

Closed by #463.

@dchelimsky dchelimsky closed this Apr 22, 2012

@dchelimsky dchelimsky added a commit that referenced this issue Apr 23, 2012

@dchelimsky dchelimsky fix cuke broken by #461 3ad5d8a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment