Nestor: A Butler for Your Tests
At yesterday’s Montreal.rb I presented Nestor, an autotest-like framework. This is it’s official release announcement.
Nestor is different in that it uses an explicit state machine, namely Aaron Pfeifer‘s StateMachine. Nestor also uses Martin Aumont’s Watchr to listen to filesystem events. But the biggest difference is that the default Rails + Test::Unit is a forking test server. Nestor will load the framework classes—ActiveRecord, ActionController, ActionView, plugins and gems—only once. This saves a lot of time on the aggregate versus running rake everytime.
This release of Nestor is 0.2 quality: it’s not ready for large projects. It only supports Rails + Test::Unit, probably doesn’t run on 1.9 or JRuby, but it’s a solid foundation for going further. In the coming days, I will blog on the internals of Nestor and how StateMachine allowed me to add plugins with very little effort.
Installation
1 $ gem install nestor 2 $ cd railsapp 3 $ # edit config/environments/test.rb to set cache_classes to false 4 $ nestor
I already have a plugin that enables Growl notifications. Install and use:
1 $ gem install nestor_growl 2 $ cd railsapp 3 $ nestor start --require nestor/growl
The —require option is where plugins are loaded. This is an Array of files Nestor will require on startup.
Notes
You must set cache_classes to false in test mode for now. This is a limitation of how Rails boots. With cache_classes set to true, Rails will load the controllers and models when it boots. Since this happens before forking, the code under test would never get reloaded. Did I say it was 0.2 quality?
