minitest 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/History.txt +16 -0
- data/README.txt +58 -6
- data/lib/minitest/benchmark.rb +10 -4
- data/lib/minitest/spec.rb +74 -17
- data/lib/minitest/unit.rb +43 -17
- data/test/test_minitest_benchmark.rb +16 -1
- data/test/test_minitest_spec.rb +85 -6
- data/test/test_minitest_unit.rb +58 -5
- metadata +20 -10
- metadata.gz.sig +2 -3
data.tar.gz.sig
CHANGED
Binary file
|
data/.gemtest
ADDED
File without changes
|
data/History.txt
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 2.1.0 / 2011-04-11
|
2
|
+
|
3
|
+
* 5 minor enhancements:
|
4
|
+
|
5
|
+
* Added MiniTest::Spec.register_spec_type(matcher, klass) and spec_type(desc)
|
6
|
+
* Added ability for specs to share code via subclassing of Spec. (metaskills)
|
7
|
+
* Clarified (or tried to) bench_performance_linear's use of threshold.
|
8
|
+
* MiniTest::Unit.runner=(runner) provides an easy way of creating custom test runners for specialized needs. (justinweiss)
|
9
|
+
* Reverse order of inheritance in teardowns of specs. (deepfryed)
|
10
|
+
|
11
|
+
* 3 bug fixes:
|
12
|
+
|
13
|
+
* FINALLY fixed problems of inheriting specs in describe/it/describe scenario. (MGPalmer)
|
14
|
+
* Fixed a new warning in 1.9.3.
|
15
|
+
* Fixed assert_block's message handling. (nobu)
|
16
|
+
|
1
17
|
=== 2.0.2 / 2010-12-24
|
2
18
|
|
3
19
|
* 1 minor enhancement:
|
data/README.txt
CHANGED
@@ -54,7 +54,7 @@ Given that you'd like to test the following class:
|
|
54
54
|
"OHAI!"
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def will_it_blend?
|
58
58
|
"YES!"
|
59
59
|
end
|
60
60
|
end
|
@@ -72,8 +72,8 @@ Given that you'd like to test the following class:
|
|
72
72
|
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
76
|
-
refute_match /^no/i, @meme.
|
75
|
+
def test_that_it_will_not_blend
|
76
|
+
refute_match /^no/i, @meme.will_it_blend?
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -94,7 +94,7 @@ Given that you'd like to test the following class:
|
|
94
94
|
|
95
95
|
describe "when asked about blending possibilities" do
|
96
96
|
it "won't say no" do
|
97
|
-
@meme.
|
97
|
+
@meme.will_it_blend?.wont_match /^no/i
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -166,14 +166,66 @@ Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
166
166
|
describe "#ask" do
|
167
167
|
describe "when passed an unpunctuated question" do
|
168
168
|
it "should invoke the appropriate predicate method on the meme" do
|
169
|
-
@meme.expect :
|
170
|
-
@meme_asker.ask "
|
169
|
+
@meme.expect :will_it_blend?, :return_value
|
170
|
+
@meme_asker.ask "will it blend"
|
171
171
|
@meme.verify
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
+
=== Customizable Test Runner Types:
|
178
|
+
|
179
|
+
MiniTest::Unit.runner=(runner) provides an easy way of creating custom
|
180
|
+
test runners for specialized needs. Justin Weiss provides the
|
181
|
+
following real-world example to create an alternative to regular
|
182
|
+
fixture loading:
|
183
|
+
|
184
|
+
class MiniTestWithHooks::Unit < MiniTest::Unit
|
185
|
+
def before_suites
|
186
|
+
end
|
187
|
+
|
188
|
+
def after_suites
|
189
|
+
end
|
190
|
+
|
191
|
+
def _run_suites(suites, type)
|
192
|
+
begin
|
193
|
+
before_suites
|
194
|
+
super(suites, type)
|
195
|
+
ensure
|
196
|
+
after_suites
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def _run_suite(suite, type)
|
201
|
+
begin
|
202
|
+
suite.before_suite
|
203
|
+
super(suite, type)
|
204
|
+
ensure
|
205
|
+
suite.after_suite
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
module MiniTestWithTransactions
|
211
|
+
class Unit < MiniTestWithHooks::Unit
|
212
|
+
include TestSetupHelper
|
213
|
+
|
214
|
+
def before_suites
|
215
|
+
super
|
216
|
+
setup_nested_transactions
|
217
|
+
# load any data we want available for all tests
|
218
|
+
end
|
219
|
+
|
220
|
+
def after_suites
|
221
|
+
teardown_nested_transactions
|
222
|
+
super
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
MiniTest::Unit.runner = MiniTestWithTransactions::Unit.new
|
228
|
+
|
177
229
|
== REQUIREMENTS:
|
178
230
|
|
179
231
|
* Ruby 1.8, maybe even 1.6 or lower. No magic is involved.
|
data/lib/minitest/benchmark.rb
CHANGED
@@ -105,10 +105,16 @@ class MiniTest::Unit
|
|
105
105
|
|
106
106
|
##
|
107
107
|
# Runs the given +work+ and asserts that the times gathered fit to
|
108
|
-
# match a constant rate (eg, linear slope == 0) within a given
|
109
|
-
# +threshold+.
|
108
|
+
# match a constant rate (eg, linear slope == 0) within a given
|
109
|
+
# +threshold+. Note: because we're testing for a slope of 0, R^2
|
110
|
+
# is not a good determining factor for the fit, so the threshold
|
111
|
+
# is applied against the slope itself. As such, you probably want
|
112
|
+
# to tighten it from the default.
|
110
113
|
#
|
111
|
-
#
|
114
|
+
# See http://www.graphpad.com/curvefit/goodness_of_fit.htm for
|
115
|
+
# more details.
|
116
|
+
#
|
117
|
+
# Fit is calculated by #fit_linear.
|
112
118
|
#
|
113
119
|
# Ranges are specified by ::bench_range.
|
114
120
|
#
|
@@ -322,7 +328,7 @@ class MiniTest::Spec
|
|
322
328
|
# end
|
323
329
|
# end
|
324
330
|
|
325
|
-
def self.bench_performance_linear name, threshold = 0.
|
331
|
+
def self.bench_performance_linear name, threshold = 0.99, &work
|
326
332
|
bench name do
|
327
333
|
assert_performance_linear threshold, &work
|
328
334
|
end
|
data/lib/minitest/spec.rb
CHANGED
@@ -55,17 +55,41 @@ module Kernel
|
|
55
55
|
#
|
56
56
|
# TODO: find good tutorial url.
|
57
57
|
#
|
58
|
-
# Defines a test class subclassing from either
|
59
|
-
#
|
60
|
-
|
61
|
-
|
58
|
+
# Defines a test class subclassing from either MiniTest::Spec or
|
59
|
+
# from the surrounding describe's class. The surrounding class may
|
60
|
+
# subclass MiniTest::Spec manually in order to easily share code:
|
61
|
+
#
|
62
|
+
# class MySpec < MiniTest::Spec
|
63
|
+
# # ... shared code ...
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# class TestStuff < MySpec
|
67
|
+
# it "does stuff" do
|
68
|
+
# # shared code available here
|
69
|
+
# end
|
70
|
+
# describe "inner stuff" do
|
71
|
+
# it "still does stuff" do
|
72
|
+
# # ...and here
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
|
77
|
+
def describe desc, &block # :doc:
|
62
78
|
stack = MiniTest::Spec.describe_stack
|
63
79
|
name = [stack.last, desc].compact.join("::")
|
64
|
-
|
80
|
+
sclas = stack.last || if Class === self && self < MiniTest::Spec then
|
81
|
+
self
|
82
|
+
else
|
83
|
+
MiniTest::Spec.spec_type desc
|
84
|
+
end
|
85
|
+
cls = Class.new sclas
|
86
|
+
|
87
|
+
sclas.children << cls unless cls == MiniTest::Spec
|
65
88
|
|
66
89
|
# :stopdoc:
|
67
90
|
# omg this sucks
|
68
91
|
(class << cls; self; end).send(:define_method, :to_s) { name }
|
92
|
+
(class << cls; self; end).send(:define_method, :desc) { desc }
|
69
93
|
# :startdoc:
|
70
94
|
|
71
95
|
cls.nuke_test_methods!
|
@@ -78,21 +102,40 @@ module Kernel
|
|
78
102
|
private :describe
|
79
103
|
end
|
80
104
|
|
81
|
-
class Module
|
82
|
-
def classes type = Object # :nodoc:
|
83
|
-
constants.map { |n| const_get n }.find_all { |c|
|
84
|
-
c.class == Class and type > c
|
85
|
-
} - [self]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
105
|
##
|
90
106
|
# MiniTest::Spec -- The faster, better, less-magical spec framework!
|
91
107
|
#
|
92
108
|
# For a list of expectations, see Object.
|
93
109
|
|
94
|
-
|
95
110
|
class MiniTest::Spec < MiniTest::Unit::TestCase
|
111
|
+
##
|
112
|
+
# Contains pairs of matchers and Spec classes to be used to
|
113
|
+
# calculate the superclass of a top-level describe. This allows for
|
114
|
+
# automatically customizable spec types.
|
115
|
+
#
|
116
|
+
# See: register_spec_type and spec_type
|
117
|
+
|
118
|
+
TYPES = [[//, MiniTest::Spec]]
|
119
|
+
|
120
|
+
##
|
121
|
+
# Register a new type of spec that matches the spec's description. Eg:
|
122
|
+
#
|
123
|
+
# register_spec_plugin(/Controller$/, MiniTest::Spec::Rails)
|
124
|
+
|
125
|
+
def self.register_spec_type matcher, klass
|
126
|
+
TYPES.unshift [matcher, klass]
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Figure out the spec class to use based on a spec's description. Eg:
|
131
|
+
#
|
132
|
+
# spec_type("BlahController") # => MiniTest::Spec::Rails
|
133
|
+
|
134
|
+
def self.spec_type desc
|
135
|
+
desc = desc.to_s
|
136
|
+
TYPES.find { |re, klass| re === desc }.last
|
137
|
+
end
|
138
|
+
|
96
139
|
@@describe_stack = []
|
97
140
|
def self.describe_stack # :nodoc:
|
98
141
|
@@describe_stack
|
@@ -102,6 +145,10 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
102
145
|
@@current_spec
|
103
146
|
end
|
104
147
|
|
148
|
+
def self.children
|
149
|
+
@children ||= []
|
150
|
+
end
|
151
|
+
|
105
152
|
def initialize name # :nodoc:
|
106
153
|
super
|
107
154
|
@@current_spec = self
|
@@ -113,12 +160,22 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
113
160
|
end
|
114
161
|
end
|
115
162
|
|
163
|
+
##
|
164
|
+
# Spec users want setup/teardown to be inherited and NOTHING ELSE.
|
165
|
+
# It is almost like method reuse is lost on them.
|
166
|
+
|
116
167
|
def self.define_inheritable_method name, &block # :nodoc:
|
168
|
+
# regular super() warns
|
117
169
|
super_method = self.superclass.instance_method name
|
118
170
|
|
171
|
+
teardown = name.to_s == "teardown"
|
172
|
+
super_before = super_method && ! teardown
|
173
|
+
super_after = super_method && teardown
|
174
|
+
|
119
175
|
define_method name do
|
120
|
-
super_method.bind(self).call if
|
176
|
+
super_method.bind(self).call if super_before
|
121
177
|
instance_eval(&block)
|
178
|
+
super_method.bind(self).call if super_after
|
122
179
|
end
|
123
180
|
end
|
124
181
|
|
@@ -165,8 +222,8 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
165
222
|
|
166
223
|
define_method name, &block
|
167
224
|
|
168
|
-
|
169
|
-
mod.send :undef_method, name if mod.
|
225
|
+
self.children.each do |mod|
|
226
|
+
mod.send :undef_method, name if mod.public_method_defined? name
|
170
227
|
end
|
171
228
|
end
|
172
229
|
end
|
data/lib/minitest/unit.rb
CHANGED
@@ -94,7 +94,8 @@ module MiniTest
|
|
94
94
|
# Fails unless the block returns a true value.
|
95
95
|
|
96
96
|
def assert_block msg = nil
|
97
|
-
|
97
|
+
msg = message(msg) { "Expected block to return true value" }
|
98
|
+
assert yield, msg
|
98
99
|
end
|
99
100
|
|
100
101
|
##
|
@@ -174,7 +175,7 @@ module MiniTest
|
|
174
175
|
def assert_match exp, act, msg = nil
|
175
176
|
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
|
176
177
|
assert_respond_to act, :"=~"
|
177
|
-
exp =
|
178
|
+
exp = Regexp.new Regexp.escape exp if String === exp and String === act
|
178
179
|
assert exp =~ act, msg
|
179
180
|
end
|
180
181
|
|
@@ -218,8 +219,8 @@ module MiniTest
|
|
218
219
|
# Fails unless the block raises one of +exp+
|
219
220
|
|
220
221
|
def assert_raises *exp
|
221
|
-
msg = String === exp.last
|
222
|
-
|
222
|
+
msg = "#{exp.pop}\n" if String === exp.last
|
223
|
+
|
223
224
|
should_raise = false
|
224
225
|
begin
|
225
226
|
yield
|
@@ -339,7 +340,14 @@ module MiniTest
|
|
339
340
|
# Returns details for exception +e+
|
340
341
|
|
341
342
|
def exception_details e, msg
|
342
|
-
|
343
|
+
[
|
344
|
+
"#{msg}",
|
345
|
+
"Class: <#{e.class}>",
|
346
|
+
"Message: <#{e.message.inspect}>",
|
347
|
+
"---Backtrace---",
|
348
|
+
"#{MiniTest::filter_backtrace(e.backtrace).join("\n")}",
|
349
|
+
"---------------",
|
350
|
+
].join "\n"
|
343
351
|
end
|
344
352
|
|
345
353
|
##
|
@@ -355,14 +363,8 @@ module MiniTest
|
|
355
363
|
|
356
364
|
def message msg = nil, &default
|
357
365
|
proc {
|
358
|
-
|
359
|
-
|
360
|
-
msg += '.' unless msg.empty?
|
361
|
-
msg += "\n#{default.call}."
|
362
|
-
msg.strip
|
363
|
-
else
|
364
|
-
"#{default.call}."
|
365
|
-
end
|
366
|
+
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
|
367
|
+
"#{custom_message}#{default.call}."
|
366
368
|
}
|
367
369
|
end
|
368
370
|
|
@@ -514,7 +516,7 @@ module MiniTest
|
|
514
516
|
end
|
515
517
|
|
516
518
|
class Unit
|
517
|
-
VERSION = "2.0
|
519
|
+
VERSION = "2.1.0" # :nodoc:
|
518
520
|
|
519
521
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
520
522
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -585,6 +587,23 @@ module MiniTest
|
|
585
587
|
@@out = stream
|
586
588
|
end
|
587
589
|
|
590
|
+
##
|
591
|
+
# Tells MiniTest::Unit to delegate to +runner+, an instance of a
|
592
|
+
# MiniTest::Unit subclass, when MiniTest::Unit#run is called.
|
593
|
+
|
594
|
+
def self.runner= runner
|
595
|
+
@@runner = runner
|
596
|
+
end
|
597
|
+
|
598
|
+
##
|
599
|
+
# Returns the MiniTest::Unit subclass instance that will be used
|
600
|
+
# to run the tests. A MiniTest::Unit instance is the default
|
601
|
+
# runner.
|
602
|
+
|
603
|
+
def self.runner
|
604
|
+
@@runner ||= self.new
|
605
|
+
end
|
606
|
+
|
588
607
|
##
|
589
608
|
# Return all plugins' run methods (methods that start with "run_").
|
590
609
|
|
@@ -622,8 +641,8 @@ module MiniTest
|
|
622
641
|
|
623
642
|
results = _run_suites suites, type
|
624
643
|
|
625
|
-
@test_count = results.inject(0) { |sum, (tc,
|
626
|
-
@assertion_count = results.inject(0) { |sum, (
|
644
|
+
@test_count = results.inject(0) { |sum, (tc, _)| sum + tc }
|
645
|
+
@assertion_count = results.inject(0) { |sum, (_, ac)| sum + ac }
|
627
646
|
|
628
647
|
output.sync = old_sync if sync
|
629
648
|
|
@@ -754,9 +773,16 @@ module MiniTest
|
|
754
773
|
end
|
755
774
|
|
756
775
|
##
|
757
|
-
#
|
776
|
+
# Begins the full test run. Delegates to +runner+'s #_run method.
|
758
777
|
|
759
778
|
def run args = []
|
779
|
+
self.class.runner._run(args)
|
780
|
+
end
|
781
|
+
|
782
|
+
##
|
783
|
+
# Top level driver, controls all output and filtering.
|
784
|
+
|
785
|
+
def _run args = []
|
760
786
|
self.options = process_args args
|
761
787
|
|
762
788
|
puts "Run options: #{help}"
|
@@ -44,6 +44,21 @@ class TestMiniTestBenchmark < MiniTest::Unit::TestCase
|
|
44
44
|
assert_fit :exponential, x, y, 0.95, 13.81148, -0.1820
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_fit_constant_clean
|
48
|
+
x = (1..5).to_a
|
49
|
+
y = [5.0, 5.0, 5.0, 5.0, 5.0]
|
50
|
+
|
51
|
+
assert_fit :linear, x, y, nil, 5.0, 0
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_fit_constant_noisy
|
55
|
+
x = (1..5).to_a
|
56
|
+
y = [1.0, 1.2, 1.0, 0.8, 1.0]
|
57
|
+
|
58
|
+
# verified in numbers and R
|
59
|
+
assert_fit :linear, x, y, nil, 1.12, -0.04
|
60
|
+
end
|
61
|
+
|
47
62
|
def test_fit_linear_clean
|
48
63
|
# y = m * x + b where m = 2.2, b = 3.1
|
49
64
|
x = (1..5).to_a
|
@@ -90,7 +105,7 @@ class TestMiniTestBenchmark < MiniTest::Unit::TestCase
|
|
90
105
|
def assert_fit msg, x, y, fit, exp_a, exp_b
|
91
106
|
a, b, rr = send "fit_#{msg}", x, y
|
92
107
|
|
93
|
-
assert_operator rr, :>=, fit
|
108
|
+
assert_operator rr, :>=, fit if fit
|
94
109
|
assert_in_delta exp_a, a
|
95
110
|
assert_in_delta exp_b, b
|
96
111
|
end
|
data/test/test_minitest_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'minitest/spec'
|
2
|
+
require 'stringio'
|
2
3
|
|
3
4
|
MiniTest::Unit.autorun
|
4
5
|
|
@@ -196,34 +197,112 @@ describe MiniTest::Spec do
|
|
196
197
|
end
|
197
198
|
|
198
199
|
class TestMeta < MiniTest::Unit::TestCase
|
199
|
-
def
|
200
|
+
def test_setup
|
201
|
+
srand 42
|
202
|
+
MiniTest::Unit::TestCase.reset
|
203
|
+
end
|
204
|
+
|
205
|
+
def util_structure
|
200
206
|
x = y = z = nil
|
207
|
+
before_list = []
|
208
|
+
after_list = []
|
201
209
|
x = describe "top-level thingy" do
|
202
|
-
before {}
|
203
|
-
after {}
|
210
|
+
before { before_list << 1 }
|
211
|
+
after { after_list << 1 }
|
204
212
|
|
205
213
|
it "top-level-it" do end
|
206
214
|
|
207
215
|
y = describe "inner thingy" do
|
208
|
-
before {}
|
216
|
+
before { before_list << 2 }
|
217
|
+
after { after_list << 2 }
|
209
218
|
it "inner-it" do end
|
210
219
|
|
211
220
|
z = describe "very inner thingy" do
|
212
|
-
before {}
|
221
|
+
before { before_list << 3 }
|
222
|
+
after { after_list << 3 }
|
213
223
|
it "inner-it" do end
|
214
224
|
end
|
215
225
|
end
|
216
226
|
end
|
217
227
|
|
228
|
+
return x, y, z, before_list, after_list
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_structure
|
232
|
+
x, y, z, * = util_structure
|
233
|
+
|
218
234
|
assert_equal "top-level thingy", x.to_s
|
219
235
|
assert_equal "top-level thingy::inner thingy", y.to_s
|
220
236
|
assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s
|
221
237
|
|
238
|
+
assert_equal "top-level thingy", x.desc
|
239
|
+
assert_equal "inner thingy", y.desc
|
240
|
+
assert_equal "very inner thingy", z.desc
|
241
|
+
|
222
242
|
top_methods = %w(setup teardown test_0001_top_level_it)
|
223
|
-
inner_methods = %w(setup test_0001_inner_it)
|
243
|
+
inner_methods = %w(setup teardown test_0001_inner_it)
|
224
244
|
|
225
245
|
assert_equal top_methods, x.instance_methods(false).sort.map {|o| o.to_s }
|
226
246
|
assert_equal inner_methods, y.instance_methods(false).sort.map {|o| o.to_s }
|
227
247
|
assert_equal inner_methods, z.instance_methods(false).sort.map {|o| o.to_s }
|
228
248
|
end
|
249
|
+
|
250
|
+
def test_setup_teardown_behavior
|
251
|
+
_, _, z, before_list, after_list = util_structure
|
252
|
+
|
253
|
+
tc = z.new(nil)
|
254
|
+
tc.setup
|
255
|
+
tc.teardown
|
256
|
+
|
257
|
+
assert_equal [1, 2, 3], before_list
|
258
|
+
assert_equal [3, 2, 1], after_list
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_children
|
262
|
+
MiniTest::Spec.children.clear
|
263
|
+
|
264
|
+
x = y = z = nil
|
265
|
+
x = describe "top-level thingy" do
|
266
|
+
y = describe "first thingy" do end
|
267
|
+
|
268
|
+
it "top-level-it" do end
|
269
|
+
|
270
|
+
z = describe "second thingy" do end
|
271
|
+
end
|
272
|
+
|
273
|
+
assert_equal [x], MiniTest::Spec.children
|
274
|
+
assert_equal [y, z], x.children
|
275
|
+
assert_equal [], y.children
|
276
|
+
assert_equal [], z.children
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_describe_first_structure
|
280
|
+
x = y = z = nil
|
281
|
+
x = describe "top-level thingy" do
|
282
|
+
y = describe "first thingy" do end
|
283
|
+
|
284
|
+
it "top-level-it" do end
|
285
|
+
|
286
|
+
z = describe "second thingy" do end
|
287
|
+
end
|
288
|
+
|
289
|
+
assert_equal ['test_0001_top_level_it'],
|
290
|
+
x.instance_methods.grep(/^test/).map {|o| o.to_s}
|
291
|
+
assert_equal [], y.instance_methods.grep(/^test/)
|
292
|
+
assert_equal [], z.instance_methods.grep(/^test/)
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_structure_subclasses
|
296
|
+
z = nil
|
297
|
+
x = Class.new MiniTest::Spec do
|
298
|
+
def xyz; end
|
299
|
+
end
|
300
|
+
y = Class.new x do
|
301
|
+
z = describe("inner") {}
|
302
|
+
end
|
303
|
+
|
304
|
+
assert_respond_to x.new(nil), "xyz"
|
305
|
+
assert_respond_to y.new(nil), "xyz"
|
306
|
+
assert_respond_to z.new(nil), "xyz"
|
307
|
+
end
|
229
308
|
end
|
data/test/test_minitest_unit.rb
CHANGED
@@ -45,6 +45,7 @@ Finished tests in 0.00
|
|
45
45
|
|
46
46
|
def teardown
|
47
47
|
MiniTest::Unit.output = $stdout
|
48
|
+
MiniTest::Unit.runner = nil
|
48
49
|
Object.send :remove_const, :ATestCase if defined? ATestCase
|
49
50
|
end
|
50
51
|
|
@@ -248,7 +249,7 @@ RuntimeError: unhandled exception
|
|
248
249
|
assert_report expected
|
249
250
|
end
|
250
251
|
|
251
|
-
def test_run_failing
|
252
|
+
def test_run_failing
|
252
253
|
tc = Class.new(MiniTest::Unit::TestCase) do
|
253
254
|
def test_something
|
254
255
|
assert true
|
@@ -354,6 +355,57 @@ not yet
|
|
354
355
|
assert_report expected
|
355
356
|
end
|
356
357
|
|
358
|
+
def test_default_runner_is_minitest_unit
|
359
|
+
assert_instance_of MiniTest::Unit, MiniTest::Unit.runner
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_run_with_other_runner
|
363
|
+
|
364
|
+
runner = Class.new(MiniTest::Unit) do
|
365
|
+
# Run once before each suite
|
366
|
+
def _run_suite(suite, type)
|
367
|
+
begin
|
368
|
+
suite.before_suite
|
369
|
+
super(suite, type)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
tc = Class.new(MiniTest::Unit::TestCase) do
|
375
|
+
|
376
|
+
def self.before_suite
|
377
|
+
MiniTest::Unit.output.puts "Running #{self.name} tests"
|
378
|
+
@@foo = 1
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_something
|
382
|
+
assert_equal 1, @@foo
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_something_else
|
386
|
+
assert_equal 1, @@foo
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
Object.const_set(:ATestCase, tc)
|
391
|
+
MiniTest::Unit.runner = runner.new
|
392
|
+
@tu.run %w[--seed 42]
|
393
|
+
|
394
|
+
# We should only see 'running ATestCase tests' once
|
395
|
+
expected = "Run options: --seed 42
|
396
|
+
|
397
|
+
# Running tests:
|
398
|
+
|
399
|
+
Running ATestCase tests
|
400
|
+
..
|
401
|
+
|
402
|
+
Finished tests in 0.00
|
403
|
+
|
404
|
+
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
|
405
|
+
"
|
406
|
+
assert_report expected
|
407
|
+
end
|
408
|
+
|
357
409
|
def util_expand_bt bt
|
358
410
|
if RUBY_VERSION =~ /^1\.9/ then
|
359
411
|
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
@@ -403,8 +455,8 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
403
455
|
end
|
404
456
|
|
405
457
|
def test_assert_block_triggered
|
406
|
-
util_assert_triggered
|
407
|
-
@tc.assert_block do
|
458
|
+
util_assert_triggered "blah.\nExpected block to return true value." do
|
459
|
+
@tc.assert_block "blah" do
|
408
460
|
false
|
409
461
|
end
|
410
462
|
end
|
@@ -883,8 +935,9 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
883
935
|
def test_message
|
884
936
|
@assertion_count = 0
|
885
937
|
|
886
|
-
assert_equal "blah2.", @tc.message
|
887
|
-
assert_equal "blah2.", @tc.message("")
|
938
|
+
assert_equal "blah2.", @tc.message { "blah2" }.call
|
939
|
+
assert_equal "blah2.", @tc.message("") { "blah2" }.call
|
940
|
+
assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
|
888
941
|
assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
|
889
942
|
end
|
890
943
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 2
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 2.0.2
|
10
|
+
version: 2.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ryan Davis
|
@@ -35,35 +36,39 @@ cert_chain:
|
|
35
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
36
37
|
-----END CERTIFICATE-----
|
37
38
|
|
38
|
-
date:
|
39
|
+
date: 2011-04-11 00:00:00 -07:00
|
39
40
|
default_executable:
|
40
41
|
dependencies:
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: minitest
|
43
44
|
prerelease: false
|
44
45
|
requirement: &id001 !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
45
47
|
requirements:
|
46
48
|
- - ">="
|
47
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 11
|
48
51
|
segments:
|
49
52
|
- 2
|
50
53
|
- 0
|
51
|
-
-
|
52
|
-
version: 2.0.
|
54
|
+
- 2
|
55
|
+
version: 2.0.2
|
53
56
|
type: :development
|
54
57
|
version_requirements: *id001
|
55
58
|
- !ruby/object:Gem::Dependency
|
56
59
|
name: hoe
|
57
60
|
prerelease: false
|
58
61
|
requirement: &id002 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
59
63
|
requirements:
|
60
64
|
- - ">="
|
61
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 41
|
62
67
|
segments:
|
63
68
|
- 2
|
64
|
-
-
|
65
|
-
-
|
66
|
-
version: 2.
|
69
|
+
- 9
|
70
|
+
- 1
|
71
|
+
version: 2.9.1
|
67
72
|
type: :development
|
68
73
|
version_requirements: *id002
|
69
74
|
description: |-
|
@@ -120,6 +125,7 @@ files:
|
|
120
125
|
- test/test_minitest_mock.rb
|
121
126
|
- test/test_minitest_spec.rb
|
122
127
|
- test/test_minitest_unit.rb
|
128
|
+
- .gemtest
|
123
129
|
has_rdoc: true
|
124
130
|
homepage: http://rubyforge.org/projects/bfts
|
125
131
|
licenses: []
|
@@ -131,23 +137,27 @@ rdoc_options:
|
|
131
137
|
require_paths:
|
132
138
|
- lib
|
133
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
134
141
|
requirements:
|
135
142
|
- - ">="
|
136
143
|
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
137
145
|
segments:
|
138
146
|
- 0
|
139
147
|
version: "0"
|
140
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
141
150
|
requirements:
|
142
151
|
- - ">="
|
143
152
|
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
144
154
|
segments:
|
145
155
|
- 0
|
146
156
|
version: "0"
|
147
157
|
requirements: []
|
148
158
|
|
149
159
|
rubyforge_project: bfts
|
150
|
-
rubygems_version: 1.
|
160
|
+
rubygems_version: 1.6.2
|
151
161
|
signing_key:
|
152
162
|
specification_version: 3
|
153
163
|
summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
6#�ĥ�O��*�{RG ���@x�.�{ej2���x����v�nXHc,�F�c
|
1
|
+
�Q1�rZ��+C��Lu��;5M=Ŏ�$<��3�ۈq��F��$^���p���~��m�<o�ź�~ʽ�@Ñ,=��lu�@Q!�lO-�@�դ�Jw�h��^��m�YeJ1��O��9�kv��=�0��
|
2
|
+
�/��G��ypgf�'v+:�_����X�v߅_~0c��;V�.��/��n�f%^�Ԏ�-�EzS~�z'#��>�}�j֣h��bk_����tv'�r���y�0�}�h��<'
|