module Rspec
  module QueryLimit
    module ActiveRecord
      class QueryCounter

        attr_reader :query_count

        def initialize
          @query_count = 0
        end

        def to_proc
          lambda(&method(:callback))
        end

        def callback(name, start, finish, message_id, values)
          @query_count += 1 unless %w(CACHE SCHEMA).include?(values[:name])
        end

      end
    end
  end
end
