Sha256: abff459b13216dcd12f50c381db13b40998d7ff4a6a260bc915d0ee2e1c660db
Contents?: true
Size: 598 Bytes
Versions: 1
Compression:
Stored size: 598 Bytes
Contents
# https://gist.github.com/rsutphin/af06c9e3dadf658d2293 # Derived from http://stackoverflow.com/a/13423584/153896. Updated for RSpec 3. RSpec::Matchers.define :under_query_limit do |expected| supports_block_expectations match do |block| query_count(&block) <= expected end failure_message do |actual| "Expected to run maximum #{expected} queries, got #{@counter.query_count}" end def query_count(&block) @counter = ActiveRecord::QueryCounter.new ActiveSupport::Notifications.subscribed(@counter.to_proc, 'sql.active_record', &block) @counter.query_count end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
read_activity-0.1.0 | spec/support/matchers/under_query_limit.rb |