Make your shoulda tests faster with fast_context
Published about 5 years ago
I’ve been using Shoulda for a while. And for my current project, I decided to go fixtureless with Shoulda + Factory Girl. All good, except one problem. Slow as fuck tests. So here’s fast_context as a solution for it. fast_context compiles all the ’should’s within a context into a single test.
For example :
class UsersControllerTest < ActionController::TestCase fast_context "#new" do setup do @user = Factory(:user) get :new end should_render_template :new should_render_with_layout :users end end
This will be compiled into something like :
class UsersControllerTest < ActionController::TestCase test "test: #new should run_fast" @user = Factory(:user) get :new should_render_template :new should_render_with_layout :users end end
As your setup method just once per fast_context, the tests run much faster.
To install :
script/plugin install git://github.com/lifo/fast_context.git
This was a result of a short time of hacking. So there may be bugs. Please comment here if you run into any issues.