Class: ActiveRecordFormatter::Formatter

Inherits:
RSpec::Core::Formatters::DocumentationFormatter
  • Object
show all
Defined in:
lib/rspec/activerecord/formatter/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



8
9
10
11
12
13
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 8

def initialize(output)
  super

  @colorizer      = ::RSpec::Core::Formatters::ConsoleCodes
  @collector      = ActiveRecordFormatter::Collector.new
end

Instance Attribute Details

#collectorObject (readonly)

Returns the value of attribute collector.



3
4
5
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 3

def collector
  @collector
end

#colorizerObject (readonly)

Returns the value of attribute colorizer.



3
4
5
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 3

def colorizer
  @colorizer
end

#configurationObject (readonly)

Returns the value of attribute configuration.



3
4
5
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 3

def configuration
  @configuration
end

Instance Method Details

#dump_summary(summary) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 23

def dump_summary(summary)
  formatted = "\nFinished in #{summary.formatted_duration} " \
    "(files took #{summary.formatted_load_time} to load)\n" \
    "#{colorized_expanded_totals(summary)}\n"

  unless summary.failed_examples.empty?
    formatted << summary.colorized_rerun_commands(colorizer) << "\n"
  end

  output.puts formatted
end

#example_started(example) ⇒ Object



19
20
21
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 19

def example_started(example)
  collector.reset_example
end

#start(start_notification) ⇒ Object



15
16
17
# File 'lib/rspec/activerecord/formatter/formatter.rb', line 15

def start(start_notification)
  output.puts "Recording and reporting ActiveRecord select and creation counts."
end