Sha256: a90cd662a6c49f62cd74d9dcb3b542cd5494ddad8d272c237e023e16db84adbb
Contents?: true
Size: 949 Bytes
Versions: 1
Compression:
Stored size: 949 Bytes
Contents
# typed: false # frozen_string_literal: true require "rspec/matchers" module WtActiverecordIndexSpy # This module defines the helper have_used_db_indexes to use in RSpec tests module TestHelpers extend RSpec::Matchers::DSL matcher :have_used_db_indexes do |only_certains: false| match do |actual| WtActiverecordIndexSpy.watch_queries(ignore_queries_originated_in_test_code: false) do actual.call end if only_certains WtActiverecordIndexSpy.certain_results.empty? else WtActiverecordIndexSpy.results.empty? end end failure_message do |_actual| "Some queries have not used indexes: #{WtActiverecordIndexSpy.results.to_h}" end failure_message_when_negated do |_actual| "All queries have used indexes and this was not expected" end def supports_block_expectations? true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wt_activerecord_index_spy-0.5.0 | lib/wt_activerecord_index_spy/test_helpers.rb |