diff --git a/lib/capybara/driver/webkit/node.rb b/lib/capybara/driver/webkit/node.rb
index 18efa6e..e253577 100644
--- a/lib/capybara/driver/webkit/node.rb
+++ b/lib/capybara/driver/webkit/node.rb
@@ -29,7 +29,9 @@ class Capybara::Driver::Webkit
end
def drag_to(element)
- raise NotImplementedError
+ trigger('mousedown')
+ element.trigger('mousemove')
+ element.trigger('mouseup')
end
def tag_name
diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb
index 58d115f..fc23437 100644
--- a/spec/driver_spec.rb
+++ b/spec/driver_spec.rb
@@ -6,16 +6,23 @@ describe Capybara::Driver::Webkit do
lambda do |env|
body = <<-HTML
- Change me, please
+ Change me
+ Push me
+ Release me
Next
@@ -140,12 +147,21 @@ describe Capybara::Driver::Webkit do
end
it "fires a mouse event" do
- subject.find("//*[@id='changeMe']").first.trigger("mouseup")
- subject.find("//*[@id='mouseup']").should_not be_empty
+ subject.find("//*[@id='mouseup']").first.trigger("mouseup")
+ subject.find("//*[@class='triggered']").should_not be_empty
end
it "fires a non-mouse event" do
- subject.find("//*[@id='changeMe']").first.trigger("change")
- subject.find("//*[@id='change']").should_not be_empty
+ subject.find("//*[@id='change']").first.trigger("change")
+ subject.find("//*[@class='triggered']").should_not be_empty
+ end
+
+ it "fires drag events" do
+ draggable = subject.find("//*[@id='mousedown']").first
+ container = subject.find("//*[@id='mouseup']").first
+
+ draggable.drag_to(container)
+
+ subject.find("//*[@class='triggered']").size.should == 2
end
end