Class: Minitest::Reporters::Ws::Reporter

Inherits:
Object
  • Object
show all
Includes:
ANSI::Code, Minitest::Reporter, Formatting, Messages
Defined in:
lib/minitest/reporters/ws/reporter.rb

Overview

A reporter based on rspec-web by RyanScottLewis

Constant Summary collapse

EMOJI =
{
'P' => "\u{1F49A} ",  # heart
'E' => "\u{1f525} ",  # flame
'F' => "\u{1f4a9} ",  # poop
'S' => "\u{1f37a} " }

Constants included from Formatting

Formatting::INFO_PADDING

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Messages

#add_to_erring, #add_to_failing, #add_to_passing, #add_to_pending, #messages, #start_new_iteration

Methods included from Formatting

#err_info, #get_description, #pad, #print_after_suite, #print_after_suites, #print_err, #print_fail, #print_info, #print_pass, #print_skip, #print_time, #print_with_info_padding

Constructor Details

#initialize(opts = {}) ⇒ Reporter

MUTEX on MiniTest::ReporterRunner?



24
25
26
27
28
29
30
31
# File 'lib/minitest/reporters/ws/reporter.rb', line 24

def initialize(opts = {})

  @config = conf = ::Minitest::Reporters::Ws::Client::DEFAULT_CONFIG
  @emoji = EMOJI.merge(opts.fetch(:emoji, {}))

  init_counts
  init_suite_counts
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



18
19
20
# File 'lib/minitest/reporters/ws/reporter.rb', line 18

def client
  @client
end

#metadataObject

Returns the value of attribute metadata.



19
20
21
# File 'lib/minitest/reporters/ws/reporter.rb', line 19

def 
  @metadata
end

#test_countObject

Returns the value of attribute test_count.



20
21
22
# File 'lib/minitest/reporters/ws/reporter.rb', line 20

def test_count
  @test_count
end

#timestampObject

beer



17
18
19
# File 'lib/minitest/reporters/ws/reporter.rb', line 17

def timestamp
  @timestamp
end

Instance Method Details

#after_suite(suite) ⇒ Object



59
60
61
62
63
64
# File 'lib/minitest/reporters/ws/reporter.rb', line 59

def after_suite(suite)
  if @test_count > 1
    @suites_results.each_key { |k| @suites_results[k] += @results[k] }
    print_after_suite(suite)
  end
end

#after_suites(suites, type) ⇒ Object



50
51
52
53
# File 'lib/minitest/reporters/ws/reporter.rb', line 50

def after_suites(suites, type)
  print_after_suites
  client.close
end

#after_test(suite, test) ⇒ Object



72
73
74
75
# File 'lib/minitest/reporters/ws/reporter.rb', line 72

def after_test(suite,test)
  @test_count += 1
  @suite_test_count += 1
end

#before_suite(suite) ⇒ Object



55
56
57
# File 'lib/minitest/reporters/ws/reporter.rb', line 55

def before_suite(suite)
  init_counts
end

#before_suites(suite, type) ⇒ Object

MINITEST HOOKS



40
41
42
43
44
45
46
47
48
# File 'lib/minitest/reporters/ws/reporter.rb', line 40

def before_suites(suite, type)
  init_client
  set_timestamp
  
  init_suite_counts
  client.identify
  total_tests = [:test_count]
  start_new_iteration(total_tests) if total_tests > 0
end

#before_test(suite, test) ⇒ Object



66
67
68
69
70
# File 'lib/minitest/reporters/ws/reporter.rb', line 66

def before_test(suite,test)
  # need to move towards using metadata[:test_count], etc
  @test_count ||= 0
  @suite_test_count ||= 0
end

#error(suite, test, test_runner) ⇒ Object



97
98
99
100
101
# File 'lib/minitest/reporters/ws/reporter.rb', line 97

def error(suite, test, test_runner)
  @results['E'] += 1
  print_err(suite,test,test_runner)
  add_to_erring((runner, test_runner))
end

#failure(suite, test, test_runner) ⇒ Object



91
92
93
94
95
# File 'lib/minitest/reporters/ws/reporter.rb', line 91

def failure(suite, test, test_runner)
  @results['F'] += 1
  print_fail(suite,test,test_runner)
  add_to_failing((runner, test_runner))
end

#init_clientObject



33
34
35
36
# File 'lib/minitest/reporters/ws/reporter.rb', line 33

def init_client
  client
  #find_or_create_client(conf)
end

#pass(suite, test, test_runner) ⇒ Object

MINITEST PASS/FAIL/ERROR/SKIP



79
80
81
82
83
# File 'lib/minitest/reporters/ws/reporter.rb', line 79

def pass(suite, test, test_runner)
  @results['P'] += 1
  print_pass(suite,test,test_runner)
  add_to_passing((runner, test_runner))
end

#skip(suite, test, test_runner) ⇒ Object



85
86
87
88
89
# File 'lib/minitest/reporters/ws/reporter.rb', line 85

def skip(suite, test, test_runner)
  @results['S'] += 1
  print_skip(suite,test,test_runner)
  add_to_pending((runner, test_runner))
end