Class: Fivemat::RSpec3

Inherits:
Object
  • Object
show all
Includes:
ElapsedTime
Defined in:
lib/fivemat/rspec3.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ElapsedTime

#print_elapsed_time

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_notificationsObject (readonly)

See fivemat.rb for formatter registration.



6
7
8
# File 'lib/fivemat/rspec3.rb', line 6

def failed_notifications
  @failed_notifications
end

#outputObject (readonly)

See fivemat.rb for formatter registration.



6
7
8
# File 'lib/fivemat/rspec3.rb', line 6

def output
  @output
end

Instance Method Details

#colorObject



15
16
17
# File 'lib/fivemat/rspec3.rb', line 15

def color
  ::RSpec::Core::Formatters::ConsoleCodes
end

#dump_summary(summary) ⇒ Object



57
58
59
# File 'lib/fivemat/rspec3.rb', line 57

def dump_summary(summary)
  output.puts summary.fully_formatted
end

#example_failed(notification) ⇒ Object



27
28
29
30
# File 'lib/fivemat/rspec3.rb', line 27

def example_failed(notification)
  @failed_notifications << notification
  output.print color.wrap('F', :failure)
end

#example_group_finished(event) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fivemat/rspec3.rb', line 41

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



32
33
34
35
36
37
38
39
# File 'lib/fivemat/rspec3.rb', line 32

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



19
20
21
# File 'lib/fivemat/rspec3.rb', line 19

def example_passed(notification)
  output.print color.wrap('.', :success)
end

#example_pending(notification) ⇒ Object



23
24
25
# File 'lib/fivemat/rspec3.rb', line 23

def example_pending(notification)
  output.print color.wrap('*', :pending)
end

#message(notification) ⇒ Object



66
67
68
# File 'lib/fivemat/rspec3.rb', line 66

def message(notification)
  output.puts notification.message
end

#seed(notification) ⇒ Object



61
62
63
64
# File 'lib/fivemat/rspec3.rb', line 61

def seed(notification)
  return unless notification.seed_used?
  output.puts notification.fully_formatted
end