Skip to content

Instantly share code, notes, and snippets.

@vitobotta
Forked from matschaffer/example.feature
Created June 4, 2012 21:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitobotta/2870951 to your computer and use it in GitHub Desktop.
Save vitobotta/2870951 to your computer and use it in GitHub Desktop.
Cucumber - confirmation box with JavaScript
@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
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)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment