public
Last active — forked from matschaffer/example.feature

  • Download Gist
example.feature
Cucumber
1 2 3 4 5 6 7 8 9 10 11
@javascript
Scenario: confiming when saving inactive
Given I expect to click "OK" on a confirmation box saying "Are you sure?"
When I press "Save"
Then the confirmation box should have been displayed
And I should see "TV" in the "Campaign Keywords" section
 
Scenario: alert when form is not valid
Given I expect to click on an alert box saying "Please complete all fields in this form"
When I press "Save"
Then the alert box should have been displayed
steps.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Given /^I expect to click "([^"]*)" on a confirmation box saying "([^"]*)"$/ do |option, message|
retval = (option == "OK") ? "true" : "false"
 
page.evaluate_script("window.confirm = function (msg) {
$.cookie('confirm_message', msg, {path: '/'});
return #{retval};
}")
 
@expected_message = message
end
 
Then /^the confirmation box should have been displayed$/ do
page.evaluate_script("$.cookie('confirm_message')").should_not be_nil
page.evaluate_script("$.cookie('confirm_message')").should eq(@expected_message)
page.evaluate_script("$.cookie('confirm_message', null)")
end
 
Given /^I expect to click on an alert box saying "([^"]*)"$/ do |message|
page.evaluate_script("window.alert = function (msg) {
$.cookie('alert_message', msg, {path: '/'});
return true;
}")
 
@expected_message = message
end
 
Then /^the alert box should have been displayed$/ do
page.evaluate_script("$.cookie('alert_message')").should_not be_nil
page.evaluate_script("$.cookie('alert_message')").should eq(@expected_message)
page.evaluate_script("$.cookie('alert_message', null)")
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.