Capybara config after each page load
<p>I'm looking for a generic way to configure RSpec Capybara to do something after each page load within test example.</p>

<p>Example:</p>

<pre><code>config.after_page_load do
  execute_script('window.analyticsEvents = []; window.analytics = function(name, properties) { analyticsEvents.push([name, properties]) }')
end
</code></pre>

<p>Then I can check that array in my feature test.</p>

<p>Only other option for a "global" configuration that I can think of is use <code>if Rails.env.test?</code> in the view.</p>

<p>Is there a better way?</p>