Sha256: 35dd9d8a6fa289124b7f354a6529da55689b49f6fc8b14552d5b1bcb018f64e4
Contents?: true
Size: 785 Bytes
Versions: 1
Compression:
Stored size: 785 Bytes
Contents
module RSpec::SQLimit class Reporter attr_reader :matcher def initialize(counter) @counter = counter @count = counter.count @queries = counter.queries @matcher = counter.matcher end def call suffix = " among others (see mark ->)" if @matcher return "No queries were invoked" if @queries.empty? <<-MESSAGE.gsub(/ +\|/, "") |The following #{@count} queries were invoked#{suffix}: |#{lines.join("\n")} MESSAGE end private def lines @queries.map.with_index { |*args| line(*args) } end def line(query, index) prefix = (matcher && query[:sql] =~ matcher) ? "->" : " " "#{prefix} #{index + 1}) #{query[:sql]} (#{query[:duration].round(3)} ms)" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-sqlimit-0.0.1 | lib/rspec/sqlimit/reporter.rb |