Jquery 在rails 3中测试拖放功能

Jquery 在rails 3中测试拖放功能,jquery,selenium,capybara,Jquery,Selenium,Capybara,如何模拟rspec请求规范中的拖放功能 我将#divItem元素拖放到#divContainer元素(jquery)中。在页面刷新中,我希望确保#divItem元素位于#divContainer元素内 it "should drag item to new list", :js => true do item = Item.create!(:title => "title 1", :group => "group 1") # verify that item is w

如何模拟rspec请求规范中的拖放功能

我将#divItem元素拖放到#divContainer元素(jquery)中。在页面刷新中,我希望确保#divItem元素位于#divContainer元素内

it "should drag item to new list", :js => true do
  item = Item.create!(:title => "title 1", :group => "group 1")

  # verify that item is withing group 1
  visit items_path
  within("#group 1") do # id of a div element (or ul element)
    page.should have_content("title 1")
  end    

  item_element = find("##{item.id}")     
  new_group_element = find("#group 2")
  item_element.drag_to new_group_element

  # verify that after page reload item is withing the new group
  visit items_path
  within("#group 2") do 
    page.should have_content("title 1")
  end

end