Skip to content


Subversion checkout URL

You can clone with
Download ZIP


request.env['HTTPS'] = 'on' leads to NoMethodError #616

reiz opened this Issue · 7 comments

3 participants


I am using rspec 2.11.0 with rails 3.2.8. In one of my controllers I am using the "force_ssl". In the testcase I am using "request.env['HTTPS'] = 'on'" to switch to https. Unfortunately I am getting always the same error message:

Failure/Error: request.env['HTTPS'] = 'on'
undefined method `env' for nil:NilClass

Any ideas?


See #596.

@dchelimsky dchelimsky closed this

It's still not working for me. I have a very simple testcase:

post "/users", :user => {:fullname => "test123", :email => "", :password => "test123"}, "HTTPS" => "on"
assert_response :success

But instead of success I am getting a 301.
How can I force a post via https?


It always seems simple :)

Is this a request spec or controller spec?


This is a request spec.


Here are some additional informations. This test case works fine:

get "/signup", nil, "HTTPS" => "on"
assert_response :success

But the example with post doesn't work.


I think I see the problem - the way you have it formatted "HTTPS" is a key in the wrong hash. Try this:

post "/users", { :user => {:fullname => "test123", :email => "", :password => "test123"} }, "HTTPS" => "on"
@dchelimsky dchelimsky reopened this

Yep. That's it :-)
Many Thanks for your help.

@alindeman alindeman closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.