Sha256: 26ebae0d643487e24b4bce937904c30538c4e0f8ced21196409bd9c41f2f4aa1
Contents?: true
Size: 517 Bytes
Versions: 8
Compression:
Stored size: 517 Bytes
Contents
RSpec::Matchers.define :perform_queries do |expected| supports_block_expectations 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 end
Version data entries
8 entries across 8 versions & 1 rubygems