說,我有一個這樣的試驗:Rspec的:定義測試組的方法,它的參數
describe "signin" do
before { visit root_path }
describe "with invalid data" do
before { click_button "Sign in" }
it { should have_error_message("Invalid") }
it { should_not have_link("Sign out") }
it "should redirect to same page" do
current_path.should == root_path
end
end
end
而且我想在任何要進行相同的測試另一頁太(不root_path
):它應該被重定向到同一頁面。
所以,我想保持乾燥,因此要在一個位置聲明此測試,並用不同的參數調用它:首先使用root_path
,然後再使用其他頁面。
我知道我們可以在support/utilities.rb
中定義自定義匹配器,但是我們如何定義測試呢?
謝謝,這正是我需要的。 –