Class: RSpec::TAP::Formatters::Compact

Inherits:
Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/rspec/tap/formatters/compact.rb

Overview

Compact TAP formatter

Constant Summary collapse

NOTIFICATIONS =

List of subscribed notifications

i[
  seed
  start
  start_dump
  example_group_started
  example_group_finished
  example_started
  example_passed
  example_failed
  example_pending
  message
  dump_failures
  dump_pending
  dump_summary
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Compact

Constructor

Parameters:

  • output (StringIO, File) —

    output stream



34
35
36
37
38
39
40
41
42
# File 'lib/rspec/tap/formatters/compact.rb', line 34

def initialize(output)
  super

  @printer = Printer.new(output)
  @test_stats = TestStats.new
  @seed = nil
  @level = 0
  @example_number = 0
end

Instance Method Details

#dump_failures(notification)

Failure examples notification

Parameters:

  • notification (ExamplesNotification)


148
149
150
# File 'lib/rspec/tap/formatters/compact.rb', line 148

def dump_failures(notification)
  @printer.store_failed_examples_summary(notification)
end

#dump_pending(notification)

Pending examples notification

Parameters:

  • notification (ExamplesNotification)


155
156
157
# File 'lib/rspec/tap/formatters/compact.rb', line 155

def dump_pending(notification)
  @printer.store_pending_examples_summary(notification)
end

#dump_summary(notification)

Examples summary notification

Parameters:

  • notification (SummaryNotification)


162
163
164
# File 'lib/rspec/tap/formatters/compact.rb', line 162

def dump_summary(notification)
  @printer.summary_output(notification, @seed)
end

#example_failed(notification)

Failing example notification

Parameters:

  • notification (FailedExampleNotification)


113
114
115
116
117
118
119
120
121
# File 'lib/rspec/tap/formatters/compact.rb', line 113

def example_failed(notification)
  @test_stats.populate(notification, 2)
  @printer.example_progress_output(:failure)
  @printer.failure_output(
    notification.example.description.strip,
    @example_number,
    @level
  )
end

#example_group_finished(notification)

Example group finish notification

Parameters:

  • notification (GroupNotification)


80
81
82
83
84
85
86
87
88
# File 'lib/rspec/tap/formatters/compact.rb', line 80

def example_group_finished(notification)
  @printer.group_finished_output(
    @test_stats.data[notification.group.[:line_number]],
    @level
  )

  @level -= 1 if @level.positive?
  @test_stats = TestStats.new if @level.zero?
end

#example_group_started(notification)

Example group start notification

Parameters:

  • notification (GroupNotification)


70
71
72
73
74
75
# File 'lib/rspec/tap/formatters/compact.rb', line 70

def example_group_started(notification)
  @printer.group_start_output(notification, @level)

  @level += 1
  @example_number = 0
end

#example_passed(notification)

Passing example notification

Parameters:

  • notification (ExampleNotification)


100
101
102
103
104
105
106
107
108
# File 'lib/rspec/tap/formatters/compact.rb', line 100

def example_passed(notification)
  @test_stats.populate(notification, 1)
  @printer.example_progress_output(:success)
  @printer.success_output(
    notification.example.description.strip,
    @example_number,
    @level
  )
end

#example_pending(notification)

Pending example notification

Parameters:

  • notification (PendingExampleFailedAsExpectedNotification, SkippedExampleException)


127
128
129
130
131
132
133
134
135
136
# File 'lib/rspec/tap/formatters/compact.rb', line 127

def example_pending(notification)
  @test_stats.populate(notification, 3)
  @printer.example_progress_output(:pending)
  @printer.pending_output(
    notification,
    notification.example.description.strip,
    @example_number,
    @level
  )
end

#example_started(_notification)

Example start notification

Parameters:

  • _notification (ExampleNotification)


93
94
95
# File 'lib/rspec/tap/formatters/compact.rb', line 93

def example_started(_notification)
  @example_number += 1
end

#message(notification)

Failure outside of example notification

Parameters:

  • notification (MessageNotification)


141
142
143
# File 'lib/rspec/tap/formatters/compact.rb', line 141

def message(notification)
  @printer.message_output(notification)
end

#seed(notification)

Seed notification

Parameters:

  • notification (SeedNotification)


47
48
49
# File 'lib/rspec/tap/formatters/compact.rb', line 47

def seed(notification)
  @seed = notification.seed if notification.seed_used?
end

#start(notification)

Start notification

Parameters:

  • notification (StartNotification)


54
55
56
57
58
# File 'lib/rspec/tap/formatters/compact.rb', line 54

def start(notification)
  super

  @printer.start_output
end

#start_dump(_notification)

Execution finished notification

Parameters:

  • _notification (NullNotification)


63
64
65
# File 'lib/rspec/tap/formatters/compact.rb', line 63

def start_dump(_notification)
  @printer.example_progress_dump
end