【发布时间】:2010-12-01 23:30:02
【问题描述】:
大家好;在使用 rspec 编写从控制器到控制器的测试时,我发现自己重复了一些基本测试,例如检查索引:
describe "on GET to index" do
it "renders the index template" do
get :index
response.should render_template('index')
end
end
当添加到五个不同的控制器时,我觉得测试很重要,只是多余的。有没有办法在控制器类之间共享测试,或者在 rspec 中包含带有方法调用的特定代码块?或者在这种情况下,复制是最佳做法吗?
【问题讨论】:
标签: ruby-on-rails unit-testing rspec