2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-28 19:11:41 -05:00
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
Capybara::SpecHelper.spec '#accept_confirm', requires: [:modals] do
|
2013-04-01 18:41:55 -04:00
|
|
|
before do
|
|
|
|
@session.visit('/with_js')
|
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should accept the confirm' do
|
2013-04-01 18:41:55 -04:00
|
|
|
@session.accept_confirm do
|
|
|
|
@session.click_link('Open confirm')
|
|
|
|
end
|
|
|
|
expect(@session).to have_xpath("//a[@id='open-confirm' and @confirmed='true']")
|
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should return the message presented' do
|
2013-04-01 18:41:55 -04:00
|
|
|
message = @session.accept_confirm do
|
|
|
|
@session.click_link('Open confirm')
|
|
|
|
end
|
|
|
|
expect(message).to eq('Confirm opened')
|
|
|
|
end
|
2015-09-28 19:19:04 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should work with nested modals' do
|
2018-02-28 19:11:41 -05:00
|
|
|
expect do
|
2015-09-28 19:19:04 -04:00
|
|
|
@session.dismiss_confirm 'Are you really sure?' do
|
|
|
|
@session.accept_confirm 'Are you sure?' do
|
|
|
|
@session.click_link('Open check twice')
|
|
|
|
end
|
|
|
|
end
|
2018-02-28 19:11:41 -05:00
|
|
|
end.not_to raise_error
|
2015-09-28 19:19:04 -04:00
|
|
|
expect(@session).to have_xpath("//a[@id='open-twice' and @confirmed='false']")
|
|
|
|
end
|
2016-03-07 19:52:19 -05:00
|
|
|
end
|