Rails Env Switcher

Rails Env Switcher allows your to switch from a rails environmemnt to another one.
Best served chilled with irb-config.

Why is it useful?

We want to run tests from the rails console.

Watch the screencast

Watch the screencast!

Usage

gem 'rails-env-switcher'

If you have Pry installed, you will have access to the env command:

pafy@bisou ~/prj/rails-prj [master

Programmatically:

RailsEnvSwitcher.with_env 'test', :reload => true do
  # Do some stuff in the test environment
  # reload => true means that we want to reload!
  # Leaving the block returns in the original environment
  # with_env is nestable
end

# You can also switch permantently with
RailsEnvSwitcher.switch_env 'staging'

TODO

  • Middleware pattern
  • Testing

License

MIT License