开发者

Testing drag and drop functionality in rails 3

开发者 https://www.devze.com 2023-04-06 16:17 出处:网络
How do you simulate drag and drop functionality from rspec request specs? I have #divItem element I am dragging and dropping in #divContainer element (jquery). On page refresh I want to make sure tha

How do you simulate drag and drop functionality from rspec request specs?

I have #divItem element I am dragging and dropping in #divContainer element (jquery). On page refresh I want to make sure that #divItem element is within #开发者_Python百科divContainer element.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消