title: How to subscribe to all query methods with ActiveSupport::Notifications
body: <p>I am not understanding an ActiveSupport::Notifications behaviour. I'm currently using ruby 2.5.0 and rails 5.2 and I'm trying to make a custom matcher for rspec (3.7.0) to verify if a query has been triggered or not. Currently my matcher looks like this:</p>
  <pre><code>RSpec::Matchers.define :trigger_query do
    supports_block_expectations
  
    match do |block|
      count_queries(&amp;block).positive?
    end
  
    def count_queries &amp;block
      count = 0
  
      counter_f = -&gt;(_name, _started, _finished, _unique_id, payload) {
        count += 1 unless %w[CACHE SCHEMA].include?(payload[:name])
      }
  
      ActiveSupport::Notifications.subscribed(
        counter_f,
        &quot;sql.active_record&quot;,
        &amp;block
      )
  
      count
    end
  end
  </code></pre>
  <p>But when I try to use it an unexpected behaviour happens</p>
  <pre><code># works
  expect { Question.first(2) }.to trigger_query
  # doesn't work
  expect { Question.limit(2) }.to trigger_query
  </code></pre>
  <p>Can anyone tell me what I've done wrong?</p>