Extract the construction of the rspec command into a function