Check if Capybara::Node::Element has been removed by jQuery.remove()

Viewed 530

I'm trying to make the following test:

it 'remove item from cart' do
  visit cart_path
  button = page.find("a[href='/carts/#{item.id}/remove']")
  card = find_ancestor_with_class(button, '.card')
  button.click
  # check if card has been removed from page
end

This test is suppossed to work because the following JS removes the card from page:

$.ajax({
  url: link,
  method: "GET",
  success: function() {
    $('#alert-modal').modal('show');
    $(button).closest(".card").remove();
  }
});

How I verify if the .card html has been removed from page?

1 Answers
Related