Sharing Rspec Tests Between Classes

Hello to all; when writing tests from controller to controller using rspec, I found that I was duplicating several basic tests, such as this check for the index:

describe "on GET to index" do it "renders the index template" do get :index response.should render_template('index') end end 

I feel the test is important, just redundant when added to five different controllers. Is there a way to share tests between controller classes or include specific blocks of code with a method call in rspec? Or is it best practice for duplication, in this case?

+4
source share
1 answer

Yes you can , and I think this will lead to cleaner code.

+3
source

All Articles