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')

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.

Need Your Help

unable to get column names when using skip along with read.csv

r rstudio

I was using the skip option in read.csv to skip a few lines before reading into my data frame from a csv file. However, when I do a names(dataframe) upon doing this, I lose my column names and get ...