minitest-reporters 0.14.24 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require 'ansi/code'
2
2
 
3
- module MiniTest
3
+ module Minitest
4
4
  module Reporters
5
5
  # Turn-like reporter that reads like a spec.
6
6
  #
@@ -8,89 +8,46 @@ module MiniTest
8
8
  #
9
9
  # @see https://github.com/TwP/turn turn
10
10
  # @see https://gist.github.com/356945 paydro's monkey-patch
11
- class SpecReporter
12
- include Reporter
11
+ class SpecReporter < BaseReporter
13
12
  include ANSI::Code
14
13
  include RelativePosition
15
14
 
16
- def initialize
17
- @suites = []
18
- end
19
-
20
- def before_suites(suites, type)
15
+ def start
16
+ super
21
17
  puts 'Started'
22
18
  puts
23
19
  end
24
20
 
25
- def after_suites(suites, type)
26
- total_time = Time.now - runner.suites_start_time
27
-
21
+ def report
22
+ super
28
23
  puts('Finished in %.5fs' % total_time)
29
- print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
30
- print(red { '%d failures, %d errors, ' } % [runner.failures, runner.errors])
31
- print(yellow { '%d skips' } % runner.skips)
24
+ print('%d tests, %d assertions, ' % [count, assertions])
25
+ print(red { '%d failures, %d errors, ' } % [failures, errors])
26
+ print(yellow { '%d skips' } % skips)
32
27
  puts
33
28
  end
34
29
 
35
- def after_suite(suite)
36
- puts if @suites.include?(suite)
37
- end
38
-
39
- def pass(suite, test, test_runner)
40
- print_suite(suite) unless @suites.include?(suite)
41
- print pad_test(test)
42
- print(green { pad_mark('PASS') })
43
- print_time(test)
30
+ def record(test)
31
+ super
32
+ print pad_test(test.name)
33
+ print(green { pad_mark( result(test).to_s.upcase ) })
34
+ print(" (%.2fs)" % test.time)
44
35
  puts
36
+ if test.failure
37
+ print_info(test.failure)
38
+ puts
39
+ end
45
40
  end
46
41
 
47
- def skip(suite, test, test_runner)
48
- print_suite(suite) unless @suites.include?(suite)
49
- print pad_test(test)
50
- print(yellow { pad_mark('SKIP') })
51
- print_time(test)
52
- puts
53
- end
42
+ protected
54
43
 
55
- def failure(suite, test, test_runner)
56
- print_suite(suite) unless @suites.include?(suite)
57
- print pad_test(test)
58
- print(red { pad_mark('FAIL') })
59
- print_time(test)
60
- puts
61
- print_info(test_runner.exception)
62
- puts
44
+ def before_suite(suite)
45
+ puts suite
63
46
  end
64
47
 
65
- def error(suite, test, test_runner)
66
- print_suite(suite) unless @suites.include?(suite)
67
- print pad_test(test)
68
- print(red { pad_mark('ERROR') })
69
- print_time(test)
70
- puts
71
- print_info(test_runner.exception)
48
+ def after_suite(suite)
72
49
  puts
73
50
  end
74
-
75
- private
76
-
77
- def print_suite(suite)
78
- puts suite.name
79
- @suites << suite
80
- end
81
-
82
- def print_time(test)
83
- total_time = Time.now - (runner.test_start_time || Time.now)
84
- print(" (%.2fs)" % total_time)
85
- end
86
-
87
- def print_info(e)
88
- print "#{e.exception.class.to_s}: "
89
- e.message.each_line { |line| print_with_info_padding(line) }
90
-
91
- trace = filter_backtrace(e.backtrace)
92
- trace.each { |line| print_with_info_padding(line) }
93
- end
94
51
  end
95
52
  end
96
53
  end
@@ -1,5 +1,5 @@
1
- module MiniTest
1
+ module Minitest
2
2
  module Reporters
3
- VERSION = '0.14.24'
3
+ VERSION = '1.0.0.beta1'
4
4
  end
5
5
  end
@@ -1,67 +1,50 @@
1
1
  require "minitest/unit"
2
2
 
3
- module MiniTest
3
+ module Minitest
4
4
  require "minitest/relative_position"
5
- require "minitest/reporter"
6
- require "minitest/reporter_runner"
7
- require "minitest/around_test_hooks"
8
- require "minitest/test_runner"
9
- require "minitest/test_recorder"
10
5
  require "minitest/extensible_backtrace_filter"
11
6
 
12
7
  module Reporters
13
8
  require "minitest/reporters/version"
14
9
 
10
+ autoload :BaseReporter, "minitest/reporters/base_reporter"
15
11
  autoload :DefaultReporter, "minitest/reporters/default_reporter"
16
12
  autoload :SpecReporter, "minitest/reporters/spec_reporter"
17
13
  autoload :ProgressReporter, "minitest/reporters/progress_reporter"
18
14
  autoload :RubyMateReporter, "minitest/reporters/ruby_mate_reporter"
19
15
  autoload :RubyMineReporter, "minitest/reporters/rubymine_reporter"
20
- autoload :GuardReporter, "minitest/reporters/guard_reporter"
21
16
  autoload :JUnitReporter, "minitest/reporters/junit_reporter"
22
17
 
18
+ class << self
19
+ attr_accessor :reporters
20
+ end
21
+
23
22
  def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = ExtensibleBacktraceFilter.default_filter)
24
23
  use_runner!(console_reporters, env)
25
- use_backtrace_filter!(backtrace_filter)
24
+ Minitest.backtrace_filter = backtrace_filter
26
25
 
27
26
  unless defined?(@@loaded)
28
27
  use_around_test_hooks!
29
- use_parallel_length_method!
30
28
  use_old_activesupport_fix!
29
+ @@loaded = true
31
30
  end
32
-
33
- @@loaded = true
34
31
  end
35
32
 
36
33
  def self.use_runner!(console_reporters, env)
37
- runner = ReporterRunner.new
38
- runner.reporters = choose_reporters(console_reporters, env)
39
- Unit.runner = runner
40
- end
41
-
42
- def self.use_backtrace_filter!(backtrace_filter)
43
- if Unit::VERSION < "4.1.0" && !defined?(@@loaded)
44
- MiniTest.class_eval do
45
- class << self
46
- attr_accessor :backtrace_filter
47
- end
48
-
49
- def self.filter_backtrace(backtrace)
50
- backtrace_filter.filter(backtrace)
51
- end
52
- end
53
- end
54
-
55
- MiniTest.backtrace_filter = backtrace_filter
34
+ self.reporters = choose_reporters(console_reporters, env)
56
35
  end
57
36
 
58
37
  def self.use_around_test_hooks!
59
- Unit::TestCase.class_eval do
60
- def run_with_hooks(runner)
61
- AroundTestHooks.before_test(self)
62
- result = run_without_hooks(runner)
63
- AroundTestHooks.after_test(self)
64
- result
38
+ Minitest::Test.class_eval do
39
+ def run_with_hooks(*args)
40
+ if defined?(Minitest::Reporters) && reporters = Minitest::Reporters.reporters
41
+ reporters.each { |r| r.before_test(self) }
42
+ result = run_without_hooks(*args)
43
+ reporters.each { |r| r.after_test(self) }
44
+ result
45
+ else
46
+ run_without_hooks(*args)
47
+ end
65
48
  end
66
49
 
67
50
  alias_method :run_without_hooks, :run
@@ -79,16 +62,6 @@ module MiniTest
79
62
  end
80
63
  end
81
64
 
82
- def self.use_parallel_length_method!
83
- if Unit::VERSION >= "4.2.0"
84
- require "minitest/parallel_each"
85
-
86
- ParallelEach.send(:define_method, :length) do
87
- @queue.length
88
- end
89
- end
90
- end
91
-
92
65
  def self.use_old_activesupport_fix!
93
66
  if defined?(ActiveSupport::VERSION) && ActiveSupport::VERSION::MAJOR < 4
94
67
  require "minitest/old_activesupport_fix"
@@ -4,24 +4,23 @@ require 'minitest/reporters/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'minitest-reporters'
7
- s.version = MiniTest::Reporters::VERSION
7
+ s.version = Minitest::Reporters::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Alexander Kern']
10
10
  s.email = ['alex@kernul.com']
11
11
  s.homepage = 'https://github.com/CapnKernul/minitest-reporters'
12
- s.summary = %q{Create customizable MiniTest output formats}
13
- s.description = %q{Death to haphazard monkey-patching! Extend MiniTest through simple hooks.}
12
+ s.summary = %q{Create customizable Minitest output formats}
13
+ s.description = %q{Death to haphazard monkey-patching! Extend Minitest through simple hooks.}
14
14
 
15
15
  s.rubyforge_project = 'minitest-reporters'
16
16
 
17
- s.add_dependency 'minitest', '>= 2.12', '< 5.0'
17
+ s.add_dependency 'minitest', '>= 5.0'
18
18
  s.add_dependency 'ansi'
19
19
  s.add_dependency 'powerbar'
20
20
  s.add_dependency 'builder'
21
21
 
22
22
  s.add_development_dependency 'maruku'
23
23
  s.add_development_dependency 'rake'
24
- s.add_development_dependency 'guard-minitest'
25
24
 
26
25
  s.files = `git ls-files`.split("\n")
27
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -1,6 +1,6 @@
1
1
  require_relative "../test_helper"
2
2
 
3
- module MiniTestReportersTest
3
+ module MinitestReportersTest
4
4
  class BadTest < TestCase
5
5
  def test_a
6
6
  assert_equal 1, 2
@@ -1,6 +1,6 @@
1
1
  require_relative "../test_helper"
2
2
 
3
- module MiniTestReportersTest
3
+ module MinitestReportersTest
4
4
  class GoodTest < TestCase
5
5
  def test_a
6
6
  assert_equal 1, 1
@@ -6,10 +6,10 @@ require 'bundler/setup'
6
6
  require 'minitest/autorun'
7
7
  require 'minitest/reporters'
8
8
 
9
- MiniTest::Reporters.use! MiniTest::Reporters::JUnitReporter.new
9
+ Minitest::Reporters.use! Minitest::Reporters::JUnitReporter.new
10
10
 
11
11
  describe 'something/other' do
12
12
  it 'does something' do
13
13
  1.must_equal 1
14
14
  end
15
- end
15
+ end
@@ -1,6 +1,6 @@
1
1
  require_relative "../../test_helper"
2
2
 
3
- module MiniTestReportersTest
3
+ module MinitestReportersTest
4
4
  class JUnitReporterTest < TestCase
5
5
  def test_replaces_special_characters_for_filenames_and_doesnt_crash
6
6
  fixtures_directory = File.expand_path('../../fixtures', __FILE__)
@@ -9,4 +9,4 @@ module MiniTestReportersTest
9
9
  refute_match 'No such file or directory', output
10
10
  end
11
11
  end
12
- end
12
+ end
data/test/test_helper.rb CHANGED
@@ -2,8 +2,8 @@ require "bundler/setup"
2
2
  require "minitest/autorun"
3
3
  require "minitest/reporters"
4
4
 
5
- module MiniTestReportersTest
6
- class TestCase < MiniTest::Unit::TestCase
5
+ module MinitestReportersTest
6
+ class TestCase < Minitest::Test
7
7
  end
8
8
  end
9
9
 
@@ -12,9 +12,8 @@ end
12
12
  # all the reporters sequentially on a fake test suite, run `rake gallery`.
13
13
 
14
14
  if ENV["REPORTER"]
15
- reporter_klass = MiniTest::Reporters.const_get(ENV["REPORTER"])
16
- MiniTest::Reporters.use!(reporter_klass.new)
15
+ reporter_klass = Minitest::Reporters.const_get(ENV["REPORTER"])
16
+ Minitest::Reporters.use!(reporter_klass.new)
17
17
  else
18
- MiniTest::Reporters.use!(MiniTest::Reporters::DefaultReporter.new)
19
- MiniTest::Reporters.use!(MiniTest::Reporters::DefaultReporter.new)
18
+ Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
20
19
  end
@@ -1,10 +1,10 @@
1
1
  require_relative "../../test_helper"
2
2
 
3
- module MiniTestReportersTest
3
+ module MinitestReportersTest
4
4
  class ExtensibleBacktraceFilterTest < TestCase
5
5
  def setup
6
- @default_filter = MiniTest::ExtensibleBacktraceFilter.default_filter
7
- @filter = MiniTest::ExtensibleBacktraceFilter.new
6
+ @default_filter = Minitest::ExtensibleBacktraceFilter.default_filter
7
+ @filter = Minitest::ExtensibleBacktraceFilter.new
8
8
  @backtrace = ["foo", "bar", "baz"]
9
9
  end
10
10
 
@@ -1,31 +1,28 @@
1
1
  require_relative "../../test_helper"
2
- require "stringio"
2
+ require "minitest/mock"
3
3
 
4
- module MiniTestReportersTest
5
- class ReportersTest < TestCase
4
+ module MinitestReportersTest
5
+ class ReportersTest < Minitest::Test
6
6
  def test_chooses_the_rubymine_reporter_when_necessary
7
7
  # Rubymine reporter complains when RubyMine libs are not available, so
8
8
  # stub its #puts method out.
9
- original_output = MiniTest::Unit.runner.output
10
- MiniTest::Unit.runner.send(:define_singleton_method, :output) { StringIO.new }
9
+ $stdout.stub :puts, nil do
10
+ reporters = Minitest::Reporters.choose_reporters [], { "RM_INFO" => "x" }
11
+ assert_instance_of Minitest::Reporters::RubyMineReporter, reporters[0]
11
12
 
12
- reporters = Minitest::Reporters.choose_reporters [], { "RM_INFO" => "x" }
13
- assert_instance_of MiniTest::Reporters::RubyMineReporter, reporters[0]
14
-
15
- reporters = Minitest::Reporters.choose_reporters [], { "TEAMCITY_VERSION" => "x" }
16
- assert_instance_of MiniTest::Reporters::RubyMineReporter, reporters[0]
17
- ensure
18
- MiniTest::Unit.runner.send(:define_singleton_method, :output) { original_output }
13
+ reporters = Minitest::Reporters.choose_reporters [], { "TEAMCITY_VERSION" => "x" }
14
+ assert_instance_of Minitest::Reporters::RubyMineReporter, reporters[0]
15
+ end
19
16
  end
20
17
 
21
18
  def test_chooses_the_textmate_reporter_when_necessary
22
19
  reporters = Minitest::Reporters.choose_reporters [], {"TM_PID" => "x"}
23
- assert_instance_of MiniTest::Reporters::RubyMateReporter, reporters[0]
20
+ assert_instance_of Minitest::Reporters::RubyMateReporter, reporters[0]
24
21
  end
25
22
 
26
23
  def test_chooses_the_console_reporters_when_necessary
27
- reporters = Minitest::Reporters.choose_reporters [MiniTest::Reporters::SpecReporter.new], {}
28
- assert_instance_of MiniTest::Reporters::SpecReporter, reporters[0]
24
+ reporters = Minitest::Reporters.choose_reporters [Minitest::Reporters::SpecReporter.new], {}
25
+ assert_instance_of Minitest::Reporters::SpecReporter, reporters[0]
29
26
  end
30
27
  end
31
28
  end
metadata CHANGED
@@ -1,152 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-reporters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.24
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-12 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '2.12'
20
- - - "<"
17
+ - - '>='
21
18
  - !ruby/object:Gem::Version
22
19
  version: '5.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '2.12'
30
- - - "<"
24
+ - - '>='
31
25
  - !ruby/object:Gem::Version
32
26
  version: '5.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: ansi
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">="
31
+ - - '>='
38
32
  - !ruby/object:Gem::Version
39
33
  version: '0'
40
34
  type: :runtime
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
- - - ">="
38
+ - - '>='
45
39
  - !ruby/object:Gem::Version
46
40
  version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: powerbar
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - ">="
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - ">="
52
+ - - '>='
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: builder
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - ">="
59
+ - - '>='
66
60
  - !ruby/object:Gem::Version
67
61
  version: '0'
68
62
  type: :runtime
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - ">="
66
+ - - '>='
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: maruku
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - ">="
73
+ - - '>='
80
74
  - !ruby/object:Gem::Version
81
75
  version: '0'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
- - - ">="
80
+ - - '>='
87
81
  - !ruby/object:Gem::Version
88
82
  version: '0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: rake
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: guard-minitest
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
87
+ - - '>='
108
88
  - !ruby/object:Gem::Version
109
89
  version: '0'
110
90
  type: :development
111
91
  prerelease: false
112
92
  version_requirements: !ruby/object:Gem::Requirement
113
93
  requirements:
114
- - - ">="
94
+ - - '>='
115
95
  - !ruby/object:Gem::Version
116
96
  version: '0'
117
- description: Death to haphazard monkey-patching! Extend MiniTest through simple hooks.
97
+ description: Death to haphazard monkey-patching! Extend Minitest through simple hooks.
118
98
  email:
119
99
  - alex@kernul.com
120
100
  executables: []
121
101
  extensions: []
122
102
  extra_rdoc_files: []
123
103
  files:
124
- - ".gitignore"
125
- - ".ruby-gemset"
126
- - ".ruby-version"
127
- - ".travis.yml"
128
- - ".yardopts"
104
+ - .gitignore
105
+ - .ruby-gemset
106
+ - .ruby-version
107
+ - .travis.yml
108
+ - .yardopts
129
109
  - Gemfile
130
110
  - LICENSE
131
111
  - README.md
132
112
  - Rakefile
133
- - lib/minitest/around_test_hooks.rb
134
113
  - lib/minitest/extensible_backtrace_filter.rb
114
+ - lib/minitest/minitest_reporter_plugin.rb
135
115
  - lib/minitest/old_activesupport_fix.rb
136
116
  - lib/minitest/relative_position.rb
137
- - lib/minitest/reporter.rb
138
- - lib/minitest/reporter_runner.rb
139
117
  - lib/minitest/reporters.rb
118
+ - lib/minitest/reporters/base_reporter.rb
140
119
  - lib/minitest/reporters/default_reporter.rb
141
- - lib/minitest/reporters/guard_reporter.rb
142
120
  - lib/minitest/reporters/junit_reporter.rb
143
121
  - lib/minitest/reporters/progress_reporter.rb
144
122
  - lib/minitest/reporters/ruby_mate_reporter.rb
145
123
  - lib/minitest/reporters/rubymine_reporter.rb
146
124
  - lib/minitest/reporters/spec_reporter.rb
147
125
  - lib/minitest/reporters/version.rb
148
- - lib/minitest/test_recorder.rb
149
- - lib/minitest/test_runner.rb
150
126
  - minitest-reporters.gemspec
151
127
  - test/gallery/bad_test.rb
152
128
  - test/gallery/good_test.rb
@@ -154,7 +130,6 @@ files:
154
130
  - test/integration/reporters/junit_reporter_test.rb
155
131
  - test/test_helper.rb
156
132
  - test/unit/minitest/extensible_backtrace_filter_test.rb
157
- - test/unit/minitest/reporter_test.rb
158
133
  - test/unit/minitest/reporters_test.rb
159
134
  homepage: https://github.com/CapnKernul/minitest-reporters
160
135
  licenses: []
@@ -165,18 +140,18 @@ require_paths:
165
140
  - lib
166
141
  required_ruby_version: !ruby/object:Gem::Requirement
167
142
  requirements:
168
- - - ">="
143
+ - - '>='
169
144
  - !ruby/object:Gem::Version
170
145
  version: '0'
171
146
  required_rubygems_version: !ruby/object:Gem::Requirement
172
147
  requirements:
173
- - - ">="
148
+ - - '>'
174
149
  - !ruby/object:Gem::Version
175
- version: '0'
150
+ version: 1.3.1
176
151
  requirements: []
177
152
  rubyforge_project: minitest-reporters
178
- rubygems_version: 2.2.0.rc.1
153
+ rubygems_version: 2.0.3
179
154
  signing_key:
180
155
  specification_version: 4
181
- summary: Create customizable MiniTest output formats
156
+ summary: Create customizable Minitest output formats
182
157
  test_files: []