minitest 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,14 @@
1
+ === 4.1.0 / 2012-10-05
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Added skip example to readme. (dissolved)
6
+ * Extracted backtrace filter to object. (tenderlove)
7
+
8
+ * 1 bug fix:
9
+
10
+ * OMG I'm so dumb. Fixed access to deprecated hook class methods. I hate ruby modules. (route)
11
+
1
12
  === 4.0.0 / 2012-09-28
2
13
 
3
14
  * 1 major enhancement:
data/README.txt CHANGED
@@ -93,6 +93,10 @@ Given that you'd like to test the following class:
93
93
  def test_that_it_will_not_blend
94
94
  refute_match /^no/i, @meme.will_it_blend?
95
95
  end
96
+
97
+ def test_that_will_be_skipped
98
+ skip "test this later"
99
+ end
96
100
  end
97
101
 
98
102
  === Specs
@@ -30,24 +30,36 @@ module MiniTest
30
30
 
31
31
  class Skip < Assertion; end
32
32
 
33
- def self.filter_backtrace bt # :nodoc:
34
- return ["No backtrace"] unless bt
33
+ class << self
34
+ attr_accessor :backtrace_filter
35
+ end
35
36
 
36
- new_bt = []
37
+ class BacktraceFilter # :nodoc:
38
+ def filter bt
39
+ return ["No backtrace"] unless bt
37
40
 
38
- unless $DEBUG then
39
- bt.each do |line|
40
- break if line =~ /lib\/minitest/
41
- new_bt << line
41
+ new_bt = []
42
+
43
+ unless $DEBUG then
44
+ bt.each do |line|
45
+ break if line =~ /lib\/minitest/
46
+ new_bt << line
47
+ end
48
+
49
+ new_bt = bt.reject { |line| line =~ /lib\/minitest/ } if new_bt.empty?
50
+ new_bt = bt.dup if new_bt.empty?
51
+ else
52
+ new_bt = bt.dup
42
53
  end
43
54
 
44
- new_bt = bt.reject { |line| line =~ /lib\/minitest/ } if new_bt.empty?
45
- new_bt = bt.dup if new_bt.empty?
46
- else
47
- new_bt = bt.dup
55
+ new_bt
48
56
  end
57
+ end
49
58
 
50
- new_bt
59
+ self.backtrace_filter = BacktraceFilter.new
60
+
61
+ def self.filter_backtrace bt # :nodoc:
62
+ backtrace_filter.filter bt
51
63
  end
52
64
 
53
65
  ##
@@ -694,7 +706,7 @@ module MiniTest
694
706
  end
695
707
 
696
708
  class Unit # :nodoc:
697
- VERSION = "4.0.0" # :nodoc:
709
+ VERSION = "4.1.0" # :nodoc:
698
710
 
699
711
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
700
712
  attr_accessor :test_count, :assertion_count # :nodoc:
@@ -1138,10 +1150,33 @@ module MiniTest
1138
1150
 
1139
1151
  module Deprecated # :nodoc:
1140
1152
 
1141
- ##
1142
- # This entire module is deprecated and slated for removal on 2013-01-01.
1153
+ ##
1154
+ # This entire module is deprecated and slated for removal on 2013-01-01.
1143
1155
 
1144
1156
  module Hooks
1157
+ def run_setup_hooks # :nodoc:
1158
+ _run_hooks self.class.setup_hooks
1159
+ end
1160
+
1161
+ def _run_hooks hooks # :nodoc:
1162
+ hooks.each do |hook|
1163
+ if hook.respond_to?(:arity) && hook.arity == 1
1164
+ hook.call(self)
1165
+ else
1166
+ hook.call
1167
+ end
1168
+ end
1169
+ end
1170
+
1171
+ def run_teardown_hooks # :nodoc:
1172
+ _run_hooks self.class.teardown_hooks.reverse
1173
+ end
1174
+ end
1175
+
1176
+ ##
1177
+ # This entire module is deprecated and slated for removal on 2013-01-01.
1178
+
1179
+ module HooksCM
1145
1180
  ##
1146
1181
  # Adds a block of code that will be executed before every
1147
1182
  # TestCase is run.
@@ -1149,13 +1184,13 @@ module MiniTest
1149
1184
  # NOTE: This method is deprecated, use before/after_setup. It
1150
1185
  # will be removed on 2013-01-01.
1151
1186
 
1152
- def self.add_setup_hook arg=nil, &block
1187
+ def add_setup_hook arg=nil, &block
1153
1188
  warn "NOTE: MiniTest::Unit::TestCase.add_setup_hook is deprecated, use before/after_setup via a module (and call super!). It will be removed on 2013-01-01. Called from #{caller.first}"
1154
1189
  hook = arg || block
1155
1190
  @setup_hooks << hook
1156
1191
  end
1157
1192
 
1158
- def self.setup_hooks # :nodoc:
1193
+ def setup_hooks # :nodoc:
1159
1194
  if superclass.respond_to? :setup_hooks then
1160
1195
  superclass.setup_hooks
1161
1196
  else
@@ -1163,20 +1198,6 @@ module MiniTest
1163
1198
  end + @setup_hooks
1164
1199
  end
1165
1200
 
1166
- def run_setup_hooks # :nodoc:
1167
- _run_hooks self.class.setup_hooks
1168
- end
1169
-
1170
- def _run_hooks hooks # :nodoc:
1171
- hooks.each do |hook|
1172
- if hook.respond_to?(:arity) && hook.arity == 1
1173
- hook.call(self)
1174
- else
1175
- hook.call
1176
- end
1177
- end
1178
- end
1179
-
1180
1201
  ##
1181
1202
  # Adds a block of code that will be executed after every
1182
1203
  # TestCase is run.
@@ -1184,23 +1205,19 @@ module MiniTest
1184
1205
  # NOTE: This method is deprecated, use before/after_teardown. It
1185
1206
  # will be removed on 2013-01-01.
1186
1207
 
1187
- def self.add_teardown_hook arg=nil, &block
1208
+ def add_teardown_hook arg=nil, &block
1188
1209
  warn "NOTE: MiniTest::Unit::TestCase#add_teardown_hook is deprecated, use before/after_teardown. It will be removed on 2013-01-01. Called from #{caller.first}"
1189
1210
  hook = arg || block
1190
1211
  @teardown_hooks << hook
1191
1212
  end
1192
1213
 
1193
- def self.teardown_hooks # :nodoc:
1214
+ def teardown_hooks # :nodoc:
1194
1215
  if superclass.respond_to? :teardown_hooks then
1195
1216
  superclass.teardown_hooks
1196
1217
  else
1197
1218
  []
1198
1219
  end + @teardown_hooks
1199
1220
  end
1200
-
1201
- def run_teardown_hooks # :nodoc:
1202
- _run_hooks self.class.teardown_hooks.reverse
1203
- end
1204
1221
  end
1205
1222
  end
1206
1223
 
@@ -1213,6 +1230,7 @@ module MiniTest
1213
1230
  class TestCase
1214
1231
  include LifecycleHooks
1215
1232
  include Deprecated::Hooks
1233
+ extend Deprecated::HooksCM # UGH... I can't wait 'til 2013!
1216
1234
  include Guard
1217
1235
  extend Guard
1218
1236
 
@@ -15,6 +15,23 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
15
15
  "#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
16
16
  "#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
17
17
 
18
+ def test_wtf
19
+ $hook_value = nil
20
+
21
+ capture_io do # don't care about deprecation
22
+ MiniTest::Unit::TestCase.add_setup_hook do
23
+ $hook_value = 42
24
+ end
25
+ end
26
+
27
+ run_setup_hooks
28
+
29
+ assert_equal 42, $hook_value
30
+ assert_equal [Proc], MiniTest::Unit::TestCase.setup_hooks.map(&:class)
31
+ MiniTest::Unit::TestCase.reset_setup_teardown_hooks
32
+ assert_equal [], MiniTest::Unit::TestCase.setup_hooks.map(&:class)
33
+ end
34
+
18
35
  def test_class_puke_with_assertion_failed
19
36
  exception = MiniTest::Assertion.new "Oh no!"
20
37
  exception.set_backtrace ["unhappy"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 4.0.0
10
+ version: 4.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2012-09-29 00:00:00 Z
39
+ date: 2012-10-05 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
metadata.gz.sig CHANGED
Binary file