开发者

Sharing Rspec tests between classes

Hey all; in writing tests from controller to controller with rspec, I've found myself 开发者_如何学Cduplicating 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜