Testing a modal dialog with RSpec and Capybara

rspec, ruby-on-rails

Solution

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.

Problem

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> ```

Original source