[rspec-users] Easy way to specify protocol for a controller spec?

Will Sargent will.sargent at gmail.com
Fri Apr 11 14:47:16 EDT 2008

Hi all,

I'd like to add some controller specs that use HTTPS rather than HTTP.
 I've poked a bit into the get() and post() methods that are provided
by ControllerTestCase, but it doesn't seem as though there's an easy
way to specify that it should be using SSL from there.

In ActionController, I can specify request.ssl! to force the request
to be over HTTPS, but it looks like the request object provided by
ControllerTestCase is using ActionController::TestRequest... and to do
that, you'd usually do ths:

@request.env['HTTPS'] = 'on'  # from http://snippets.dzone.com/posts/show/467

But when I try this in a controller spec, this gives me a 302 redirect:

request.env['HTTPS'] = 'on'
get :foo

So I must be missing something.  Anyone know how to do this?


More information about the rspec-users mailing list