When I joined Crowdtap last June, I needed to massively refactor one of our applications, and I needed to seriously speed up my workflow.
I wanted things to be instant and interactive. I needed to feel closer to the code.
I tried Spork, but found it limited in what it could do: switching from rspec/cucumber is hard, reloading is problematic. Zeus lifts these limitations, but introduces new ones. Regardless, These solutions solve the instant problem to some extent, but do not address the interactive one.
I am approaching the problem differently. Instead of having to use a preloader, I found that staying in the ruby interactive shell turns out to be very effective. To support my workflow, I made irb-config. It allows running RSpec/Cucumber tests directly in the rails console.
I am a heavy user of Vim, but it doesn’t have a shell like Emacs. Fortunately, we have tmux to the rescue. By using the vim screen plugin, we can integrate vim and irb-config, which is more powerful than using something like guard-rspec in my opinion.
Let me share my workflow with you.
download mp4 (09:13 / 720p / 26Mb)
1. Install irb-config
git clone git://github.com/nviennot/irb-config.git ~/.irb cd ~/.irb make install
You don’t need to change any of your projects.
irb-config is pervasive:
.irbrc file is loaded, irb-config adds the global gemset to Bundler,
and loads Pry.
2. Setup some vim bindings
a. You can use my vim-config:
git clone git://github.com/nviennot/vim-config.git ~/.vim cd ~/.vim make install
b. Or install the screen plugin and add these bindings to your config:
3. Setup a proper tmux config (optional)
git clone git://github.com/nviennot/tmux-config.git ~/.tmux cd ~/.tmux make install
If you are using OSX you will have to fiddle your Terminal settings to enable the Alt key.
If you are using Linux, you are good to go.
If you are using Windows, you deserve better.
Starting in the dev environment
When doing testing in the console with irb-config, always run
and let irb-config switch between your development environment and test
environment. This will allow painless reloading.
If you application has some gems that do not like to have their environment
switched, start the console with
rails c test. But be careful, you will
have to use
:W to reload the files you are changing.
Config files references