Running an individual shoulda context test
By kenglish
I’m suffering from serious CRS. Yesterday, I was wondering how to run my shoulda tests individually. My co-worker said “Just google for it.” I entered a google search term and the 4th or 5th result was a post by ME to the shoulda google group. This was the post: Can you controller context test just one test via the -n flag?
To reinforce the lesson, you can run a single context using a regular expression.
context "on GET to :show for first record" do setup do get :show, :id => 1 end should_assign_to :sweater should_respond_with :success should_render_template :show end
Although, you need to put quotes around the regular expression or the command line interpreter mistaked the spaces for separate arguments:
ruby test/functional/sweater_controller_test.rb -n "/show for first record/"



February 25th, 2009