views:

467

answers:

1

In order to avoid adding

request.env["HTTP_REFERER"] = '/'

to a before block on every controller_spec file I create, I have tried to add this to the global config (in spec_helper.rb)

config.before(:each) {request.env["HTTP_REFERER"] = '/'}

The problem is, I get the following error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.env

Has anyone any pointers on how to implement this correctly?

Cheers!

+2  A: 

Have you tried

  config.before(:type => :controller) do
    request.env["HTTP_REFERER"] = "/"
  end
Matt Darby
Cheers - Works perfectly!
Mr. Matt