minitest-reporters 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,7 +24,8 @@ The following reporters are provided:
24
24
  MiniTest::Reporters::DefaultReporter # => Identical to the standard MiniTest reporter
25
25
  MiniTest::Reporters::SpecReporter # => Turn-like output that reads like a spec
26
26
  MiniTest::Reporters::ProgressReporter # => Fuubar-like output with a progress bar
27
- MiniTest::Reporters::RubyMateReporter # => Simple reporter designed for RubyMate; see below
27
+ MiniTest::Reporters::RubyMateReporter # => Simple reporter designed for RubyMate
28
+ MiniTest::Reporters::RubyMineReporter # => Reporter designed for RubyMine IDE and TeamCity CI server; see below
28
29
 
29
30
  I really like `ProgressReporter` for my everyday terminal usage, but I like
30
31
  using `RubyMateReporter` when I'm executing test suites from TextMate. My usual
@@ -38,6 +39,14 @@ set up looks like this:
38
39
  MiniTest::Unit.runner.reporters << MiniTest::Reporters::ProgressReporter.new
39
40
  end
40
41
 
42
+ If you prefer integration with RubyMine test runner or TeamCity CI server you'll need:
43
+
44
+ if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
45
+ MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
46
+ else
47
+ ...
48
+ end
49
+
41
50
  ## TODO ##
42
51
 
43
52
  * Make the boilerplate code look prettier. Something like a one-line require for the general use-case would be nice.
@@ -0,0 +1,66 @@
1
+ module MiniTest
2
+ # Filters backtraces of exceptions that may arise when running tests.
3
+ class BacktraceFilter
4
+ # Returns the default filter.
5
+ #
6
+ # The default filter will filter out all MiniTest and minitest-reporters
7
+ # lines.
8
+ #
9
+ # @return [MiniTest::BacktraceFilter]
10
+ def self.default_filter
11
+ unless defined? @default_filter
12
+ filter = self.new
13
+ filter.add_filter(/lib\/minitest/)
14
+ @default_filter = filter
15
+ end
16
+
17
+ @default_filter
18
+ end
19
+
20
+ # Creates a new backtrace filter.
21
+ def initialize
22
+ @filters = []
23
+ end
24
+
25
+ # Adds a filter.
26
+ #
27
+ # @param [Regex] regex the filter
28
+ def add_filter(regex)
29
+ @filters << regex
30
+ end
31
+
32
+ # Determines if the string would be filtered.
33
+ #
34
+ # @param [String] str
35
+ # @return [Boolean]
36
+ def filters?(str)
37
+ @filters.any? { |filter| str =~ filter }
38
+ end
39
+
40
+ # Filters a backtrace.
41
+ #
42
+ # This will add new lines to the new backtrace until a filtered line is
43
+ # encountered. If there were lines added to the new backtrace, it returns
44
+ # those lines. However, if the first line in the backtrace was filtered,
45
+ # resulting in an empty backtrace, it returns all lines that would have
46
+ # been unfiltered. If that in turn does not contain any lines, it returns
47
+ # the original backtrace.
48
+ #
49
+ # @param [Array] backtrace the backtrace to filter
50
+ # @return [Array] the filtered backtrace
51
+ # @note This logic is based off of MiniTest's #filter_backtrace.
52
+ def filter(backtrace)
53
+ result = []
54
+
55
+ backtrace.each do |line|
56
+ break if filters?(line)
57
+ result << line
58
+ end
59
+
60
+ result = backtrace.reject { |line| filters?(line) } if result.empty?
61
+ result = backtrace.dup if result.empty?
62
+
63
+ result
64
+ end
65
+ end
66
+ end
@@ -1,16 +1,18 @@
1
- require 'minitest/unit'
1
+ require "minitest/unit"
2
2
 
3
3
  module MiniTest
4
- autoload :Reporter, 'minitest/reporter'
5
- autoload :SuiteRunner, 'minitest/suite_runner'
6
- autoload :TestRunner, 'minitest/test_runner'
7
-
4
+ autoload :Reporter, "minitest/reporter"
5
+ autoload :SuiteRunner, "minitest/suite_runner"
6
+ autoload :TestRunner, "minitest/test_runner"
7
+ autoload :BacktraceFilter, "minitest/backtrace_filter"
8
+
8
9
  module Reporters
9
- require 'minitest/reporters/version'
10
-
11
- autoload :DefaultReporter, 'minitest/reporters/default_reporter'
12
- autoload :SpecReporter, 'minitest/reporters/spec_reporter'
13
- autoload :ProgressReporter, 'minitest/reporters/progress_reporter'
14
- autoload :RubyMateReporter, 'minitest/reporters/ruby_mate_reporter'
10
+ require "minitest/reporters/version"
11
+
12
+ autoload :DefaultReporter, "minitest/reporters/default_reporter"
13
+ autoload :SpecReporter, "minitest/reporters/spec_reporter"
14
+ autoload :ProgressReporter, "minitest/reporters/progress_reporter"
15
+ autoload :RubyMateReporter, "minitest/reporters/ruby_mate_reporter"
16
+ autoload :RubyMineReporter, "minitest/reporters/rubymine_reporter"
15
17
  end
16
- end
18
+ end
@@ -3,47 +3,51 @@ require 'ansi'
3
3
  module MiniTest
4
4
  module Reporters
5
5
  # A reporter identical to the standard MiniTest reporter.
6
- #
6
+ #
7
7
  # Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
8
- #
8
+ #
9
9
  # @see https://github.com/seattlerb/minitest MiniTest
10
10
  class DefaultReporter
11
11
  include MiniTest::Reporter
12
-
12
+
13
+ def initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter)
14
+ @backtrace_filter = backtrace_filter
15
+ end
16
+
13
17
  def before_suites(suites, type)
14
18
  puts
15
19
  puts "# Running #{type}s:"
16
20
  puts
17
21
  end
18
-
22
+
19
23
  def before_test(suite, test)
20
- print "#{suite}##{method} = " if verbose?
24
+ print "#{suite}##{test} = " if verbose?
21
25
  end
22
-
26
+
23
27
  def pass(suite, test, test_runner)
24
28
  after_test('.')
25
29
  end
26
-
30
+
27
31
  def skip(suite, test, test_runner)
28
32
  after_test('S')
29
33
  end
30
-
34
+
31
35
  def failure(suite, test, test_runner)
32
36
  after_test('F')
33
37
  end
34
-
38
+
35
39
  def error(suite, test, test_runner)
36
40
  after_test('E')
37
41
  end
38
-
42
+
39
43
  def after_suites(suites, type)
40
44
  time = Time.now - runner.start_time
41
-
45
+
42
46
  puts
43
47
  puts
44
48
  puts "Finished #{type}s in %.6fs, %.4f tests/s, %.4f assertions/s." %
45
49
  [time, runner.test_count / time, runner.assertion_count / time]
46
-
50
+
47
51
  i = 0
48
52
  runner.report.each do |suite, tests|
49
53
  tests.each do |test, test_runner|
@@ -54,48 +58,48 @@ module MiniTest
54
58
  end
55
59
  end
56
60
  end
57
-
61
+
58
62
  puts
59
-
63
+
60
64
  puts status
61
65
  end
62
-
66
+
63
67
  private
64
-
68
+
65
69
  def after_test(result)
66
70
  time = Time.now - runner.test_start_time
67
-
71
+
68
72
  print '%.2f s = ' % time if verbose?
69
73
  print result
70
74
  puts if verbose?
71
75
  end
72
-
76
+
73
77
  def location(exception)
74
78
  last_before_assertion = ''
75
-
79
+
76
80
  exception.backtrace.reverse_each do |s|
77
81
  break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
78
82
  last_before_assertion = s
79
83
  end
80
-
84
+
81
85
  last_before_assertion.sub(/:in .*$/, '')
82
86
  end
83
-
87
+
84
88
  def message_for(test_runner)
85
89
  suite = test_runner.suite
86
90
  test = test_runner.test
87
91
  e = test_runner.exception
88
-
92
+
89
93
  case test_runner.result
90
94
  when :pass then nil
91
95
  when :skip then "Skipped:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
92
96
  when :failure then "Failure:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
93
97
  when :error
94
- bt = MiniTest::filter_backtrace(test_runner.exception.backtrace).join "\n "
98
+ bt = @backtrace_filter.filter(test_runner.exception.backtrace).join "\n "
95
99
  "Error:\n#{test}(#{suite}):\n#{e.class}: #{e.message}\n #{bt}\n"
96
100
  end
97
101
  end
98
-
102
+
99
103
  def status
100
104
  '%d tests, %d assertions, %d failures, %d errors, %d skips' %
101
105
  [runner.test_count, runner.assertion_count, runner.failures, runner.errors, runner.skips]
@@ -4,28 +4,32 @@ require 'progressbar'
4
4
  module MiniTest
5
5
  module Reporters
6
6
  # Fuubar-like reporter with a progress bar.
7
- #
7
+ #
8
8
  # Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's
9
9
  # monkey-patch.
10
- #
10
+ #
11
11
  # @see https://github.com/jeffkreeftmeijer/fuubar Fuubar
12
12
  # @see https://gist.github.com/356945 paydro's monkey-patch
13
13
  class ProgressReporter
14
14
  include MiniTest::Reporter
15
15
  include ANSI::Code
16
-
16
+
17
17
  INFO_PADDING = 2
18
-
18
+
19
+ def initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter)
20
+ @backtrace_filter = backtrace_filter
21
+ end
22
+
19
23
  def before_suites(suites, type)
20
24
  puts 'Started'
21
25
  puts
22
-
26
+
23
27
  @color = GREEN
24
28
  @finished_count = 0
25
29
  @progress = ProgressBar.new("0/#{runner.test_count}", runner.test_count, runner.output)
26
30
  @progress.bar_mark = '='
27
31
  end
28
-
32
+
29
33
  def increment
30
34
  with_color do
31
35
  @finished_count += 1
@@ -33,11 +37,11 @@ module MiniTest
33
37
  @progress.inc
34
38
  end
35
39
  end
36
-
40
+
37
41
  def pass(suite, test, test_runner)
38
42
  increment
39
43
  end
40
-
44
+
41
45
  def skip(suite, test, test_runner)
42
46
  @color = YELLOW unless @color == RED
43
47
  print(yellow { 'SKIP' })
@@ -46,7 +50,7 @@ module MiniTest
46
50
  puts
47
51
  increment
48
52
  end
49
-
53
+
50
54
  def failure(suite, test, test_runner)
51
55
  @color = RED
52
56
  print(red { 'FAIL' })
@@ -56,7 +60,7 @@ module MiniTest
56
60
  puts
57
61
  increment
58
62
  end
59
-
63
+
60
64
  def error(suite, test, test_runner)
61
65
  @color = RED
62
66
  print(red { 'ERROR' })
@@ -66,12 +70,12 @@ module MiniTest
66
70
  puts
67
71
  increment
68
72
  end
69
-
73
+
70
74
  def after_suites(suites, type)
71
75
  with_color { @progress.finish }
72
-
76
+
73
77
  total_time = Time.now - runner.start_time
74
-
78
+
75
79
  puts
76
80
  puts('Finished in %.5fs' % total_time)
77
81
  print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
@@ -79,25 +83,25 @@ module MiniTest
79
83
  print(yellow { '%d skips' } % runner.skips)
80
84
  puts
81
85
  end
82
-
86
+
83
87
  private
84
-
88
+
85
89
  def print_test_with_time(suite, test)
86
90
  total_time = Time.now - runner.test_start_time
87
91
  print(" #{suite}##{test} (%.2fs)#{clr}" % total_time)
88
92
  end
89
-
93
+
90
94
  def print_info(e)
91
95
  e.message.each_line { |line| puts pad(line) }
92
-
93
- trace = MiniTest.filter_backtrace(e.backtrace)
96
+
97
+ trace = @backtrace_filter.filter(e.backtrace)
94
98
  trace.each { |line| puts pad(line) }
95
99
  end
96
-
100
+
97
101
  def pad(str)
98
102
  ' ' * INFO_PADDING + str
99
103
  end
100
-
104
+
101
105
  def with_color
102
106
  print @color
103
107
  yield
@@ -105,4 +109,4 @@ module MiniTest
105
109
  end
106
110
  end
107
111
  end
108
- end
112
+ end
@@ -6,21 +6,25 @@ module MiniTest
6
6
  # Simple reporter designed for RubyMate.
7
7
  class RubyMateReporter
8
8
  include MiniTest::Reporter
9
-
9
+
10
10
  INFO_PADDING = 2
11
-
11
+
12
+ def initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter)
13
+ @backtrace_filter = backtrace_filter
14
+ end
15
+
12
16
  def before_suites(suites, type)
13
17
  puts 'Started'
14
18
  puts
15
19
  end
16
-
20
+
17
21
  def skip(suite, test, test_runner)
18
22
  print 'SKIP'
19
23
  print_test_with_time(suite, test)
20
24
  puts
21
25
  puts
22
26
  end
23
-
27
+
24
28
  def failure(suite, test, test_runner)
25
29
  print 'FAIL'
26
30
  print_test_with_time(suite, test)
@@ -28,7 +32,7 @@ module MiniTest
28
32
  print_info(test_runner.exception)
29
33
  puts
30
34
  end
31
-
35
+
32
36
  def error(suite, test, test_runner)
33
37
  print 'ERROR'
34
38
  print_test_with_time(suite, test)
@@ -36,10 +40,10 @@ module MiniTest
36
40
  print_info(test_runner.exception)
37
41
  puts
38
42
  end
39
-
43
+
40
44
  def after_suites(suites, type)
41
45
  total_time = Time.now - runner.start_time
42
-
46
+
43
47
  puts
44
48
  puts('Finished in %.5fs' % total_time)
45
49
  print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
@@ -47,24 +51,24 @@ module MiniTest
47
51
  print('%d skips' % runner.skips)
48
52
  puts
49
53
  end
50
-
54
+
51
55
  private
52
-
56
+
53
57
  def print_test_with_time(suite, test)
54
58
  total_time = Time.now - runner.test_start_time
55
59
  print(" #{suite}##{test} (%.2fs)" % total_time)
56
60
  end
57
-
61
+
58
62
  def print_info(e)
59
63
  e.message.each_line { |line| puts pad(line) }
60
-
61
- trace = MiniTest.filter_backtrace(e.backtrace)
64
+
65
+ trace = @backtrace_filter.filter(e.backtrace)
62
66
  trace.each { |line| puts pad(line) }
63
67
  end
64
-
68
+
65
69
  def pad(str)
66
70
  ' ' * INFO_PADDING + str
67
71
  end
68
72
  end
69
73
  end
70
- end
74
+ end
@@ -0,0 +1,163 @@
1
+ # Test results reporter for RubyMine IDE (http://www.jetbrains.com/ruby/) and
2
+ # TeamCity(http://www.jetbrains.com/teamcity/) Continuous Integration Server
3
+ #
4
+ # Usage:
5
+ # # in test_helper.rb
6
+ # ...
7
+ # if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
8
+ # MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
9
+ # else
10
+ # MiniTest::Unit.runner.reporters << MiniTest::Reporters::DefaultReporter.new
11
+ # end
12
+
13
+ require "ansi"
14
+ begin
15
+ require 'teamcity/runner_common'
16
+ require 'teamcity/utils/service_message_factory'
17
+ require 'teamcity/utils/runner_utils'
18
+ require 'teamcity/utils/url_formatter'
19
+ rescue LoadError
20
+ MiniTest::Unit.runner.output.puts("====================================================================================================\n")
21
+ MiniTest::Unit.runner.output.puts("RubyMine reporter works only if it test was launched using RubyMine IDE or TeamCity CI server !!!\n")
22
+ MiniTest::Unit.runner.output.puts("====================================================================================================\n")
23
+ MiniTest::Unit.runner.output.puts("Using default results reporter...\n")
24
+
25
+ require "minitest/reporters/default_reporter"
26
+
27
+ # delegate to default reporter
28
+ module MiniTest
29
+ module Reporters
30
+ class RubyMineReporter < MiniTest::Reporters::DefaultReporter
31
+ end
32
+ end
33
+ end
34
+ else
35
+ module MiniTest
36
+ module Reporters
37
+ class RubyMineReporter
38
+ include MiniTest::Reporter
39
+ include ANSI::Code
40
+
41
+ include ::Rake::TeamCity::RunnerCommon
42
+ include ::Rake::TeamCity::RunnerUtils
43
+ include ::Rake::TeamCity::Utils::UrlFormatter
44
+
45
+ def runner
46
+ MiniTest::Unit.runner
47
+ end
48
+
49
+ def output
50
+ runner.output
51
+ end
52
+
53
+ def verbose?
54
+ runner.verbose
55
+ end
56
+
57
+ def print(*args)
58
+ runner.output.print(*args)
59
+ end
60
+
61
+ def puts(*args)
62
+ runner.output.puts(*args)
63
+ end
64
+
65
+ def before_suites(suites, type)
66
+ puts 'Started'
67
+ puts
68
+
69
+ # Setup test runner's MessageFactory
70
+ set_message_factory(Rake::TeamCity::MessageFactory)
71
+ log_test_reporter_attached()
72
+
73
+ # Report tests count:
74
+ test_count = runner.test_count
75
+ if ::Rake::TeamCity.is_in_idea_mode
76
+ log(@message_factory.create_tests_count(test_count))
77
+ elsif ::Rake::TeamCity.is_in_buildserver_mode
78
+ log(@message_factory.create_progress_message("Starting.. (#{test_count} tests)"))
79
+ end
80
+
81
+ end
82
+
83
+ def after_suites(suites, type)
84
+ total_time = Time.now - runner.start_time
85
+
86
+ puts('Finished in %.5fs' % total_time)
87
+ print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
88
+ print(red { '%d failures, %d errors, ' } % [runner.failures, runner.errors])
89
+ print(yellow { '%d skips' } % runner.skips)
90
+ puts
91
+ end
92
+
93
+ def before_suite(suite)
94
+ fqn = suite.name
95
+ log(@message_factory.create_suite_started(suite.name, location_from_ruby_qualified_name(fqn)))
96
+ end
97
+
98
+ def after_suite(suite)
99
+ log(@message_factory.create_suite_finished(suite.name))
100
+ end
101
+
102
+ def before_test(suite, test)
103
+ fqn = "#{suite.name}.#{test.to_s}"
104
+ log(@message_factory.create_test_started(test, minitest_test_location(fqn)))
105
+ end
106
+
107
+ def pass(suite, test, test_runner)
108
+ test_finished(test, test_runner)
109
+ end
110
+
111
+ def skip(suite, test, test_runner)
112
+ test_finished(test, test_runner) do |exception_msg, backtrace|
113
+ log(@message_factory.create_test_ignored(test, exception_msg, backtrace))
114
+ end
115
+ end
116
+
117
+ def failure(suite, test, test_runner)
118
+ test_finished(test, test_runner) do |exception_msg, backtrace|
119
+ log(@message_factory.create_test_failed(test, exception_msg, backtrace))
120
+ end
121
+ end
122
+
123
+ def error(suite, test, test_runner)
124
+ test_finished(test, test_runner) do |exception_msg, backtrace|
125
+ log(@message_factory.create_test_error(test, exception_msg, backtrace))
126
+ end
127
+ end
128
+
129
+ #########
130
+ def log(msg)
131
+ output.flush
132
+ output.puts("\n#{msg}")
133
+ output.flush
134
+
135
+ # returns:
136
+ msg
137
+ end
138
+
139
+ def minitest_test_location(fqn)
140
+ return nil if (fqn.nil?)
141
+ "ruby_minitest_qn://#{fqn}"
142
+ end
143
+
144
+ def test_finished(test, test_runner)
145
+ duration_ms = get_current_time_in_ms() - get_time_in_ms(runner.test_start_time)
146
+
147
+ begin
148
+ if block_given?
149
+ exception = test_runner.exception
150
+ msg = exception.nil? ? "" : "#{exception.class.name}: #{exception.message}"
151
+ backtrace = exception.nil? ? "" : format_backtrace(exception.backtrace)
152
+
153
+ yield(msg, backtrace)
154
+ end
155
+ ensure
156
+ log(@message_factory.create_test_finished(test, duration_ms.nil? ? 0 : duration_ms))
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+
@@ -3,54 +3,58 @@ require 'ansi'
3
3
  module MiniTest
4
4
  module Reporters
5
5
  # Turn-like reporter that reads like a spec.
6
- #
6
+ #
7
7
  # Based upon TwP's turn (MIT License) and paydro's monkey-patch.
8
- #
8
+ #
9
9
  # @see https://github.com/TwP/turn turn
10
10
  # @see https://gist.github.com/356945 paydro's monkey-patch
11
11
  class SpecReporter
12
12
  include MiniTest::Reporter
13
13
  include ANSI::Code
14
-
14
+
15
15
  TEST_PADDING = 2
16
16
  INFO_PADDING = 8
17
17
  MARK_SIZE = 5
18
-
18
+
19
+ def initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter)
20
+ @backtrace_filter = backtrace_filter
21
+ end
22
+
19
23
  def before_suites(suites, type)
20
24
  puts 'Started'
21
25
  puts
22
26
  end
23
-
27
+
24
28
  def after_suites(suites, type)
25
29
  total_time = Time.now - runner.start_time
26
-
30
+
27
31
  puts('Finished in %.5fs' % total_time)
28
32
  print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
29
33
  print(red { '%d failures, %d errors, ' } % [runner.failures, runner.errors])
30
34
  print(yellow { '%d skips' } % runner.skips)
31
35
  puts
32
36
  end
33
-
37
+
34
38
  def before_suite(suite)
35
- puts suite
39
+ puts suite.name
36
40
  end
37
-
41
+
38
42
  def after_suite(suite)
39
43
  puts
40
44
  end
41
-
45
+
42
46
  def pass(suite, test, test_runner)
43
47
  print(green { pad_mark('PASS') })
44
48
  print_test_with_time(test)
45
49
  puts
46
50
  end
47
-
51
+
48
52
  def skip(suite, test, test_runner)
49
53
  print(yellow { pad_mark('SKIP') })
50
54
  print_test_with_time(test)
51
55
  puts
52
56
  end
53
-
57
+
54
58
  def failure(suite, test, test_runner)
55
59
  print(red { pad_mark('FAIL') })
56
60
  print_test_with_time(test)
@@ -58,7 +62,7 @@ module MiniTest
58
62
  print_info(test_runner.exception)
59
63
  puts
60
64
  end
61
-
65
+
62
66
  def error(suite, test, test_runner)
63
67
  print(red { pad_mark('ERROR') })
64
68
  print_test_with_time(test)
@@ -66,28 +70,28 @@ module MiniTest
66
70
  print_info(test_runner.exception)
67
71
  puts
68
72
  end
69
-
73
+
70
74
  private
71
-
75
+
72
76
  def print_test_with_time(test)
73
77
  total_time = Time.now - runner.test_start_time
74
- print(" #{test} (%.2fs)" % total_time)
78
+ print(" %s (%.2fs)" % [test, total_time])
75
79
  end
76
-
80
+
77
81
  def print_info(e)
78
82
  e.message.each_line { |line| puts pad(line, INFO_PADDING) }
79
-
80
- trace = MiniTest.filter_backtrace(e.backtrace)
83
+
84
+ trace = @backtrace_filter.filter(e.backtrace)
81
85
  trace.each { |line| puts pad(line, INFO_PADDING) }
82
86
  end
83
-
87
+
84
88
  def pad(str, size)
85
89
  ' ' * size + str
86
90
  end
87
-
91
+
88
92
  def pad_mark(str)
89
93
  pad("%#{MARK_SIZE}s" % str, TEST_PADDING)
90
94
  end
91
95
  end
92
96
  end
93
- end
97
+ end
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  module Reporters
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  end
5
- end
5
+ end
@@ -0,0 +1,38 @@
1
+ require "test_helper"
2
+
3
+ module MiniTestReportersTest
4
+ class BacktraceFilterTest < TestCase
5
+ def setup
6
+ @default_filter = MiniTest::BacktraceFilter.default_filter
7
+ @filter = MiniTest::BacktraceFilter.new
8
+ @backtrace = ["foo", "bar", "baz"]
9
+ end
10
+
11
+ test "adding filters" do
12
+ @filter.add_filter(/foo/)
13
+ assert @filter.filters?("foo")
14
+ refute @filter.filters?("baz")
15
+ end
16
+
17
+ test "filter backtrace when first line is filtered" do
18
+ @filter.add_filter(/foo/)
19
+ assert_equal ["bar", "baz"], @filter.filter(@backtrace)
20
+ end
21
+
22
+ test "filter backtrace when middle line is filtered" do
23
+ @filter.add_filter(/bar/)
24
+ assert_equal ["foo"], @filter.filter(@backtrace)
25
+ end
26
+
27
+ test "filter backtrace when all lines are filtered" do
28
+ @filter.add_filter(/./)
29
+ assert_equal ["foo", "bar", "baz"], @filter.filter(@backtrace)
30
+ end
31
+
32
+ test "default filter" do
33
+ assert @default_filter.filters?("lib/minitest")
34
+ assert @default_filter.filters?("lib/minitest/reporters")
35
+ refute @default_filter.filters?("lib/my_gem")
36
+ end
37
+ end
38
+ end
@@ -6,7 +6,7 @@ require 'minitest/reporters'
6
6
 
7
7
  module MiniTestReportersTest
8
8
  require File.expand_path('../support/test_case', __FILE__)
9
-
9
+
10
10
  module Fixtures
11
11
  require File.expand_path('../support/fixtures/test_case_fixture', __FILE__)
12
12
  require File.expand_path('../support/fixtures/empty_test_fixture', __FILE__)
@@ -24,13 +24,15 @@ MiniTest::Unit.runner = MiniTest::SuiteRunner.new
24
24
  # brittle. Consequently, there are no unit tests for them. Instead, uncomment
25
25
  # the reporter that you'd like to test and run the full test suite. Make sure to
26
26
  # try them with skipped, failing, and error tests as well!
27
- #
27
+ #
28
28
  # Personally, I like the progress reporter. Make sure you don't change that line
29
29
  # when you commit.
30
- if ENV['TM_PID']
30
+ if ENV["TM_PID"]
31
31
  MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMateReporter.new
32
+ elsif ENV["RM_INFO"]
33
+ MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
32
34
  else
33
35
  # MiniTest::Unit.runner.reporters << MiniTest::Reporters::DefaultReporter.new
34
36
  # MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new
35
37
  MiniTest::Unit.runner.reporters << MiniTest::Reporters::ProgressReporter.new
36
- end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-28 00:00:00.000000000Z
12
+ date: 2012-01-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &2164351020 !ruby/object:Gem::Requirement
16
+ requirement: &70355216336440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164351020
24
+ version_requirements: *70355216336440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ansi
27
- requirement: &2164350600 !ruby/object:Gem::Requirement
27
+ requirement: &70355216335720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164350600
35
+ version_requirements: *70355216335720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-progressbar
38
- requirement: &2164350140 !ruby/object:Gem::Requirement
38
+ requirement: &70355216335180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2164350140
46
+ version_requirements: *70355216335180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &2164349720 !ruby/object:Gem::Requirement
49
+ requirement: &70355216334660 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2164349720
57
+ version_requirements: *70355216334660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: maruku
60
- requirement: &2164349300 !ruby/object:Gem::Requirement
60
+ requirement: &70355216334060 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2164349300
68
+ version_requirements: *70355216334060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: test_declarative
71
- requirement: &2164348880 !ruby/object:Gem::Requirement
71
+ requirement: &70355216333360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2164348880
79
+ version_requirements: *70355216333360
80
80
  description: Death to haphazard monkey-patching! Extend MiniTest through simple hooks.
81
81
  email:
82
82
  - alex@kernul.com
@@ -91,19 +91,22 @@ files:
91
91
  - LICENSE
92
92
  - README.md
93
93
  - Rakefile
94
+ - lib/minitest/backtrace_filter.rb
94
95
  - lib/minitest/reporter.rb
95
96
  - lib/minitest/reporters.rb
96
97
  - lib/minitest/reporters/default_reporter.rb
97
98
  - lib/minitest/reporters/progress_reporter.rb
98
99
  - lib/minitest/reporters/ruby_mate_reporter.rb
100
+ - lib/minitest/reporters/rubymine_reporter.rb
99
101
  - lib/minitest/reporters/spec_reporter.rb
100
102
  - lib/minitest/reporters/version.rb
101
103
  - lib/minitest/suite_runner.rb
102
104
  - lib/minitest/test_runner.rb
103
105
  - minitest-reporters.gemspec
104
- - test/journo/reporter_test.rb
105
- - test/journo/suite_runner_test.rb
106
- - test/journo/test_runner_test.rb
106
+ - test/minitest/backtrace_filter_test.rb
107
+ - test/minitest/reporter_test.rb
108
+ - test/minitest/suite_runner_test.rb
109
+ - test/minitest/test_runner_test.rb
107
110
  - test/support/fixtures/empty_test_fixture.rb
108
111
  - test/support/fixtures/error_test_fixture.rb
109
112
  - test/support/fixtures/failure_test_fixture.rb
@@ -133,14 +136,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
136
  version: '0'
134
137
  requirements: []
135
138
  rubyforge_project: minitest-reporters
136
- rubygems_version: 1.8.6
139
+ rubygems_version: 1.8.10
137
140
  signing_key:
138
141
  specification_version: 3
139
142
  summary: Create customizable MiniTest output formats
140
143
  test_files:
141
- - test/journo/reporter_test.rb
142
- - test/journo/suite_runner_test.rb
143
- - test/journo/test_runner_test.rb
144
+ - test/minitest/backtrace_filter_test.rb
145
+ - test/minitest/reporter_test.rb
146
+ - test/minitest/suite_runner_test.rb
147
+ - test/minitest/test_runner_test.rb
144
148
  - test/support/fixtures/empty_test_fixture.rb
145
149
  - test/support/fixtures/error_test_fixture.rb
146
150
  - test/support/fixtures/failure_test_fixture.rb
@@ -150,3 +154,4 @@ test_files:
150
154
  - test/support/fixtures/test_case_fixture.rb
151
155
  - test/support/test_case.rb
152
156
  - test/test_helper.rb
157
+ has_rdoc: