Skip to content

Commit

Permalink
test nested modal commands
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jul 8, 2014
1 parent 10e8450 commit 024b20b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/capybara/spec/public/test.js
Expand Up @@ -71,6 +71,10 @@ $(function() {
alert('Alert opened');
$(this).attr('opened', 'true');
});
$('#open-nested-alert').click(function() {
alert('First nested alert opened');
alert('Second nested alert opened');
})
$('#open-delayed-alert').click(function() {
var link = this;
setTimeout(function() {
Expand Down
12 changes: 12 additions & 0 deletions lib/capybara/spec/session/accept_alert_spec.rb
Expand Up @@ -54,4 +54,16 @@
expect(@session).to have_xpath("//a[@id='open-slow-alert' and @opened='true']")
end
end

context "with nested modals" do
it "should accept both alerts" do
message2 = @session.accept_alert do
message = @session.accept_alert do
@session.click_link('Open nested alert')
end
expect(message).to eq('First nested alert opened')
end
expect(message2).to eq('Second nested alert opened')
end
end
end
4 changes: 4 additions & 0 deletions lib/capybara/spec/views/with_js.erb
Expand Up @@ -75,6 +75,10 @@
<p>
<a href="#" id="open-alert">Open alert</a>
</p>

<p>
<a href="#" id="open-nested-alert">Open nested alert</a>
</p>

<p>
<a href="#" id="open-delayed-alert">Open delayed alert</a>
Expand Down

0 comments on commit 024b20b

Please sign in to comment.