2014-01-29 2 views

답변

8

가 여기

<td id="name" contenteditable="true"><%= @name %></td> 
<td><button id="update" class="btn btn-sm btn-default">Update</button></td> 

나는이 실패 사양을 얻을 ...이 사양으로

...

scenario "Using valid input" do 
    fill_in "name", with: "Zinn" 
    click_button "Update" 
    expect(page).to have_content("Update successful!") 
end 

...이 환경 파일 ... 내가 어떻게 문제를 해결했는지. this thread 당신의 contentEditable div의에 fill_in 도우미를 사용할 수 있어야합니다 것 같습니다,하지만 난 그 일을 가져올 수 없습니다에 따르면

feature "Editing", js: true do 

    scenario "with valid input" do 
    el = find(:xpath, "//div[@contenteditable='true' and @name='name']") 
    el.set("Zinn") 
    el.native.send_keys(:return) 
    expect(page).to have_content("Update successful!") 
    expect(page).to have_content("Zinn") 
    end 

end 

.

+0

capybara 2.4.1에서는 작동하지 않습니다. 'el.text' 또는'have_content'로 텍스트를 확인하는 것은 원본 텍스트를 보여줍니다. – BM5k

+0

필자는 phantomjs 1.9.7과 poltergeist 1.5.1을 사용하고 있다고 덧붙여 야합니다. – BM5k

+0

Poltergeist JS에서는': return'이 아닌'el.native.send_keys (: Enter)'가 될 것입니다. – Mike