Class: RSpec::SQLimit::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sqlimit/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(counter) ⇒ Reporter

Returns a new instance of Reporter.



5
6
7
8
9
10
# File 'lib/rspec/sqlimit/reporter.rb', line 5

def initialize(counter)
  @counter = counter
  @count   = counter.count
  @queries = counter.queries
  @matcher = counter.matcher
end

Instance Attribute Details

#matcherObject (readonly)

Returns the value of attribute matcher.



3
4
5
# File 'lib/rspec/sqlimit/reporter.rb', line 3

def matcher
  @matcher
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/rspec/sqlimit/reporter.rb', line 12

def call
  suffix = " among others (see mark ->)" if @matcher

  return "No queries were invoked" if @queries.empty?

  "    |The following \#{@count} queries were invoked\#{suffix}:\n    |\#{lines.join(\"\\n\")}\n  MESSAGE\nend\n".gsub(/ +\|/, "")