Skip to content


Subversion checkout URL

You can clone with
Download ZIP
What's happening with the env hash in test mode?
Ruby JavaScript CoffeeScript
Branch: master
Failed to load latest commit information.
app First commit
config First commit
db First commit
doc First commit
lib First commit
log First commit
script First commit
spec First commit
vendor First commit
.gitignore First commit
.rspec First commit
Gemfile removed public/index.html
Gemfile.lock removed public/index.html updated readme
Rakefile First commit

App for this question on stack overflow.

In my Rails app, I'm accessing the env hash in one of my controller actions.

Something along the lines of:

def my_before_filter
  env['some.key'] = "Something or other"

This works great for my requirements.

If I start my Rails app in test environment, and visit an action like:

# /users in UsersController#index
def index
  puts env.inspect

Then the content of the env hash is output to the console as expected.

When I get this action from within an RSPec example, the output is an empty hash?

it 'should get the index action' do
  get :index
.....{}.... # rspec output

Why is the env hash empty?

Something went wrong with that request. Please try again.