I have gone through the post of capybara + click on alert box but nothing seems to be work. Following is my scenario:
Scenario: When I click update
Try this line if you want to click on the ok button of the alert box:
page.evaluate_script('window.confirm = function() { return true; }')
Don't forget to mark your test with the javascript flag
it "update user to trainer", js: true do
...
end
and enable Capybara.javascript_driver with :webkit or :selenium in your spec_helper file