I need to test a two-stage login system which first asks for your email address and password and then presents the user with two select lists containing [a-zA-Z0-9]. The labels beside the drop down's are of the form 'Select character X from your security phrase', where X is a random character index from a known security phrase.
I'd rather not stub the code for an acceptance test, so is it possible to write a matcher in cucumber which will, given that we know the whole phrase, select the required character in each of the two lists?
Here is the scenario I have so far and the steps involved:
Scenario: valid login email, password and secret phrase takes me to the dashboard
Given I am not logged in
When I log in as "
[email protected]"
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
For example, if the security phrase is 'Secret123', X = 3 and Y = 8, the above would have to produce the equivalent of:
select "c", :from => "Select character 3 of your security phrase"
select "2", :from => "Select character 8 of your security phrase"
The numbers X and Y in the actual page are inside span#svc_1 and span#svc_2 respectively.
Thanks,