最初にメールアドレスとパスワードを要求し、次に[a-zA-Z0-9]を含む2つの選択リストをユーザーに提示する2段階のログインシステムをテストする必要があります。ドロップダウンの横のラベルは、「セキュリティフレーズから文字Xを選択」の形式です。ここで、Xは既知のセキュリティフレーズからのランダムな文字インデックスです。
検収試験のためにコードをスタブしたくないので、キュウリでマッチャーを書くことは可能ですか?それは、フレーズ全体を知っているので、2つのリストのそれぞれで必要な文字を選択しますか?
これまでのシナリオと関連する手順は次のとおりです。
Scenario: valid login email, password and secret phrase takes me to the dashboard
Given I am not logged in
When I log in as "admin@example.com"
Then I should be on the dashboard page
And I should see "Your Dashboard"
When /^I log in as "([^\"]*)"$/ do |login|
visit path_to('Login page')
fill_in "Email", :with => login
fill_in "Password", :with => "Password123"
click_button "Log in"
response.should contain("Please verify some characters from your security phrase")
select "a", :from => "Select character X of your security phrase"
select "b", :from => "Select character Y of your security phrase"
click_button "Submit"
end
たとえば、セキュリティフレーズが「Secret123」、X = 3、Y = 8の場合、上記は次と同等のものを生成する必要があります。
select "c", :from => "Select character 3 of your security phrase"
select "2", :from => "Select character 8 of your security phrase"
実際のページの番号XとYは、それぞれspan#svc_1とspan#svc_2の中にあります。
ありがとう、