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"
end
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
end
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
end
.....{}.... # rspec output
Why is the env hash empty?
I've built a dummy rails app to show this
use
request.env
instead of just env within the controller code.
e.g/
def index
puts request.env.inspect
end
Hope that helps?
BTW on another note: when working with your github repo you need to delete the public/index.html for your root route to work, when running the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With