Get rid of the Rails development environment
When Rails projects grow, setting up a representable development environment becomes harder and harder.
- Designers should not know about the one special case in your app making it i.e. show additional fields of your model or having a specific state.
- Developers usually have a hard time setting up the situation to reproduce a bug.
All these problems are acually already addressed by BDD tools like Cucumber.
- Most of the special cases should already be documented in a Feature.
- Writing a Feature for it helps targetting the bug precisely.
But when the moment comes of styling the page / debugging, Rails' testing environment does not really help. Classes are cached, most components won't be re-evaluated even when changed, and additionally the assets from the pipeline are usually compressed for faster running tests (similar to production).
This is where Develotest comes in:
- Write your feature, tag it with @javscript to run it in a real browser
- Have cucumber step that pauses execution of the suite.
We use
binding.pry
in 'When I pause' directly after the page is visited the first time - Set shell env variable (in bash:
export DEVELOTEST=yes
) - Run the feature, wait for the browser to pop up and pause.
- Edit assets or ruby code in app/
- Reload page in browser as you would normally do in development
- Changes should be recognized.
- repeat at 4.
- Profit!
Add rails-develotest
to your Gemfile
gem 'rails-develotest', group: 'test'
At the bottom of your config/environments/test.rb
, but within the configure
block:
# .. a lot of config.foo = 23
Develotest.setup(config)
end
Bundle. Done.