Railsã¨capybaraã§ä½ãããã©ãã°ã¢ã³ããããããã¦ã½ã¼ããããã¹ããæ¸ã
ä»åã¯ã«ãã´ãªãç»é¢ã§ã½ã¼ãã§ãããã¨ããã¹ãããããã¨ãã°ããã°ã§è¨ãã°ããã°ã«ãã´ãªã®è¡¨ç¤ºé ã管çç»é¢ã§ã½ã¼ããããã¨ãããªã©ã®è©±ã
ãããªç»é¢ã§ããã©ãã°ã¢ã³ãããããã§ã½ã¼ãå¾ãæ´æ°ãã¿ã³ãæ¼ãããããã®é çªã«æ´æ°ããããã¨ããä»æ§ã®ãã¹ããæ¸ãã
å®è£
ã¯ããã§ã¯çãã¨ãã¦ããã¹ããæ¸ããã¨æã£ãã¨ãã«D&Dãã©ããããããã¤ã³ãã«ãªãã¨æãããã
ã§ãcapybara-webkitã«ã¯drag_toã¨ããã¡ã½ãããããã®ã§ãããã§è§£æ±ºããã
ãªã®ã§ãcapybara-webkitã使ãåæãªã®ã§ä½¿ããããã«ãã¨ãã¦ãã ããã
ã¡ãªã¿ã«ã½ã¼ãUIã«ã¯jquery-sortableã使ã£ã¦ã¾ãã
å
·ä½çã«ã¯ãããªæãã
view
<section id="blog-categories" class="categories"> <header class="page-header clearfix"> <h1>ã«ãã´ãªç·¨é</h1> </header> <ol id="category-list" class="list-group sortable-list-group"> <% @categories.each do |c| -%> <li class="list-group-item"><%= c.name %><span class="glyphicon glyphicon-sort pointer"></span></li> <% end -%> </ol> <button class="btn btn-warning"><%= t('views.categories.strings.sort_btn') -%></button> </section>
spec
before do @category1 = FactoryGirl.create(:category) @category2 = FactoryGirl.create(:category) end # webkitã¯on scenario 'sorting categories', js: true do visit categories_path expect(page).to have_title I18n.t('views.categories.actions.index.title') # æåã®é çªãç¢ºèª expect(find('#category-list li:first-child')).to have_text @category1.name expect(find('#category-list li:last-child')).to have_text @category2.name # ï¼ã¤ç®ã®ãªã¹ãè¦ç´ ãï¼çªãã®ã¨ããã¾ã§D&D draggable = find('#category-list li:first-child .pointer') droppable = find('#category-list li:last-child') draggable.drag_to(droppable) # ããããããããã®é çªã«ãªã£ã¦ãããç¢ºèª expect(find('#category-list li:first-child')).to have_text @category2.name expect(find('#category-list li:last-child')).to have_text @category1.name click_button I18n.t('views.categories.strings.sort_btn') # æ´æ°ãã¿ã³æ¼ä¸å¾ããªãã¼ããã¦ãé çªãç¶æããã¦ããã確èªã visit current_path expect(find('#category-list li:first-child')).to have_text @category2.name expect(find('#category-list li:last-child')).to have_text @category1.name end
ããã§ã¯ãæ´æ°ãã¿ã³ãæ¼ãã¨åæ ãããä»æ§ã«ãªã£ã¦ããã©ãããããæã«åæ ããã¦ããããã¦å¤ãããªãã¯ãã
ã¹ã¼ãã¼ããªãª 3Dã¯ã¼ã«ã
- åºç社/ã¡ã¼ã«ã¼: 任天å
- çºå£²æ¥: 2013/11/21
- ã¡ãã£ã¢: Video Game
- ãã®ååãå«ãããã° (27件) ãè¦ã