Class: Assert::DefaultView

Inherits:
View
  • Object
show all
Includes:
ViewHelpers::Ansi
Defined in:
lib/assert/default_view.rb

Overview

This is the default view used by assert. It renders ansi test output designed for terminal viewing.

Defined Under Namespace

Classes: ResultData, TestData

Constant Summary

Constants included from ViewHelpers::Ansi

ViewHelpers::Ansi::CODES

Instance Attribute Summary

Attributes inherited from View

#config

Instance Method Summary collapse

Methods included from ViewHelpers::Ansi

#ansi_styled_msg, code_for

Methods inherited from View

#after_test, #before_test, #initialize, #is_tty?, #on_result, #print, #puts, require_user_view, #view

Methods included from ViewHelpers

included

Methods included from ConfigHelpers

#all_pass?, #error_result_count, #fail_result_count, #formatted_result_rate, #formatted_run_time, #formatted_suite_result_rate, #formatted_suite_run_time, #formatted_suite_test_rate, #formatted_test_rate, #ignore_result_count, #ocurring_result_types, #pass_result_count, #result_count, #runner, #runner_seed, #show_test_profile_info?, #show_test_verbose_info?, #single_test?, #single_test_file_line, #skip_result_count, #suite, #test_count, #tests_to_run?, #tests_to_run_count, #view

Constructor Details

This class inherits a constructor from Assert::View

Instance Method Details

#after_loadObject


24
25
26
# File 'lib/assert/default_view.rb', line 24

def after_load
  puts "Loaded suite (#{tests_to_run_count_statement})"
end

#before_load(test_files) ⇒ Object


21
22
# File 'lib/assert/default_view.rb', line 21

def before_load(test_files)
end

#on_finishObject


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/assert/default_view.rb', line 33

def on_finish
  dump_test_results if test_count > 0

  # show profile output
  if show_test_profile_info?
    # sort the test datas fastest to slowest
    @test_datas
      .values
      .sort{ |a, b| a.run_time <=> b.run_time }
      .each do |test_data|
        puts "#{formatted_run_time(test_data.run_time)} seconds,"\
             " #{test_data.result_count} results,"\
             " #{formatted_result_rate(test_data.result_rate)} results/s "\
             "-- #{test_data.context}: #{test_data.name.inspect}"
      end
    puts
  end

  # style the summaries of each result set
  styled_results_sentence =
    results_summary_sentence do |summary, result_type|
      ansi_styled_msg(summary, result_type)
    end

  puts "#{result_count_statement}: #{styled_results_sentence}"
  puts
  puts "(#{formatted_suite_run_time} seconds, " \
       "#{formatted_suite_test_rate} tests/s, " \
       "#{formatted_suite_result_rate} results/s)"
end

#on_info(test) ⇒ Object


64
65
66
67
68
69
70
71
# File 'lib/assert/default_view.rb', line 64

def on_info(test)
  dump_test_results

  puts "Current test:"
  puts test.name
  puts test.file_line.to_s
  puts
end

#on_interrupt(_err) ⇒ Object


73
74
75
# File 'lib/assert/default_view.rb', line 73

def on_interrupt(_err)
  dump_test_results
end

#on_startObject


28
29
30
31
# File 'lib/assert/default_view.rb', line 28

def on_start
  reset_run_data
  set_callbacks
end