Rails3 – RSpec – How to set request.env?-Collection of common programming errors

I try to stub my request.env

require 'spec_helper'

describe AuthenticationController do
  render_views
  include Devise::TestHelpers

  describe "GET 'create'" do
    @request.env["HTTP_REFERER"] = '/'

results in

`method_missing': undefined method `env' for nil:NilClass (NoMethodError)

How can I put data into my request.env object before calling the method? Also using request.env = does not work.

Originally posted 2013-11-09 22:10:54.