Class: Rails::TestUnitReporter
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Minitest::StatisticsReporter
|
|
Instance Chain:
self,
Minitest::StatisticsReporter
|
|
Inherits: |
Minitest::StatisticsReporter
|
Defined in: | railties/lib/rails/test_unit/reporter.rb |
Constant Summary
-
COLOR_BY_RESULT_CODE =
# File 'railties/lib/rails/test_unit/reporter.rb', line 106{ "." => codes[:green], "E" => codes[:red], "F" => codes[:red], "S" => codes[:yellow] }
Class Attribute Summary
Instance Attribute Summary
- #app_root= rw
- #app_root? ⇒ Boolean rw
- #executable rw
- #executable? ⇒ Boolean rw
- #app_root rw private
- #colored_output? ⇒ Boolean readonly private
- #fail_fast? ⇒ Boolean readonly private
- #output_inline? ⇒ Boolean readonly private
Instance Method Summary
- #filtered_results
- #prerecord(test_class, test_name)
- #record(result)
- #relative_path_for(file)
- #report
- #color_output(string, by:) private
- #format_line(result) private
- #format_rerun_snippet(result) private
- #aggregated_results Internal use only
Class Attribute Details
.app_root (rw)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 8
class_attribute :app_root
.app_root? ⇒ Boolean
(rw)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 8
class_attribute :app_root
.executable (rw)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 9
class_attribute :executable, default: "bin/rails test"
.executable? ⇒ Boolean
(rw)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 9
class_attribute :executable, default: "bin/rails test"
Instance Attribute Details
#app_root (rw, private)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 92
class_attribute :app_root
#app_root= (rw)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 8
class_attribute :app_root
#app_root? ⇒ Boolean
(rw)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 8
class_attribute :app_root
#colored_output? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 101
def colored_output? [:color] && io.respond_to?(:tty?) && io.tty? end
#executable (rw)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 9
class_attribute :executable, default: "bin/rails test"
#executable? ⇒ Boolean
(rw)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 9
class_attribute :executable, default: "bin/rails test"
#fail_fast? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 74
def fail_fast? [:fail_fast] end
#output_inline? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 70
def output_inline? [:output_inline] end
Instance Method Details
#aggregated_results
This method is for internal use only.
[ GitHub ]
# File 'railties/lib/rails/test_unit/reporter.rb', line 49
def aggregated_results # :nodoc: filtered_results.map { |result| format_rerun_snippet(result) }.join "\n" end
#color_output(string, by:) (private)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 113
def color_output(string, by:) if colored_output? "\e[#{COLOR_BY_RESULT_CODE[by.result_code]}m#{string}\e[0m" else string end end
#filtered_results
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 53
def filtered_results if [:verbose] results else results.reject(&:skipped?) end end
#format_line(result) (private)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 78
def format_line(result) "%.2f s = %s" % [result.time, result.result_code] end
#format_rerun_snippet(result) (private)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 82
def format_rerun_snippet(result) location, line = if result.respond_to?(:source_location) result.source_location else result.method(result.name).source_location end "#{executable} #{relative_path_for(location)}:#{line}" end
#prerecord(test_class, test_name)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 11
def prerecord(test_class, test_name) super if [:verbose] io.print "%s#%s = " % [test_class.name, test_name] end end
#record(result)
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 18
def record(result) super if [:verbose] io.puts color_output(format_line(result), by: result) else io.print color_output(result.result_code, by: result) end if output_inline? && result.failure && (!result.skipped? || [:verbose]) io.puts io.puts io.puts color_output(result, by: result) io.puts io.puts format_rerun_snippet(result) io.puts end if fail_fast? && result.failure && !result.skipped? raise Interrupt end end
#relative_path_for(file)
[ GitHub ]#report
[ GitHub ]# File 'railties/lib/rails/test_unit/reporter.rb', line 41
def report return if output_inline? || filtered_results.empty? io.puts io.puts "Failed tests:" io.puts io.puts aggregated_results end