I see a lot of questions and answers about Capybara not waiting for an AJAX request to complete before testing for content, but I need to do the opposite: I want to test that a loading message is present before the AJAX request is done.
How would I check content is shown before an AJAX request is done with Capybara in RSpec?
Thanks!
I figured it out...
If you want to check something right away without waiting for AJAX to finish, you just check the text with an include:
page.find('#id').text.should include('loading...')
If you do want to wait for AJAX to return you use have_content:
page.find('#id').should have_content('loaded')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With