minitest 4.6.2 → 4.7.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/History.txt +10 -0
- data/README.txt +50 -50
- data/lib/minitest/spec.rb +143 -132
- data/lib/minitest/unit.rb +2 -15
- data/test/minitest/test_minitest_spec.rb +25 -1
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 4.7.0 / 2013-03-18
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
|
5
|
+
* Refactored MiniTest::Spec into MiniTest::Spec::DSL.
|
6
|
+
|
7
|
+
* 1 bug fix:
|
8
|
+
|
9
|
+
* Removed $DEBUG handler that detected when test/unit and minitest were both loaded. (tenderlove)
|
10
|
+
|
1
11
|
=== 4.6.2 / 2013-02-27
|
2
12
|
|
3
13
|
* 1 minor enhancement:
|
data/README.txt
CHANGED
@@ -104,7 +104,7 @@ Given that you'd like to test the following class:
|
|
104
104
|
def test_that_it_will_not_blend
|
105
105
|
refute_match /^no/i, @meme.will_it_blend?
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def test_that_will_be_skipped
|
109
109
|
skip "test this later"
|
110
110
|
end
|
@@ -283,55 +283,55 @@ fixture loading:
|
|
283
283
|
|
284
284
|
== Known Extensions:
|
285
285
|
|
286
|
-
capybara_minitest_spec
|
287
|
-
minispec-metadata
|
288
|
-
|
289
|
-
minitest-ansi
|
290
|
-
minitest-around
|
291
|
-
minitest-capistrano
|
292
|
-
minitest-capybara
|
293
|
-
minitest-chef-handler
|
294
|
-
minitest-ci
|
295
|
-
minitest-colorize
|
296
|
-
minitest-context
|
297
|
-
|
298
|
-
minitest-debugger
|
299
|
-
|
300
|
-
minitest-display
|
301
|
-
minitest-emoji
|
302
|
-
minitest-excludes
|
303
|
-
|
304
|
-
minitest-firemock
|
286
|
+
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content('Title')).
|
287
|
+
minispec-metadata :: Metadata for describe/it blocks
|
288
|
+
(e.g. `it 'requires JS driver', js: true do`)
|
289
|
+
minitest-ansi :: Colorize minitest output with ANSI colors.
|
290
|
+
minitest-around :: Around block for minitest. An alternative to setup/teardown dance.
|
291
|
+
minitest-capistrano :: Assertions and expectations for testing Capistrano recipes
|
292
|
+
minitest-capybara :: Capybara matchers support for minitest unit and spec
|
293
|
+
minitest-chef-handler :: Run Minitest suites as Chef report handlers
|
294
|
+
minitest-ci :: CI reporter plugin for MiniTest.
|
295
|
+
minitest-colorize :: Colorize MiniTest output and show failing tests instantly.
|
296
|
+
minitest-context :: Defines contexts for code reuse in MiniTest
|
297
|
+
specs that share common expectations.
|
298
|
+
minitest-debugger :: Wraps assert so failed assertions drop into
|
299
|
+
the ruby debugger.
|
300
|
+
minitest-display :: Patches MiniTest to allow for an easily configurable output.
|
301
|
+
minitest-emoji :: Print out emoji for your test passes, fails, and skips.
|
302
|
+
minitest-excludes :: Clean API for excluding certain tests you
|
303
|
+
don't want to run under certain conditions.
|
304
|
+
minitest-firemock :: Makes your MiniTest mocks more resilient.
|
305
305
|
minitest-great_expectations :: Generally useful additions to minitest's assertions and expectations
|
306
|
-
minitest-growl
|
307
|
-
minitest-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
minitest-
|
313
|
-
minitest-
|
314
|
-
minitest-
|
315
|
-
minitest-
|
316
|
-
minitest-
|
317
|
-
minitest-
|
318
|
-
minitest-
|
319
|
-
minitest-
|
320
|
-
minitest-rails
|
321
|
-
minitest-
|
322
|
-
minitest-
|
323
|
-
minitest-should_syntax
|
324
|
-
minitest-shouldify
|
325
|
-
minitest-spec-magic
|
326
|
-
minitest-spec-rails
|
327
|
-
minitest-stub-const
|
328
|
-
minitest-tags
|
329
|
-
minitest-wscolor
|
330
|
-
minitest_owrapper
|
331
|
-
minitest_should
|
332
|
-
minitest_tu_shim
|
333
|
-
mongoid-minitest
|
334
|
-
pry-rescue
|
306
|
+
minitest-growl :: Test notifier for minitest via growl.
|
307
|
+
minitest-implicit-subject :: Implicit declaration of the test subject.
|
308
|
+
minitest-instrument :: Instrument ActiveSupport::Notifications when
|
309
|
+
test method is executed
|
310
|
+
minitest-instrument-db :: Store information about speed of test
|
311
|
+
execution provided by minitest-instrument in database
|
312
|
+
minitest-libnotify :: Test notifier for minitest via libnotify.
|
313
|
+
minitest-macruby :: Provides extensions to minitest for macruby UI testing.
|
314
|
+
minitest-matchers :: Adds support for RSpec-style matchers to minitest.
|
315
|
+
minitest-metadata :: Annotate tests with metadata (key-value).
|
316
|
+
minitest-mongoid :: Mongoid assertion matchers for MiniTest
|
317
|
+
minitest-must_not :: Provides must_not as an alias for wont in MiniTest
|
318
|
+
minitest-nc :: Test notifier for minitest via Mountain Lion's Notification Center
|
319
|
+
minitest-predicates :: Adds support for .predicate? methods
|
320
|
+
minitest-rails :: MiniTest integration for Rails 3.x
|
321
|
+
minitest-rails-capybara :: Capybara integration for MiniTest::Rails
|
322
|
+
minitest-reporters :: Create customizable MiniTest output formats
|
323
|
+
minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
|
324
|
+
minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
|
325
|
+
minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
|
326
|
+
minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
|
327
|
+
minitest-stub-const :: Stub constants for the duration of a block
|
328
|
+
minitest-tags :: add tags for minitest
|
329
|
+
minitest-wscolor :: Yet another test colorizer.
|
330
|
+
minitest_owrapper :: Get tests results as a TestResult object.
|
331
|
+
minitest_should :: Shoulda style syntax for minitest test::unit.
|
332
|
+
minitest_tu_shim :: minitest_tu_shim bridges between test/unit and minitest.
|
333
|
+
mongoid-minitest :: MiniTest matchers for Mongoid.
|
334
|
+
pry-rescue :: A pry plugin w/ minitest support. See pry-rescue/minitest.rb.
|
335
335
|
|
336
336
|
== Unknown Extensions:
|
337
337
|
|
@@ -372,7 +372,7 @@ the gem, but you'll need to activate the gem explicitly to use it:
|
|
372
372
|
require 'rubygems'
|
373
373
|
gem 'minitest' # ensures you're using the gem, and not the built in MT
|
374
374
|
require 'minitest/autorun'
|
375
|
-
|
375
|
+
|
376
376
|
# ... usual testing stuffs ...
|
377
377
|
|
378
378
|
DO NOTE: There is a serious problem with the way that ruby 1.9/2.0
|
data/lib/minitest/spec.rb
CHANGED
@@ -59,7 +59,7 @@ module Kernel # :nodoc:
|
|
59
59
|
def describe desc, additional_desc = nil, &block # :doc:
|
60
60
|
stack = MiniTest::Spec.describe_stack
|
61
61
|
name = [stack.last, desc, additional_desc].compact.join("::")
|
62
|
-
sclas = stack.last || if Class === self &&
|
62
|
+
sclas = stack.last || if Class === self && is_a?(MiniTest::Spec::DSL) then
|
63
63
|
self
|
64
64
|
else
|
65
65
|
MiniTest::Spec.spec_type desc
|
@@ -81,173 +81,184 @@ end
|
|
81
81
|
# For a list of expectations, see MiniTest::Expectations.
|
82
82
|
|
83
83
|
class MiniTest::Spec < MiniTest::Unit::TestCase
|
84
|
-
##
|
85
|
-
# Contains pairs of matchers and Spec classes to be used to
|
86
|
-
# calculate the superclass of a top-level describe. This allows for
|
87
|
-
# automatically customizable spec types.
|
88
|
-
#
|
89
|
-
# See: register_spec_type and spec_type
|
90
|
-
|
91
|
-
TYPES = [[//, MiniTest::Spec]]
|
92
|
-
|
93
|
-
##
|
94
|
-
# Register a new type of spec that matches the spec's description.
|
95
|
-
# This method can take either a Regexp and a spec class or a spec
|
96
|
-
# class and a block that takes the description and returns true if
|
97
|
-
# it matches.
|
98
|
-
#
|
99
|
-
# Eg:
|
100
|
-
#
|
101
|
-
# register_spec_type(/Controller$/, MiniTest::Spec::Rails)
|
102
|
-
#
|
103
|
-
# or:
|
104
|
-
#
|
105
|
-
# register_spec_type(MiniTest::Spec::RailsModel) do |desc|
|
106
|
-
# desc.superclass == ActiveRecord::Base
|
107
|
-
# end
|
108
|
-
|
109
|
-
def self.register_spec_type(*args, &block)
|
110
|
-
if block then
|
111
|
-
matcher, klass = block, args.first
|
112
|
-
else
|
113
|
-
matcher, klass = *args
|
114
|
-
end
|
115
|
-
TYPES.unshift [matcher, klass]
|
116
|
-
end
|
117
84
|
|
118
85
|
##
|
119
|
-
#
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
86
|
+
# Oh look! A MiniTest::Spec::DSL module! Eat your heart out DHH.
|
87
|
+
|
88
|
+
module DSL
|
89
|
+
##
|
90
|
+
# Contains pairs of matchers and Spec classes to be used to
|
91
|
+
# calculate the superclass of a top-level describe. This allows for
|
92
|
+
# automatically customizable spec types.
|
93
|
+
#
|
94
|
+
# See: register_spec_type and spec_type
|
95
|
+
|
96
|
+
TYPES = [[//, MiniTest::Spec]]
|
97
|
+
|
98
|
+
##
|
99
|
+
# Register a new type of spec that matches the spec's description.
|
100
|
+
# This method can take either a Regexp and a spec class or a spec
|
101
|
+
# class and a block that takes the description and returns true if
|
102
|
+
# it matches.
|
103
|
+
#
|
104
|
+
# Eg:
|
105
|
+
#
|
106
|
+
# register_spec_type(/Controller$/, MiniTest::Spec::Rails)
|
107
|
+
#
|
108
|
+
# or:
|
109
|
+
#
|
110
|
+
# register_spec_type(MiniTest::Spec::RailsModel) do |desc|
|
111
|
+
# desc.superclass == ActiveRecord::Base
|
112
|
+
# end
|
113
|
+
|
114
|
+
def register_spec_type(*args, &block)
|
115
|
+
if block then
|
116
|
+
matcher, klass = block, args.first
|
127
117
|
else
|
128
|
-
matcher
|
118
|
+
matcher, klass = *args
|
129
119
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
@@describe_stack = []
|
134
|
-
def self.describe_stack # :nodoc:
|
135
|
-
@@describe_stack
|
136
|
-
end
|
120
|
+
TYPES.unshift [matcher, klass]
|
121
|
+
end
|
137
122
|
|
138
|
-
|
139
|
-
|
123
|
+
##
|
124
|
+
# Figure out the spec class to use based on a spec's description. Eg:
|
125
|
+
#
|
126
|
+
# spec_type("BlahController") # => MiniTest::Spec::Rails
|
140
127
|
|
141
|
-
|
142
|
-
|
143
|
-
|
128
|
+
def spec_type desc
|
129
|
+
TYPES.find { |matcher, klass|
|
130
|
+
if matcher.respond_to? :call then
|
131
|
+
matcher.call desc
|
132
|
+
else
|
133
|
+
matcher === desc.to_s
|
134
|
+
end
|
135
|
+
}.last
|
136
|
+
end
|
144
137
|
|
145
|
-
|
146
|
-
|
147
|
-
|
138
|
+
@@describe_stack = []
|
139
|
+
def describe_stack # :nodoc:
|
140
|
+
@@describe_stack
|
148
141
|
end
|
149
|
-
end
|
150
142
|
|
151
|
-
|
152
|
-
|
153
|
-
#
|
154
|
-
# NOTE: +type+ is ignored and is only there to make porting easier.
|
155
|
-
#
|
156
|
-
# Equivalent to MiniTest::Unit::TestCase#setup.
|
143
|
+
##
|
144
|
+
# Returns the children of this spec.
|
157
145
|
|
158
|
-
|
159
|
-
|
160
|
-
super()
|
161
|
-
self.instance_eval(&block)
|
146
|
+
def children
|
147
|
+
@children ||= []
|
162
148
|
end
|
163
|
-
end
|
164
149
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
# Equivalent to MiniTest::Unit::TestCase#teardown.
|
150
|
+
def nuke_test_methods! # :nodoc:
|
151
|
+
self.public_instance_methods.grep(/^test_/).each do |name|
|
152
|
+
self.send :undef_method, name
|
153
|
+
end
|
154
|
+
end
|
171
155
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
156
|
+
##
|
157
|
+
# Define a 'before' action. Inherits the way normal methods should.
|
158
|
+
#
|
159
|
+
# NOTE: +type+ is ignored and is only there to make porting easier.
|
160
|
+
#
|
161
|
+
# Equivalent to MiniTest::Unit::TestCase#setup.
|
162
|
+
|
163
|
+
def before type = nil, &block
|
164
|
+
define_method :setup do
|
165
|
+
super()
|
166
|
+
self.instance_eval(&block)
|
167
|
+
end
|
176
168
|
end
|
177
|
-
end
|
178
169
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
170
|
+
##
|
171
|
+
# Define an 'after' action. Inherits the way normal methods should.
|
172
|
+
#
|
173
|
+
# NOTE: +type+ is ignored and is only there to make porting easier.
|
174
|
+
#
|
175
|
+
# Equivalent to MiniTest::Unit::TestCase#teardown.
|
176
|
+
|
177
|
+
def after type = nil, &block
|
178
|
+
define_method :teardown do
|
179
|
+
self.instance_eval(&block)
|
180
|
+
super()
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
##
|
185
|
+
# Define an expectation with name +desc+. Name gets morphed to a
|
186
|
+
# proper test method name. For some freakish reason, people who
|
187
|
+
# write specs don't like class inheritance, so this goes way out of
|
188
|
+
# its way to make sure that expectations aren't inherited.
|
189
|
+
#
|
190
|
+
# This is also aliased to #specify and doesn't require a +desc+ arg.
|
191
|
+
#
|
192
|
+
# Hint: If you _do_ want inheritence, use minitest/unit. You can mix
|
193
|
+
# and match between assertions and expectations as much as you want.
|
194
|
+
|
195
|
+
def it desc = "anonymous", &block
|
196
|
+
block ||= proc { skip "(no tests defined)" }
|
189
197
|
|
190
|
-
|
191
|
-
|
198
|
+
@specs ||= 0
|
199
|
+
@specs += 1
|
192
200
|
|
193
|
-
|
194
|
-
@specs += 1
|
201
|
+
name = "test_%04d_%s" % [ @specs, desc ]
|
195
202
|
|
196
|
-
|
203
|
+
define_method name, &block
|
197
204
|
|
198
|
-
|
205
|
+
self.children.each do |mod|
|
206
|
+
mod.send :undef_method, name if mod.public_method_defined? name
|
207
|
+
end
|
199
208
|
|
200
|
-
|
201
|
-
mod.send :undef_method, name if mod.public_method_defined? name
|
209
|
+
name
|
202
210
|
end
|
203
211
|
|
204
|
-
|
205
|
-
|
212
|
+
##
|
213
|
+
# Essentially, define an accessor for +name+ with +block+.
|
214
|
+
#
|
215
|
+
# Why use let instead of def? I honestly don't know.
|
206
216
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
217
|
+
def let name, &block
|
218
|
+
define_method name do
|
219
|
+
@_memoized ||= {}
|
220
|
+
@_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
|
221
|
+
end
|
222
|
+
end
|
211
223
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
224
|
+
##
|
225
|
+
# Another lazy man's accessor generator. Made even more lazy by
|
226
|
+
# setting the name for you to +subject+.
|
227
|
+
|
228
|
+
def subject &block
|
229
|
+
let :subject, &block
|
216
230
|
end
|
217
|
-
end
|
218
231
|
|
219
|
-
|
220
|
-
|
221
|
-
|
232
|
+
def create name, desc # :nodoc:
|
233
|
+
cls = Class.new(self) do
|
234
|
+
@name = name
|
235
|
+
@desc = desc
|
222
236
|
|
223
|
-
|
224
|
-
|
225
|
-
end
|
237
|
+
nuke_test_methods!
|
238
|
+
end
|
226
239
|
|
227
|
-
|
228
|
-
cls = Class.new(self) do
|
229
|
-
@name = name
|
230
|
-
@desc = desc
|
240
|
+
children << cls
|
231
241
|
|
232
|
-
|
242
|
+
cls
|
233
243
|
end
|
234
244
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
end
|
245
|
+
def name # :nodoc:
|
246
|
+
defined?(@name) ? @name : super
|
247
|
+
end
|
239
248
|
|
240
|
-
|
241
|
-
|
242
|
-
|
249
|
+
def to_s # :nodoc:
|
250
|
+
name # Can't alias due to 1.8.7, not sure why
|
251
|
+
end
|
243
252
|
|
244
|
-
|
245
|
-
class << self
|
253
|
+
# :stopdoc:
|
246
254
|
attr_reader :desc
|
247
255
|
alias :specify :it
|
248
|
-
|
256
|
+
# :startdoc:
|
249
257
|
end
|
250
|
-
|
258
|
+
|
259
|
+
extend DSL
|
260
|
+
|
261
|
+
TYPES = DSL::TYPES
|
251
262
|
end
|
252
263
|
|
253
264
|
##
|
data/lib/minitest/unit.rb
CHANGED
@@ -220,7 +220,7 @@ module MiniTest
|
|
220
220
|
|
221
221
|
def assert_equal exp, act, msg = nil
|
222
222
|
msg = message(msg, "") { diff exp, act }
|
223
|
-
assert
|
223
|
+
assert exp == act, msg
|
224
224
|
end
|
225
225
|
|
226
226
|
##
|
@@ -726,7 +726,7 @@ module MiniTest
|
|
726
726
|
end
|
727
727
|
|
728
728
|
class Unit # :nodoc:
|
729
|
-
VERSION = "4.
|
729
|
+
VERSION = "4.7.0" # :nodoc:
|
730
730
|
|
731
731
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
732
732
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -1393,16 +1393,3 @@ module MiniTest
|
|
1393
1393
|
end # module MiniTest
|
1394
1394
|
|
1395
1395
|
Minitest = MiniTest # :nodoc: because ugh... I typo this all the time
|
1396
|
-
|
1397
|
-
if $DEBUG then
|
1398
|
-
module Test # :nodoc:
|
1399
|
-
module Unit # :nodoc:
|
1400
|
-
class TestCase # :nodoc:
|
1401
|
-
def self.inherited x # :nodoc:
|
1402
|
-
# this helps me ferret out porting issues
|
1403
|
-
raise "Using minitest and test/unit in the same process: #{x}"
|
1404
|
-
end
|
1405
|
-
end
|
1406
|
-
end
|
1407
|
-
end
|
1408
|
-
end
|
@@ -3,7 +3,11 @@ require "minitest/autorun"
|
|
3
3
|
require "stringio"
|
4
4
|
|
5
5
|
class MiniSpecA < MiniTest::Spec; end
|
6
|
-
class MiniSpecB < MiniTest::Spec; end
|
6
|
+
class MiniSpecB < MiniTest::Unit::TestCase; extend MiniTest::Spec::DSL; end
|
7
|
+
class MiniSpecC < MiniSpecB; end
|
8
|
+
class NamedExampleA < MiniSpecA; end
|
9
|
+
class NamedExampleB < MiniSpecB; end
|
10
|
+
class NamedExampleC < MiniSpecC; end
|
7
11
|
class ExampleA; end
|
8
12
|
class ExampleB < ExampleA; end
|
9
13
|
|
@@ -650,6 +654,26 @@ class TestMeta < MiniTest::Unit::TestCase
|
|
650
654
|
MiniTest::Spec::TYPES.replace original_types
|
651
655
|
end
|
652
656
|
|
657
|
+
def test_name
|
658
|
+
spec_a = describe ExampleA do; end
|
659
|
+
spec_b = describe ExampleB, :random_method do; end
|
660
|
+
|
661
|
+
assert_equal "ExampleA", spec_a.name
|
662
|
+
assert_equal "ExampleB::random_method", spec_b.name
|
663
|
+
end
|
664
|
+
|
665
|
+
def test_name2
|
666
|
+
assert_equal "NamedExampleA", NamedExampleA.name
|
667
|
+
assert_equal "NamedExampleB", NamedExampleB.name
|
668
|
+
assert_equal "NamedExampleC", NamedExampleC.name
|
669
|
+
|
670
|
+
spec_a = describe ExampleA do; end
|
671
|
+
spec_b = describe ExampleB, :random_method do; end
|
672
|
+
|
673
|
+
assert_equal "ExampleA", spec_a.name
|
674
|
+
assert_equal "ExampleB::random_method", spec_b.name
|
675
|
+
end
|
676
|
+
|
653
677
|
def test_structure
|
654
678
|
x, y, z, * = util_structure
|
655
679
|
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 4.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 4.7.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: 2013-
|
39
|
+
date: 2013-03-18 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
metadata.gz.sig
CHANGED
Binary file
|