minitest-hooks 1.4.1 → 1.4.2

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: d783ae841e96a694f434edcdc954f1ba84d55dcf
4
- data.tar.gz: 834f32299a9ac3543d5bb54fc6c70981f36b5f53
3
+ metadata.gz: cab2b3cd7d0bc63cc18436e87e08ff392e9facfc
4
+ data.tar.gz: 82eed894ed6beab837d83fd94a64ab3c36e1acb4
5
5
  SHA512:
6
- metadata.gz: d2ffd54816bc6486818e5f48b242029a9b6f8224be7b4b1deb3c804e30712947d2522805c91fef6a9917a37335e2affd352c9f5ea21a42ec0523dc3b4d556b4e
7
- data.tar.gz: bc165e9d45529d4fdedcd7efa8b244d34cfa7c0429283ff2d8a735501b7aba8230573f67f315b689d925450e2179c492d4532974d029939495f1303045d1b9e0
6
+ metadata.gz: fa12984df59acb3da5d4d038f2d5aa83b758724a5f7a2d258f6f82ddc5d23d7afc739eaaa9b09bdd72befa7f040f693a398ced29b3086e6ef9278118753975bb
7
+ data.tar.gz: b2e8f5f4bdf2e1283711cb2b947da5ea5526eaf7e00bd2ec0912011764203c16f7ba376011df4898a4bb8108599b6e416b447859838af44d7adf229f89d152ee
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.4.2 (2017-09-12)
2
+
3
+ * Don't modify test instance name if before_all/after_all cause an error (jeremyevans) (#14)
4
+
5
+ * Set around_all test instance name to strings so that exceptions in {before,after,around}_all don't break reporters (jeremyevans) (#14)
6
+
7
+ * Set time to 0 for around_all test instance so that exceptions in {before,after,around}_all don't break reporters (jeremyevans) (#13, #14)
8
+
1
9
  === 1.4.1 (2017-07-31)
2
10
 
3
11
  * Set test/spec name correctly when running before(:all)/after(:all)/around(:all) hooks (rcrogers, jeremyevans) (#12)
data/Rakefile CHANGED
@@ -12,9 +12,7 @@ end
12
12
 
13
13
  desc "Run specs"
14
14
  task :spec do
15
- ENV['RUBY'] = FileUtils::RUBY
16
- ENV['RUBYLIB'] = "lib:#{ENV['RUBYLIB']}"
17
- sh %{#{FileUtils::RUBY} -I lib -e 'ARGV.each{|f| require f}' ./spec/*.rb}
15
+ sh %{#{FileUtils::RUBY} spec/all.rb}
18
16
  end
19
17
 
20
18
  task :default=>:spec
@@ -49,7 +49,7 @@ module Minitest::Hooks::ClassMethods
49
49
  # Unless name is NEW, return a dup singleton instance.
50
50
  def new(name)
51
51
  if name.equal?(NEW)
52
- return super(:around_all)
52
+ return super('around_all')
53
53
  end
54
54
 
55
55
  instance = @instance.dup
@@ -63,14 +63,15 @@ 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
66
+ @instance.time = 0
67
+ description = respond_to?(:desc) ? desc : name
68
+ @instance.name = "#{description}#around_all"
67
69
 
68
70
  begin
69
71
  @instance.around_all do
70
- inside = true
71
72
  begin
72
73
  @instance.capture_exceptions do
73
- @instance.name = :before_all
74
+ @instance.name = "#{description}#before_all"
74
75
  @instance.before_all
75
76
  end
76
77
 
@@ -82,15 +83,14 @@ module Minitest::Hooks::ClassMethods
82
83
  end
83
84
  ensure
84
85
  @instance.capture_exceptions do
85
- @instance.name = :after_all
86
+ @instance.name = "#{description}#after_all" unless failed
86
87
  @instance.after_all
87
88
  end
88
89
  if @instance.failure && !failed
89
90
  failed = true
90
91
  reporter.record @instance
91
92
  end
92
- @instance.name = :around_all
93
- inside = false
93
+ @instance.name = "#{description}#around_all" unless failed
94
94
  end
95
95
  end
96
96
  rescue => e
@@ -0,0 +1,4 @@
1
+ require 'rbconfig'
2
+ ENV['RUBY'] ||= ENV["RUBY"] || File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).sub(/.*\s.*/m, '"\&"')
3
+ ENV['RUBYLIB'] = "lib:#{ENV['RUBYLIB']}"
4
+ Dir['./spec/*_spec.rb'].each{|f| require f}
@@ -24,6 +24,14 @@ describe 'Minitest::Hooks error handling' do
24
24
  around(:all) do |&block|
25
25
  raise if error == 'around-all-before'
26
26
  super(&block)
27
+ case error
28
+ when 'before-all'
29
+ name.must_equal 'Minitest::Hooks error handling#before_all'
30
+ when 'after-all'
31
+ name.must_equal 'Minitest::Hooks error handling#after_all'
32
+ else
33
+ name.must_equal 'Minitest::Hooks error handling#around_all'
34
+ end
27
35
  raise if error == 'around-all-after'
28
36
  end
29
37
 
@@ -1,4 +1,6 @@
1
+ $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../lib/"))
1
2
  require 'rubygems'
2
3
  require 'sequel'
3
4
  gem 'minitest'
4
5
  require 'minitest/autorun'
6
+ DATABASE_URL = ENV['DATABASE_URL'] || (defined?(JRUBY_VERSION) ? 'jdbc:sqlite::memory:' : 'sqlite:/')
@@ -3,17 +3,15 @@ require 'minitest/hooks/default'
3
3
 
4
4
  describe 'Minitest::Hooks error handling' do
5
5
  before(:all) do
6
- name.must_equal :before_all
6
+ name.must_equal 'Minitest::Hooks error handling#before_all'
7
7
  end
8
8
  after(:all) do
9
- name.must_equal :after_all
10
- end
11
- around do |&block|
9
+ name.must_equal 'Minitest::Hooks error handling#after_all'
12
10
  end
13
11
  around(:all) do |&block|
14
- name.must_equal :around_all
12
+ name.must_equal 'Minitest::Hooks error handling#around_all'
15
13
  super(&block)
16
- name.must_equal :around_all
14
+ name.must_equal 'Minitest::Hooks error handling#around_all'
17
15
  end
18
16
 
19
17
  3.times do |i|
@@ -21,3 +19,24 @@ describe 'Minitest::Hooks error handling' do
21
19
  end
22
20
  end
23
21
  end
22
+
23
+ class MinitestHooksNameTest < Minitest::Test
24
+ include Minitest::Hooks
25
+
26
+ def before_all
27
+ assert_equal 'MinitestHooksNameTest#before_all', name
28
+ end
29
+ def after_all
30
+ assert_equal 'MinitestHooksNameTest#after_all', name
31
+ end
32
+ def around_all
33
+ assert_equal 'MinitestHooksNameTest#around_all', name
34
+ super
35
+ assert_equal 'MinitestHooksNameTest#around_all', name
36
+ end
37
+
38
+ 3.times do |i|
39
+ define_method "test_should_work_try_#{i}" do
40
+ end
41
+ end
42
+ end
@@ -1,7 +1,7 @@
1
1
  require './spec/helper'
2
2
  require 'minitest/hooks'
3
3
 
4
- NDB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/')
4
+ NDB = Sequel.connect(DATABASE_URL)
5
5
 
6
6
  MiniTest::Spec.register_spec_type(/no_default/, Minitest::Spec)
7
7
 
@@ -8,7 +8,7 @@ describe 'Minitest::Hooks error handling' do
8
8
  def self.run_test(desc, runs, errors)
9
9
  it "should handle errors in #{desc}" do
10
10
  ENV['MINITEST_HOOKS_ERRORS'] = desc
11
- Open3.popen3(RUBY, "spec/errors/example.rb") do |_, o, e, w|
11
+ Open3.popen3(RUBY, "spec/errors/example.rb", "-v") do |_, o, e, w|
12
12
  o.read.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/
13
13
  e.read.must_equal ''
14
14
  w.value.exitstatus.wont_equal 0 if w
@@ -1,7 +1,7 @@
1
1
  require './spec/helper'
2
2
  require 'minitest/hooks/default'
3
3
 
4
- DB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/')
4
+ DB = Sequel.connect(DATABASE_URL)
5
5
 
6
6
  describe 'Minitest::Hooks with transactions/savepoints' do
7
7
  before(:all) do
@@ -6,7 +6,7 @@ class MyTest < Minitest::Test
6
6
  end
7
7
 
8
8
  class TestMinitestHooks < MyTest
9
- DB = Sequel.connect(ENV['DATABASE_URL'] || 'sqlite:/')
9
+ DB = Sequel.connect(DATABASE_URL)
10
10
 
11
11
  def before_all
12
12
  super
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.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -86,6 +86,7 @@ files:
86
86
  - lib/minitest/hooks.rb
87
87
  - lib/minitest/hooks/default.rb
88
88
  - lib/minitest/hooks/test.rb
89
+ - spec/all.rb
89
90
  - spec/errors/example.rb
90
91
  - spec/helper.rb
91
92
  - spec/minitest_hooks_all_name_spec.rb
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  version: '0'
121
122
  requirements: []
122
123
  rubyforge_project:
123
- rubygems_version: 2.6.11
124
+ rubygems_version: 2.6.13
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: Around and before_all/after_all/around_all hooks for Minitest