Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abachman/422998 to your computer and use it in GitHub Desktop.
Save abachman/422998 to your computer and use it in GitHub Desktop.
Accomodating rails' default javascript-driven "delete" link behavior in Cucumber.
# web_steps.rb
When /^I am going to confirm all js popups on this page$/ do
# hackish, but not unreasonable.
page.evaluate_script("window.alert = function(msg) { return true; }")
page.evaluate_script("window.confirm = function(msg) { return true; }")
end
# some_feature.feature
# note that "I am going to confirm..." has to be called after arriving on
# a page and before pressing links that use confirm (delete, in most cases)
@javascript
Scenario: Admin user should be able to delete an existing category
Given I am an admin user with the login "admin" and the password "password"
And there is a active study
And a category exists with name: "Behavioral", category_type: "treatment"
And I login as "admin" authenticating with "password"
When I follow "Categories" within "#treatment_lists_categories_link"
And I am going to confirm all js popups on this page
And I follow "Delete Behavioral"
Then I should be on the admin categories page
And I should not see "Behavioral" within "#content_panel"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment