In my Rails app there is a whole lot of front-end js, and I'd like to check is a specific event is attached to a DOM element.
An example of the JS that adds the event is here:
$('.nextCard')[0].addEventListener('click',nextCard);
I'd like to write something like:
expect(page).evaluate_script('$._data( $(".nextCard")[0], "events" )').to eq('nextCard');
I know it's a bit cryptic, and I could test the JS separately ... but I would like to do all the testing with Ruby / Capybara if possible.
How to return a value when using execute_script in capybara?