Skip to content

Instantly share code, notes, and snippets.

@bbonamin
Created July 17, 2012 14:18
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbonamin/3129666 to your computer and use it in GitHub Desktop.
Save bbonamin/3129666 to your computer and use it in GitHub Desktop.
Capybara drag and drop
shared_examples_for "driver with javascript support" do
before { @driver.visit('/with_js') }
describe '#find' do
it "should find dynamically changed nodes" do
@driver.find('//p').first.text.should == 'I changed it'
end
end
describe '#drag_to' do
it "should drag and drop an object" do
draggable = @driver.find('//div[@id="drag"]').first
droppable = @driver.find('//div[@id="drop"]').first
draggable.drag_to(droppable)
@driver.find('//div[contains(., "Dropped!")]').should_not be_nil
end
end
describe "#evaluate_script" do
it "should return the value of the executed script" do
@driver.evaluate_script('1+1').should == 2
end
end
end
(http://blog.plataformatec.com.br/2010/04/best-ruby-open-source-test-suites-awards/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment