说,我有一个这样的试验: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
中定义自定义匹配器,但是我们如何定义测试呢?
谢谢,这正是我需要的。 –