我有这个控制器规格文件。
describe BriefNotesController do
render_views
before(:all) do
@customer=Factory(:customer)
@project=Factory(:project_started, :owner => @customer)
end
context 'get :new' do
it 'should redirect to login page for not signed in users' do
get :new, :project_id => @project.id
response.should new_user_session_path
end
end
context 'get :create' do
it 'should redirect to login page for not signed in users' do
post :create, {:project_id => @project.to_param, :brief_note => Factory.attributes_for(:brief_note, :project_id => @project.id)}
response.should redirect_to new_user_session_path
end
end
在这些测试中,我对每个操作重复相同的身份验证测试,因此我想用干的方式重新编码它。我试图用shared_examples_for
方法重新编码这个测试,但我没有处理它。