Sha256: 51cc03e0492131fddd2680cf3b371521fb8ff0a54ca33735e468d35895a12530
Contents?: true
Size: 538 Bytes
Versions: 13
Compression:
Stored size: 538 Bytes
Contents
RSpec::Matchers.define :perform_queries do |expected| match do |block| query_count(&block) == expected end failure_message do |actual| "Expected to run #{expected} queries, got #{@counter.query_count}" end def query_count(&block) @counter = ActiveRecord::QueryCounter.new ActiveSupport::Notifications.subscribe('sql.active_record', @counter.to_proc) yield ActiveSupport::Notifications.unsubscribe(@counter.to_proc) @counter.query_count end def supports_block_expectations? true end end
Version data entries
13 entries across 13 versions & 3 rubygems