title: Testing newly injected content with Rspec and Capybara
body: <p>We're using react components in our Rails views, one of which when a button is clicked renders another component in its place.  </p>
  
  <p>Ideally we want to back these up with Rspec feature tests but when the button is clicked and the new component is renders the value of <code>page</code> isn't updated to reflect this.</p>
  
  <p>Is there a way with Rspec/Capybara to get the newly injected content after the new react component as rendered?</p>
  
  <p>Here's the snippet:</p>
  
  <pre><code>scenario 'users should be able to move to step 2', js: true do
    sign_in_with 'test@test.com', 'testpassword'
    visit new_path
    fill_in 'name', with: 'Test'
    select "Category One", :from =&gt; "dropdown"
    click_button 'Next'
    expect(page).to have_content('New Content')
  end
  </code></pre>