Class: Fivemat::RSpec3
- Inherits:
-
Object
- Object
- Fivemat::RSpec3
- Includes:
- ElapsedTime
- Defined in:
- lib/fivemat/rspec3.rb
Instance Attribute Summary collapse
-
#failed_notifications ⇒ Object
readonly
See fivemat.rb for formatter registration.
-
#output ⇒ Object
readonly
See fivemat.rb for formatter registration.
Instance Method Summary collapse
- #color ⇒ Object
- #dump_summary(summary) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_group_finished(event) ⇒ Object
- #example_group_started(event) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(output) ⇒ RSpec3
constructor
A new instance of RSpec3.
- #message(notification) ⇒ Object
- #seed(notification) ⇒ Object
Methods included from ElapsedTime
Constructor Details
#initialize(output) ⇒ RSpec3
Returns a new instance of RSpec3.
8 9 10 11 12 13 |
# File 'lib/fivemat/rspec3.rb', line 8 def initialize(output) @output = output @group_level = 0 @index_offset = 0 @failed_notifications = [] end |
Instance Attribute Details
#failed_notifications ⇒ Object (readonly)
See fivemat.rb for formatter registration.
6 7 8 |
# File 'lib/fivemat/rspec3.rb', line 6 def failed_notifications @failed_notifications end |
#output ⇒ Object (readonly)
See fivemat.rb for formatter registration.
6 7 8 |
# File 'lib/fivemat/rspec3.rb', line 6 def output @output end |
Instance Method Details
#color ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fivemat/rspec3.rb', line 15 def color unless defined?(::RSpec::Core::Formatters::ConsoleCodes) require 'rspec/core/formatters/console_codes' end ::RSpec::Core::Formatters::ConsoleCodes end |
#dump_summary(summary) ⇒ Object
60 61 62 |
# File 'lib/fivemat/rspec3.rb', line 60 def dump_summary(summary) output.puts summary.fully_formatted end |
#example_failed(notification) ⇒ Object
30 31 32 33 |
# File 'lib/fivemat/rspec3.rb', line 30 def example_failed(notification) @failed_notifications << notification output.print color.wrap('F', :failure) end |
#example_group_finished(event) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fivemat/rspec3.rb', line 44 def example_group_finished(event) @group_level -= 1 if @group_level.zero? print_elapsed_time output, @start_time output.puts failed_notifications.each_with_index do |failure, index| output.puts failure.fully_formatted(@index_offset + index + 1) end @index_offset += failed_notifications.size failed_notifications.clear end end |
#example_group_started(event) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/fivemat/rspec3.rb', line 35 def example_group_started(event) if @group_level.zero? output.print "#{event.group.description} " @start_time = Time.now end @group_level += 1 end |
#example_passed(notification) ⇒ Object
22 23 24 |
# File 'lib/fivemat/rspec3.rb', line 22 def example_passed(notification) output.print color.wrap('.', :success) end |
#example_pending(notification) ⇒ Object
26 27 28 |
# File 'lib/fivemat/rspec3.rb', line 26 def example_pending(notification) output.print color.wrap('*', :pending) end |
#message(notification) ⇒ Object
69 70 71 |
# File 'lib/fivemat/rspec3.rb', line 69 def (notification) output.puts notification. end |
#seed(notification) ⇒ Object
64 65 66 67 |
# File 'lib/fivemat/rspec3.rb', line 64 def seed(notification) return unless notification.seed_used? output.puts notification.fully_formatted end |