Skip to content

Instantly share code, notes, and snippets.

@chromeragnarok
Created September 16, 2011 12:37
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 chromeragnarok/1222036 to your computer and use it in GitHub Desktop.
Save chromeragnarok/1222036 to your computer and use it in GitHub Desktop.
// JS Stuffs here
$("#add-new").droppable({
accept: ".draggable-stuffs",
drop: handleDrop
});
function handleAddNewDrop(event, ui) {
// do stuffs with your event and ui params... or not.
}
# some web steps to be called on your cukes...
When /^I drag the div "([^"]*)" to the add-new dropzone$/ do |div_id|
javascript = <<-eos
var ui = { draggable: $("#{div_id}")}; // this is a mock ui object that is to be passed in the method
handleAddNewDrop($.Event("drop"), ui);
eos
page.execute_script javascript
end
When /^I change the group\-box number (\d+) title to "([^"]*)"$/ do |order, new_title|
javascript = <<-eos
var selectedGroupBox = $($(".group-box")[#{order}]);
selectedGroupBox.find(".edit").click();
selectedGroupBox.find("input").val("#{new_title}");
selectedGroupBox.find("input").blur();
eos
page.execute_script javascript
end
@chromeragnarok
Copy link
Author

These are just some examples how you can actually trigger events and call functions from your cukes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment