minitest-hooks 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 678da317b529ac1cf071fd42f4abd5d325ccfb55
4
- data.tar.gz: 2462e95a886cc806fe5fd14caa1157ab19ce9efe
3
+ metadata.gz: 46c586c45d801e02455f2d74a92f50e01a17d879
4
+ data.tar.gz: e9d4dbde7545d3d5fbe792c83ddf2760a88944c9
5
5
  SHA512:
6
- metadata.gz: 34e5d358da0294ec5819af4afaa9594bfa313008d8f038986d494b33e9600161ab0a076c3bc42a60f49e57eba62fb56cecf2f02dcfaf76388d896062d4370429
7
- data.tar.gz: efe83c55538e493b71104e53a8a20a24fc1be05c8b5f1250f3bed6f5a35c23f76a427df209e46da6f06dfc329ad1250a7aeb62447a9f954800bc73be2dda83d7
6
+ metadata.gz: b9d8417604cb8cb9b55bfea18bd4b6d5ce4668f7efa50fcfbe9f63211ba7217ff072b3769c8789bd6f7284604fd39a5452d0eace4718ced3206718e64925a4cf
7
+ data.tar.gz: 89eb265c8ec02d84cafa99440e80c6b681ef9e40d2f30207067b6ac773d2fe6a201827f0f484b406480e5a06d6c10e5166d64eb112fcd57ef79e14e52b071a6f
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.4.0 (2015-11-17)
2
+
3
+ * Handle errors in before(:all)/after(:all)/around(:all) hooks (jeremyevans)
4
+
1
5
  === 1.3.0 (2015-08-17)
2
6
 
3
7
  * Don't run before_all/after_all/around_all hooks for classes with no tests/specs when using minitest >= 5.8.0 (jeremyevans) (#7)
data/Rakefile CHANGED
@@ -12,6 +12,8 @@ end
12
12
 
13
13
  desc "Run specs"
14
14
  task :spec do
15
+ ENV['RUBY'] = FileUtils::RUBY
16
+ ENV['RUBYLIB'] = "lib:#{ENV['RUBYLIB']}"
15
17
  sh %{#{FileUtils::RUBY} -I lib -e 'ARGV.each{|f| require f}' ./spec/*.rb}
16
18
  end
17
19
 
@@ -63,14 +63,38 @@ module Minitest::Hooks::ClassMethods
63
63
  # dup of the singleton instance.
64
64
  def with_info_handler(reporter, &block)
65
65
  @instance = new(NEW)
66
+ inside = false
67
+
68
+ begin
69
+ @instance.around_all do
70
+ inside = true
71
+ begin
72
+ @instance.capture_exceptions do
73
+ @instance.before_all
74
+ end
66
75
 
67
- @instance.around_all do
68
- begin
69
- @instance.before_all
70
- super(reporter, &block)
71
- ensure
72
- @instance.after_all
76
+ if @instance.failure
77
+ failed = true
78
+ reporter.record @instance
79
+ else
80
+ super(reporter, &block)
81
+ end
82
+ ensure
83
+ @instance.capture_exceptions do
84
+ @instance.after_all
85
+ end
86
+ if @instance.failure && !failed
87
+ failed = true
88
+ reporter.record @instance
89
+ end
90
+ inside = false
91
+ end
73
92
  end
93
+ rescue => e
94
+ @instance.capture_exceptions do
95
+ raise e
96
+ end
97
+ reporter.record @instance
74
98
  end
75
99
  end
76
100
 
@@ -0,0 +1,34 @@
1
+ require './spec/helper'
2
+ require 'minitest/hooks/default'
3
+
4
+ error = ENV['MINITEST_HOOKS_ERRORS']
5
+
6
+ describe 'Minitest::Hooks error handling' do
7
+ before(:all) do
8
+ raise if error == 'before-all'
9
+ end
10
+ before do
11
+ raise if error == 'before'
12
+ end
13
+ after do
14
+ raise if error == 'after'
15
+ end
16
+ after(:all) do
17
+ raise if error == 'after-all'
18
+ end
19
+ around do |&block|
20
+ raise if error == 'around-before'
21
+ super(&block)
22
+ raise if error == 'around-after'
23
+ end
24
+ around(:all) do |&block|
25
+ raise if error == 'around-all-before'
26
+ super(&block)
27
+ raise if error == 'around-all-after'
28
+ end
29
+
30
+ 3.times do |i|
31
+ it "should work try #{i}" do
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ require './spec/helper'
2
+ require 'minitest/hooks/default'
3
+ require 'open3'
4
+
5
+ RUBY = ENV['RUBY'] || 'ruby'
6
+
7
+ describe 'Minitest::Hooks error handling' do
8
+ def self.run_test(desc, runs, errors)
9
+ it "should handle errors in #{desc}" do
10
+ ENV['MINITEST_HOOKS_ERRORS'] = desc
11
+ Open3.popen3(RUBY, "spec/errors/example.rb") do |_, o, e, w|
12
+ o.read.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/
13
+ e.read.must_equal ''
14
+ w.value.exitstatus.wont_equal 0 if w
15
+ end
16
+ end
17
+ end
18
+
19
+ run_test "before-all", 1, 1
20
+ run_test "before", 3, 3
21
+ run_test "after", 3, 3
22
+ run_test "after-all", 4, 1
23
+ run_test "around-before", 1, 1
24
+ run_test "around-after", 1, 1
25
+ run_test "around-all-before", 1, 1
26
+ run_test "around-all-after", 4, 1
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -86,8 +86,10 @@ files:
86
86
  - lib/minitest/hooks.rb
87
87
  - lib/minitest/hooks/default.rb
88
88
  - lib/minitest/hooks/test.rb
89
+ - spec/errors/example.rb
89
90
  - spec/helper.rb
90
91
  - spec/minitest_hooks_direct_spec.rb
92
+ - spec/minitest_hooks_errors_spec.rb
91
93
  - spec/minitest_hooks_spec.rb
92
94
  - spec/minitest_hooks_test.rb
93
95
  homepage: http://github.com/jeremyevans/minitest-hooks
@@ -117,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  version: '0'
118
120
  requirements: []
119
121
  rubyforge_project:
120
- rubygems_version: 2.4.5
122
+ rubygems_version: 2.4.5.1
121
123
  signing_key:
122
124
  specification_version: 4
123
125
  summary: Around and before_all/after_all/around_all hooks for Minitest