Sharing Rspec tests between classes
Hey all; in writing tests from controller to controller with rspec, I've found myself duplicating a few basic tests, such as this check for index:
describe "on GET to index" do it "renders the index template" do get :index response.should render_template('index') end end
I feel that the test is important, just redundant, when added to five different controllers. Is there some way to share tests between controller classes, or include specific code blocks with a method call in rspec? Or is it best practices to duplicate, in this case?
Yes you can, and I think it will lead to cleaner code.