I'm a bit unsure about this. Here's my spec:
it 'hides the "Load more" link when the last page is reached', js: true, focus: true do
within "table.#{model.model_name.underscore.pluralize}" do
click_link 'Mehr laden'
end
page.should have_selector('.load_more a', visible: false)
end
This works, but I'm actually testing the implementation, which is not good practice. So I rewrote the spec like this:
it 'hides the "Load more" link when the last page is reached', js: true, focus: true do
within "table.#{model.model_name.underscore.pluralize}" do
click_link 'Mehr laden'
end
find_link("Mehr laden").should_not be_visible
end
But sadly, find_link
does not wait for the AJAX request to complete, so it fails. If I put a sleep 1
in front of it, it works.
How can I tell find_link
to wait (like has_selector?
)? I don't want to change any global configuration for this, and wait_until
will be deprecated in Capybara 2.
Thanks a lot for help, Josh