Skip to content

Instantly share code, notes, and snippets.

@gkop
Created June 12, 2012 23:09
Show Gist options
  • Save gkop/2920731 to your computer and use it in GitHub Desktop.
Save gkop/2920731 to your computer and use it in GitHub Desktop.
Drag thing in to other thing capybara step
## in features/support/selectors.rb
when /^the (?<type>\w+){1} "(?<name>[^"]*){1}"$/
[:xpath, "//li[contains(@class, '#{$~[:type]}') and contains(., '#{$~[:name]}')]"]
## in features/step_definitions/drag_things_steps.rb
def find_by_selector(thing)
selector = selector_for(thing)
find(selector[0], selector[1])
end
When /^I drag (.+) into (.+)$/ do |thing, other_thing|
find_by_selector(thing).drag_to(find_by_selector(other_thing))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment