简体   繁体   中英

Testing a modal dialog with RSpec and Capybara

When I click 'Log In' on the navbar a modal dialog pops up rendering the log in partial.

How would I go about testing this using RSpec and Capybara?

<!--....-->
<li><%= link_to "Log in", '#', data: {:'reveal-id' => 'loginModal'} %></li>
<!--....-->

<div id="loginModal" class="reveal-modal">
  <%= render 'devise/sessions/new' %>
  <a class="close-reveal-modal">&#215;</a>
</div>

Try:

visit your_page_path
click_link "Log in"
page.should have_content('a_modal_content_here') # async

Please consider using the following,

within('#loginModal') do
  page.should have_content('a_modal_content_here') # async
end

to look for your content in the modal only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM