我正在使用Devise併爲用戶刪除自己的帳戶的方案編寫測試,但我卡在如何調用確認框並單擊確定。水豚&Rspec:如何刪除一個帳戶?
這裏是鏈接和我的測試:
<p><%= link_to "Delete my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
規格/請求/ users_spec.rb
scenario 'user deletes account' do
make_user_and_login
click_link('Account Settings')
page.should have_selector('title', :text => 'Account Settings')
click_link('Delete my account')
# Are You Sure?
# click OK in confirm box
# page.should etc.....
end
這將如何做呢?
希望這個答案會幫助你:http://stackoverflow.com/questions/2458632/how-to-test-a-confirm-dialog-with-cucumber –