restify 2.0.1 → 2.0.2

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/restify/relation.rb +6 -2
  4. data/lib/restify/version.rb +1 -1
  5. data/spec/restify/relation_spec.rb +54 -1
  6. data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/LICENSE +21 -0
  7. data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/README.md +23 -0
  8. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/CHANGELOG.md +255 -0
  9. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/MIT-LICENSE +20 -0
  10. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/README.rdoc +40 -0
  11. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
  12. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
  13. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
  14. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/LICENSE.txt +22 -0
  15. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/README.md +48 -0
  16. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/README.md +138 -0
  17. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/LICENSE +56 -0
  18. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
  19. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
  20. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
  21. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/LICENSE +20 -0
  22. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/README.md +167 -0
  23. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/LICENSE.txt +22 -0
  24. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/CHANGELOG.md +375 -0
  25. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/LICENSE +20 -0
  26. data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/README.md +118 -0
  27. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/CHANGELOG.md +473 -0
  28. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE +24 -0
  29. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE.SPECS +22 -0
  30. data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/README.md +137 -0
  31. data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/LICENSE.txt +16 -0
  32. data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/README.md +187 -0
  33. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/MIT-LICENSE +20 -0
  34. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/README.md +127 -0
  35. data/vendor/bundle/ruby/3.4.0/gems/little-plugger-1.1.4/README.rdoc +53 -0
  36. data/vendor/bundle/ruby/3.4.0/gems/logger-1.7.0/README.md +104 -0
  37. data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/LICENSE +22 -0
  38. data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/README.md +140 -0
  39. data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.5/README.rdoc +842 -0
  40. data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/ChangeLog +368 -0
  41. data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/LICENSE +177 -0
  42. data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/README.md +302 -0
  43. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/CHANGELOG.md +275 -0
  44. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/LICENSE.md +20 -0
  45. data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/README.md +121 -0
  46. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/CHANGELOG.md +193 -0
  47. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/LICENSE +201 -0
  48. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/README.md +68 -0
  49. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/CHANGELOG.md +98 -0
  50. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/LICENSE +201 -0
  51. data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/README.md +62 -0
  52. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/CHANGELOG.md +498 -0
  53. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/LICENSE.txt +22 -0
  54. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/README.md +222 -0
  55. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/CHANGELOG.md +1146 -0
  56. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/MIT-LICENSE +20 -0
  57. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/README.md +355 -0
  58. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
  59. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/README.rdoc +155 -0
  60. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
  61. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
  62. data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
  63. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/CHANGELOG.md +410 -0
  64. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/LICENSE +22 -0
  65. data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/README.md +588 -0
  66. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
  67. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
  68. data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.3/README.md +55 -0
  69. metadata +66 -4
  70. data/doc/file.README.html +0 -192
@@ -0,0 +1,842 @@
1
+ = minitest/{test,spec,mock,benchmark}
2
+
3
+ home :: https://github.com/minitest/minitest
4
+ bugs :: https://github.com/minitest/minitest/issues
5
+ rdoc :: https://docs.seattlerb.org/minitest
6
+ clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
7
+ vim :: https://github.com/sunaku/vim-ruby-minitest
8
+ emacs:: https://github.com/arthurnn/minitest-emacs
9
+
10
+ == DESCRIPTION:
11
+
12
+ minitest provides a complete suite of testing facilities supporting
13
+ TDD, BDD, mocking, and benchmarking.
14
+
15
+ "I had a class with Jim Weirich on testing last week and we were
16
+ allowed to choose our testing frameworks. Kirk Haines and I were
17
+ paired up and we cracked open the code for a few test
18
+ frameworks...
19
+
20
+ I MUST say that minitest is *very* readable / understandable
21
+ compared to the 'other two' options we looked at. Nicely done and
22
+ thank you for helping us keep our mental sanity."
23
+
24
+ -- Wayne E. Seguin
25
+
26
+ minitest/test is a small and incredibly fast unit testing framework.
27
+ It provides a rich set of assertions to make your tests clean and
28
+ readable.
29
+
30
+ minitest/spec is a functionally complete spec engine. It hooks onto
31
+ minitest/test and seamlessly bridges test assertions over to spec
32
+ expectations.
33
+
34
+ minitest/benchmark is an awesome way to assert the performance of your
35
+ algorithms in a repeatable manner. Now you can assert that your newb
36
+ co-worker doesn't replace your linear algorithm with an exponential
37
+ one!
38
+
39
+ minitest/mock by Steven Baker, is a beautifully tiny mock (and stub)
40
+ object framework.
41
+
42
+ minitest/pride shows pride in testing and adds coloring to your test
43
+ output. I guess it is an example of how to write IO pipes too. :P
44
+
45
+ minitest/test is meant to have a clean implementation for language
46
+ implementors that need a minimal set of methods to bootstrap a working
47
+ test suite. For example, there is no magic involved for test-case
48
+ discovery.
49
+
50
+ "Again, I can't praise enough the idea of a testing/specing
51
+ framework that I can actually read in full in one sitting!"
52
+
53
+ -- Piotr Szotkowski
54
+
55
+ Comparing to rspec:
56
+
57
+ rspec is a testing DSL. minitest is ruby.
58
+
59
+ -- Adam Hawkins, "Bow Before MiniTest"
60
+
61
+ minitest doesn't reinvent anything that ruby already provides, like:
62
+ classes, modules, inheritance, methods. This means you only have to
63
+ learn ruby to use minitest and all of your regular OO practices like
64
+ extract-method refactorings still apply.
65
+
66
+ == FEATURES/PROBLEMS:
67
+
68
+ * minitest/autorun - the easy and explicit way to run all your tests.
69
+ * minitest/test - a very fast, simple, and clean test system.
70
+ * minitest/spec - a very fast, simple, and clean spec system.
71
+ * minitest/mock - a simple and clean mock/stub system.
72
+ * minitest/benchmark - an awesome way to assert your algorithm's performance.
73
+ * minitest/pride - show your pride in testing!
74
+ * minitest/test_task - a full-featured and clean rake task generator.
75
+ * Incredibly small and fast runner, but no bells and whistles.
76
+ * Written by squishy human beings. Software can never be perfect. We will all eventually die.
77
+
78
+ == RATIONALE:
79
+
80
+ See design_rationale.rb to see how specs and tests work in minitest.
81
+
82
+ == SYNOPSIS:
83
+
84
+ Given that you'd like to test the following class:
85
+
86
+ class Meme
87
+ def i_can_has_cheezburger?
88
+ "OHAI!"
89
+ end
90
+
91
+ def will_it_blend?
92
+ "YES!"
93
+ end
94
+ end
95
+
96
+ === Unit tests
97
+
98
+ Define your tests as methods beginning with +test_+.
99
+
100
+ require "minitest/autorun"
101
+
102
+ class TestMeme < Minitest::Test
103
+ def setup
104
+ @meme = Meme.new
105
+ end
106
+
107
+ def test_that_kitty_can_eat
108
+ assert_equal "OHAI!", @meme.i_can_has_cheezburger?
109
+ end
110
+
111
+ def test_that_it_will_not_blend
112
+ refute_match /^no/i, @meme.will_it_blend?
113
+ end
114
+
115
+ def test_that_will_be_skipped
116
+ skip "test this later"
117
+ end
118
+ end
119
+
120
+ === Specs
121
+
122
+ require "minitest/autorun"
123
+
124
+ describe Meme do
125
+ before do
126
+ @meme = Meme.new
127
+ end
128
+
129
+ describe "when asked about cheeseburgers" do
130
+ it "must respond positively" do
131
+ _(@meme.i_can_has_cheezburger?).must_equal "OHAI!"
132
+ end
133
+ end
134
+
135
+ describe "when asked about blending possibilities" do
136
+ it "won't say no" do
137
+ _(@meme.will_it_blend?).wont_match /^no/i
138
+ end
139
+ end
140
+ end
141
+
142
+ For matchers support check out:
143
+
144
+ * https://github.com/wojtekmach/minitest-matchers
145
+ * https://github.com/rmm5t/minitest-matchers_vaccine
146
+
147
+ === Benchmarks
148
+
149
+ Add benchmarks to your tests.
150
+
151
+ # optionally run benchmarks, good for CI-only work!
152
+ require "minitest/benchmark" if ENV["BENCH"]
153
+
154
+ class TestMeme < Minitest::Benchmark
155
+ # Override self.bench_range or default range is [1, 10, 100, 1_000, 10_000]
156
+ def bench_my_algorithm
157
+ assert_performance_linear 0.9999 do |n| # n is a range value
158
+ @obj.my_algorithm(n)
159
+ end
160
+ end
161
+ end
162
+
163
+ Or add them to your specs. If you make benchmarks optional, you'll
164
+ need to wrap your benchmarks in a conditional since the methods won't
165
+ be defined. In minitest 5, the describe name needs to match
166
+ <tt>/Bench(mark)?$/</tt>.
167
+
168
+ describe "Meme Benchmark" do
169
+ if ENV["BENCH"] then
170
+ bench_performance_linear "my_algorithm", 0.9999 do |n|
171
+ 100.times do
172
+ @obj.my_algorithm(n)
173
+ end
174
+ end
175
+ end
176
+ end
177
+
178
+ outputs something like:
179
+
180
+ # Running benchmarks:
181
+
182
+ TestBlah 100 1000 10000
183
+ bench_my_algorithm 0.006167 0.079279 0.786993
184
+ bench_other_algorithm 0.061679 0.792797 7.869932
185
+
186
+ Output is tab-delimited to make it easy to paste into a spreadsheet.
187
+
188
+ === Mocks
189
+
190
+ Mocks and stubs defined using terminology by Fowler & Meszaros at
191
+ https://www.martinfowler.com/bliki/TestDouble.html:
192
+
193
+ "Mocks are pre-programmed with expectations which form a specification
194
+ of the calls they are expected to receive. They can throw an exception
195
+ if they receive a call they don't expect and are checked during
196
+ verification to ensure they got all the calls they were expecting."
197
+
198
+ class MemeAsker
199
+ def initialize(meme)
200
+ @meme = meme
201
+ end
202
+
203
+ def ask(question)
204
+ method = question.tr(" ", "_") + "?"
205
+ @meme.__send__(method)
206
+ end
207
+ end
208
+
209
+ require "minitest/autorun"
210
+
211
+ describe MemeAsker, :ask do
212
+ describe "when passed an unpunctuated question" do
213
+ it "should invoke the appropriate predicate method on the meme" do
214
+ @meme = Minitest::Mock.new
215
+ @meme_asker = MemeAsker.new @meme
216
+ @meme.expect :will_it_blend?, :return_value
217
+
218
+ @meme_asker.ask "will it blend"
219
+
220
+ @meme.verify
221
+ end
222
+ end
223
+ end
224
+
225
+ ==== Multi-threading and Mocks
226
+
227
+ Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
228
+ you can use regular ruby patterns and facilities like local variables. Here's
229
+ an example of asserting that code inside a thread is run:
230
+
231
+ def test_called_inside_thread
232
+ called = false
233
+ pr = Proc.new { called = true }
234
+ thread = Thread.new(&pr)
235
+ thread.join
236
+ assert called, "proc not called"
237
+ end
238
+
239
+ === Stubs
240
+
241
+ Mocks and stubs are defined using terminology by Fowler & Meszaros at
242
+ https://www.martinfowler.com/bliki/TestDouble.html:
243
+
244
+ "Stubs provide canned answers to calls made during the test".
245
+
246
+ Minitest's stub method overrides a single method for the duration of
247
+ the block.
248
+
249
+ def test_stale_eh
250
+ obj_under_test = Something.new
251
+
252
+ refute obj_under_test.stale?
253
+
254
+ Time.stub :now, Time.at(0) do # stub goes away once the block is done
255
+ assert obj_under_test.stale?
256
+ end
257
+ end
258
+
259
+ A note on stubbing: In order to stub a method, the method must
260
+ actually exist prior to stubbing. Use a singleton method to create a
261
+ new non-existing method:
262
+
263
+ def obj_under_test.fake_method
264
+ ...
265
+ end
266
+
267
+ === Running Your Tests
268
+
269
+ Ideally, you'll use a rake task to run your tests (see below), either
270
+ piecemeal or all at once. BUT! You don't have to:
271
+
272
+ % ruby -Ilib:test test/minitest/test_minitest_test.rb
273
+ Run options: --seed 37685
274
+
275
+ # Running:
276
+
277
+ ...................................................................... (etc)
278
+
279
+ Finished in 0.107130s, 1446.8403 runs/s, 2959.0217 assertions/s.
280
+
281
+ 155 runs, 317 assertions, 0 failures, 0 errors, 0 skips
282
+
283
+ There are runtime options available, both from minitest itself, and also
284
+ provided via plugins. To see them, simply run with +--help+:
285
+
286
+ % ruby -Ilib:test test/minitest/test_minitest_test.rb --help
287
+ minitest options:
288
+ -h, --help Display this help.
289
+ -s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake
290
+ -v, --verbose Verbose. Show progress processing files.
291
+ -n, --name PATTERN Filter run on /regexp/ or string.
292
+ -e, --exclude PATTERN Exclude /regexp/ or string from run.
293
+
294
+ Known extensions: pride, autotest
295
+ -p, --pride Pride. Show your testing pride!
296
+ -a, --autotest Connect to autotest server.
297
+
298
+ === Rake Tasks
299
+
300
+ You can set up a rake task to run all your tests by adding this to your Rakefile:
301
+
302
+ require "minitest/test_task"
303
+
304
+ Minitest::TestTask.create # named test, sensible defaults
305
+
306
+ # or more explicitly:
307
+
308
+ Minitest::TestTask.create(:test) do |t|
309
+ t.libs << "test"
310
+ t.libs << "lib"
311
+ t.warning = false
312
+ t.test_globs = ["test/**/*_test.rb"]
313
+ end
314
+
315
+ task :default => :test
316
+
317
+ Each of these will generate 4 tasks:
318
+
319
+ rake test :: Run the test suite.
320
+ rake test:cmd :: Print out the test command.
321
+ rake test:isolated :: Show which test files fail when run separately.
322
+ rake test:slow :: Show bottom 25 tests sorted by time.
323
+
324
+ === Rake Task Variables
325
+
326
+ There are a bunch of variables you can supply to rake to modify the run.
327
+
328
+ MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
329
+ N :: -n: Tests to run (string or /regexp/).
330
+ X :: -x: Tests to exclude (string or /regexp/).
331
+ A :: Any extra arguments. Honors shell quoting.
332
+ MT_CPU :: How many threads to use for parallel test runs
333
+ SEED :: -s --seed Sets random seed.
334
+ TESTOPTS :: Deprecated, same as A
335
+ FILTER :: Deprecated, same as A
336
+
337
+ == Writing Extensions
338
+
339
+ To define a plugin, add a file named minitest/XXX_plugin.rb to your
340
+ project/gem. That file must be discoverable via ruby's LOAD_PATH (via
341
+ rubygems or otherwise). Minitest will find and require that file using
342
+ Gem.find_files. It will then try to call +plugin_XXX_init+ during
343
+ startup. The option processor will also try to call +plugin_XXX_options+
344
+ passing the OptionParser instance and the current options hash. This
345
+ lets you register your own command-line options. Here's a totally
346
+ bogus example:
347
+
348
+ # minitest/bogus_plugin.rb:
349
+
350
+ module Minitest
351
+ def self.plugin_bogus_options(opts, options)
352
+ opts.on "--myci", "Report results to my CI" do
353
+ options[:myci] = true
354
+ options[:myci_addr] = get_myci_addr
355
+ options[:myci_port] = get_myci_port
356
+ end
357
+ end
358
+
359
+ def self.plugin_bogus_init(options)
360
+ self.reporter << MyCI.new(options) if options[:myci]
361
+ end
362
+ end
363
+
364
+ === Adding custom reporters
365
+
366
+ Minitest uses composite reporter to output test results using multiple
367
+ reporter instances. You can add new reporters to the composite during
368
+ the init_plugins phase. As we saw in +plugin_bogus_init+ above, you
369
+ simply add your reporter instance to the composite via <tt><<</tt>.
370
+
371
+ +AbstractReporter+ defines the API for reporters. You may subclass it
372
+ and override any method you want to achieve your desired behavior.
373
+
374
+ start :: Called when the run has started.
375
+ record :: Called for each result, passed or otherwise.
376
+ report :: Called at the end of the run.
377
+ passed? :: Called to see if you detected any problems.
378
+
379
+ Using our example above, here is how we might implement MyCI:
380
+
381
+ # minitest/bogus_plugin.rb
382
+
383
+ module Minitest
384
+ class MyCI < AbstractReporter
385
+ attr_accessor :results, :addr, :port
386
+
387
+ def initialize options
388
+ self.results = []
389
+ self.addr = options[:myci_addr]
390
+ self.port = options[:myci_port]
391
+ end
392
+
393
+ def record result
394
+ self.results << result
395
+ end
396
+
397
+ def report
398
+ CI.connect(addr, port).send_results self.results
399
+ end
400
+ end
401
+
402
+ # code from above...
403
+ end
404
+
405
+ == FAQ
406
+
407
+ === What versions are compatible with what? Or what versions are supported?
408
+
409
+ Minitest is a dependency of rails, which until very recently had an
410
+ overzealous backwards compatibility policy. As such, I'm stuck
411
+ supporting versions of ruby that are long past EOL. Hopefully I'll be
412
+ able to support only current versions of ruby sometime in the near
413
+ future.
414
+
415
+ NOTICE: At this point, I will only locally test/dev against the
416
+ currently 3 supported (non-EOL) versions of ruby. I cannot and will
417
+ not maintain that many builds.
418
+
419
+ (As of 2025-02-03)
420
+
421
+ Current versions of rails: (https://endoflife.date/rails)
422
+
423
+ | rails | min ruby | minitest | status | EOL Date |
424
+ |-------+----------+----------+----------+------------|
425
+ | 8.0 | >= 3.2 | >= 5.1 | Current | 2026-11-07 |
426
+ | 7.2 | >= 3.1 | >= 5.1 | Current | 2026-08-09 |
427
+ | 7.1 | >= 2.7 | >= 5.1 | Security | 2025-10-01 |
428
+ | 7.0 | >= 2.7 | >= 5.1 | Security | 2025-04-01 |
429
+ | 6.1 | >= 2.5 | >= 5.1 | EOL | 2024-10-01 |
430
+ | 6.0 | >= 2.5 | >= 5.1 | EOL | 2023-06-01 |
431
+ | 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
432
+
433
+ If you want to look at the requirements for a specific version, run:
434
+
435
+ gem spec -r --ruby rails -v 8.0.0
436
+
437
+ Current versions of ruby: (https://endoflife.date/ruby)
438
+
439
+ | ruby | Status | EOL Date |
440
+ |------+---------+------------|
441
+ | 3.4 | Current | 2028-03-31 |
442
+ | 3.3 | Maint | 2027-03-31 |
443
+ | 3.2 | Security| 2026-03-31 |
444
+ | 3.1 | EOL | 2025-03-31 |
445
+ | 3.0 | EOL | 2024-03-31 |
446
+ | 2.7 | EOL | 2023-03-31 |
447
+ | 2.6 | EOL | 2022-03-31 |
448
+ | 2.5 | EOL | 2021-03-31 |
449
+
450
+ === How to test SimpleDelegates?
451
+
452
+ The following implementation and test:
453
+
454
+ class Worker < SimpleDelegator
455
+ def work
456
+ end
457
+ end
458
+
459
+ describe Worker do
460
+ before do
461
+ @worker = Worker.new(Object.new)
462
+ end
463
+
464
+ it "must respond to work" do
465
+ _(@worker).must_respond_to :work
466
+ end
467
+ end
468
+
469
+ outputs a failure:
470
+
471
+ 1) Failure:
472
+ Worker#test_0001_must respond to work [bug11.rb:16]:
473
+ Expected #<Object:0x007f9e7184f0a0> (Object) to respond to #work.
474
+
475
+ Worker is a SimpleDelegate which in 1.9+ is a subclass of BasicObject.
476
+ Expectations are put on Object (one level down) so the Worker
477
+ (SimpleDelegate) hits +method_missing+ and delegates down to the
478
+ +Object.new+ instance. That object doesn't respond to work so the test
479
+ fails.
480
+
481
+ You can bypass <tt>SimpleDelegate#method_missing</tt> by extending the worker
482
+ with <tt>Minitest::Expectations</tt>. You can either do that in your setup at
483
+ the instance level, like:
484
+
485
+ before do
486
+ @worker = Worker.new(Object.new)
487
+ @worker.extend Minitest::Expectations
488
+ end
489
+
490
+ or you can extend the Worker class (within the test file!), like:
491
+
492
+ class Worker
493
+ include ::Minitest::Expectations
494
+ end
495
+
496
+ === How to share code across test classes?
497
+
498
+ Use a module. That's exactly what they're for:
499
+
500
+ module UsefulStuff
501
+ def useful_method
502
+ # ...
503
+ end
504
+ end
505
+
506
+ describe Blah do
507
+ include UsefulStuff
508
+
509
+ def test_whatever
510
+ # useful_method available here
511
+ end
512
+ end
513
+
514
+ Remember, +describe+ simply creates test classes. It's just ruby at
515
+ the end of the day and all your normal Good Ruby Rules (tm) apply. If
516
+ you want to extend your test using setup/teardown via a module, just
517
+ make sure you ALWAYS call super. before/after automatically call super
518
+ for you, so make sure you don't do it twice.
519
+
520
+ === How to run code before a group of tests?
521
+
522
+ Use a constant with begin...end like this:
523
+
524
+ describe Blah do
525
+ SETUP = begin
526
+ # ... this runs once when describe Blah starts
527
+ end
528
+ # ...
529
+ end
530
+
531
+ This can be useful for expensive initializations or sharing state.
532
+ Remember, this is just ruby code, so you need to make sure this
533
+ technique and sharing state doesn't interfere with your tests.
534
+
535
+ === Why am I seeing <tt>uninitialized constant MiniTest::Test (NameError)</tt>?
536
+
537
+ Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
538
+ in order to require minitest, you must first add the <tt>gem 'minitest'</tt>
539
+ to your Gemfile and run +bundle+. Once it's installed, you should be
540
+ able to require minitest and run your tests.
541
+
542
+ == Prominent Projects using Minitest:
543
+
544
+ * arel
545
+ * journey
546
+ * mime-types
547
+ * nokogiri
548
+ * rails (active_support et al)
549
+ * rake
550
+ * rdoc
551
+ * ...and of course, everything from seattle.rb...
552
+
553
+ == Developing Minitest:
554
+
555
+ Minitest requires {Hoe}[https://rubygems.org/gems/hoe].
556
+
557
+ === Minitest's own tests require UTF-8 external encoding.
558
+
559
+ This is a common problem in Windows, where the default external Encoding is
560
+ often CP850, but can affect any platform.
561
+ Minitest can run test suites using any Encoding, but to run Minitest's
562
+ own tests you must have a default external Encoding of UTF-8.
563
+
564
+ If your encoding is wrong, you'll see errors like:
565
+
566
+ --- expected
567
+ +++ actual
568
+ @@ -1,2 +1,3 @@
569
+ # encoding: UTF-8
570
+ -"Expected /\\w+/ to not match \"blah blah blah\"."
571
+ +"Expected /\\w+/ to not match # encoding: UTF-8
572
+ +\"blah blah blah\"."
573
+
574
+ To check your current encoding, run:
575
+
576
+ ruby -e 'puts Encoding.default_external'
577
+
578
+ If your output is something other than UTF-8, you can set the RUBYOPTS
579
+ env variable to a value of '-Eutf-8'. Something like:
580
+
581
+ RUBYOPT='-Eutf-8' ruby -e 'puts Encoding.default_external'
582
+
583
+ Check your OS/shell documentation for the precise syntax (the above
584
+ will not work on a basic Windows CMD prompt, look for the SET command).
585
+ Once you've got it successfully outputing UTF-8, use the same setting
586
+ when running rake in Minitest.
587
+
588
+ === Minitest's own tests require GNU (or similar) diff.
589
+
590
+ This is also a problem primarily affecting Windows developers. PowerShell
591
+ has a command called diff, but it is not suitable for use with Minitest.
592
+
593
+ If you see failures like either of these, you are probably missing diff tool:
594
+
595
+ 4) Failure:
596
+ TestMinitestUnitTestCase#test_assert_equal_different_long [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:936]:
597
+ Expected: "--- expected\n+++ actual\n@@ -1 +1 @@\n-\"hahahahahahahahahahahahahahahahahahahaha\"\n+\"blahblahblahblahblahblahblahblahblahblah\"\n"
598
+ Actual: "Expected: \"hahahahahahahahahahahahahahahahahahahaha\"\n Actual: \"blahblahblahblahblahblahblahblahblahblah\""
599
+
600
+
601
+ 5) Failure:
602
+ TestMinitestUnitTestCase#test_assert_equal_different_collection_hash_hex_invisible [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:845]:
603
+ Expected: "No visible difference in the Hash#inspect output.\nYou should look at the implementation of #== on Hash or its members.\n
604
+ {1=>#<Object:0xXXXXXX>}"
605
+ Actual: "Expected: {1=>#<Object:0x00000003ba0470>}\n Actual: {1=>#<Object:0x00000003ba0448>}"
606
+
607
+
608
+ If you use Cygwin or MSYS2 or similar there are packages that include a
609
+ GNU diff for Windows. If you don't, you can download GNU diffutils from
610
+ http://gnuwin32.sourceforge.net/packages/diffutils.htm
611
+ (make sure to add it to your PATH).
612
+
613
+ You can make sure it's installed and path is configured properly with:
614
+
615
+ diff.exe -v
616
+
617
+ There are multiple lines of output, the first should be something like:
618
+
619
+ diff (GNU diffutils) 2.8.1
620
+
621
+ If you are using PowerShell make sure you run diff.exe, not just diff,
622
+ which will invoke the PowerShell built in function.
623
+
624
+ == Known Extensions:
625
+
626
+ capybara_minitest_spec :: Bridge between Capybara RSpec matchers and
627
+ Minitest::Spec expectations (e.g.
628
+ <tt>page.must_have_content("Title")</tt>).
629
+ color_pound_spec_reporter :: Test names print Ruby Object types in color with
630
+ your Minitest Spec style tests.
631
+ minispec-metadata :: Metadata for describe/it blocks & CLI tag filter.
632
+ E.g. <tt>it "requires JS driver", js: true do</tt> &
633
+ <tt>ruby test.rb --tag js</tt> runs tests tagged :js.
634
+ minispec-rails :: Minimal support to use Spec style in Rails 5+.
635
+ mini-apivore :: for swagger based automated API testing.
636
+ minitest-around :: Around block for minitest. An alternative to
637
+ setup/teardown dance.
638
+ minitest-assert_errors :: Adds Minitest assertions to test for errors raised
639
+ or not raised by Minitest itself.
640
+ minitest-autotest :: autotest is a continuous testing facility meant to
641
+ be used during development.
642
+ minitest-bacon :: minitest-bacon extends minitest with bacon-like
643
+ functionality.
644
+ minitest-bang :: Adds support for RSpec-style let! to immediately
645
+ invoke let statements before each test.
646
+ minitest-bisect :: Helps you isolate and debug random test failures.
647
+ minitest-blink1_reporter :: Display test results with a Blink1.
648
+ minitest-capistrano :: Assertions and expectations for testing
649
+ Capistrano recipes.
650
+ minitest-capybara :: Capybara matchers support for minitest unit and
651
+ spec.
652
+ minitest-cc :: It provides minimal information about code coverage.
653
+ minitest-chef-handler :: Run Minitest suites as Chef report handlers
654
+ minitest-ci :: CI reporter plugin for Minitest.
655
+ minitest-context :: Defines contexts for code reuse in Minitest
656
+ specs that share common expectations.
657
+ minitest-debugger :: Wraps assert so failed assertions drop into
658
+ the ruby debugger.
659
+ minitest-display :: Patches Minitest to allow for an easily
660
+ configurable output.
661
+ minitest-documentation :: Minimal documentation format inspired by rspec's.
662
+ minitest-doc_reporter :: Detailed output inspired by rspec's documentation
663
+ format.
664
+ minitest-emoji :: Print out emoji for your test passes, fails, and
665
+ skips.
666
+ minitest-english :: Semantically symmetric aliases for assertions and
667
+ expectations.
668
+ minitest-excludes :: Clean API for excluding certain tests you
669
+ don't want to run under certain conditions.
670
+ minitest-fail-fast :: Reimplements RSpec's "fail fast" feature
671
+ minitest-filecontent :: Support unit tests with expectation results in files.
672
+ Differing results will be stored again in files.
673
+ minitest-filesystem :: Adds assertion and expectation to help testing
674
+ filesystem contents.
675
+ minitest-firemock :: Makes your Minitest mocks more resilient.
676
+ minitest-focus :: Focus on one test at a time.
677
+ minitest-gcstats :: A minitest plugin that adds a report of the top
678
+ tests by number of objects allocated.
679
+ minitest-global_expectations:: Support minitest expectation methods for all objects
680
+ minitest-great_expectations :: Generally useful additions to minitest's
681
+ assertions and expectations.
682
+ minitest-growl :: Test notifier for minitest via growl.
683
+ minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
684
+ minitest-have_tag :: Adds Minitest assertions to test for the existence of
685
+ HTML tags, including contents, within a provided string.
686
+ minitest-heat :: Reporting that builds a heat map of failure locations
687
+ minitest-hooks :: Around and before_all/after_all/around_all hooks
688
+ minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
689
+ minitest-implicit-subject :: Implicit declaration of the test subject.
690
+ minitest-instrument :: Instrument ActiveSupport::Notifications when
691
+ test method is executed.
692
+ minitest-instrument-db :: Store information about speed of test execution
693
+ provided by minitest-instrument in database.
694
+ minitest-junit :: JUnit-style XML reporter for minitest.
695
+ minitest-keyword :: Use Minitest assertions with keyword arguments.
696
+ minitest-libnotify :: Test notifier for minitest via libnotify.
697
+ minitest-line :: Run test at line number.
698
+ minitest-logger :: Define assert_log and enable minitest to test log messages.
699
+ Supports Logger and Log4r::Logger.
700
+ minitest-macruby :: Provides extensions to minitest for macruby UI
701
+ testing.
702
+ minitest-matchers :: Adds support for RSpec-style matchers to
703
+ minitest.
704
+ minitest-matchers_vaccine :: Adds assertions that adhere to the matcher spec,
705
+ but without any expectation infections.
706
+ minitest-metadata :: Annotate tests with metadata (key-value).
707
+ minitest-mock_expectations :: Provides method call assertions for minitest.
708
+ minitest-mongoid :: Mongoid assertion matchers for Minitest.
709
+ minitest-must_not :: Provides must_not as an alias for wont in
710
+ Minitest.
711
+ minitest-optional_retry :: Automatically retry failed test to help with flakiness.
712
+ minitest-osx :: Reporter for the Mac OS X notification center.
713
+ minitest-parallel_fork :: Fork-based parallelization
714
+ minitest-parallel-db :: Run tests in parallel with a single database.
715
+ minitest-power_assert :: PowerAssert for Minitest.
716
+ minitest-predicates :: Adds support for .predicate? methods.
717
+ minitest-profile :: List the 10 slowest tests in your suite.
718
+ minitest-rails :: Minitest integration for Rails 3.x.
719
+ minitest-rails-capybara :: Capybara integration for Minitest::Rails.
720
+ minitest-reporters :: Create customizable Minitest output formats.
721
+ minitest-rg :: Colored red/green output for Minitest.
722
+ minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
723
+ minitest-server :: minitest-server provides a client/server setup
724
+ with your minitest process, allowing your test
725
+ run to send its results directly to a handler.
726
+ minitest-sequel :: Minitest assertions to speed-up development and
727
+ testing of Ruby Sequel database setups.
728
+ minitest-shared_description :: Support for shared specs and shared spec
729
+ subclasses
730
+ minitest-should_syntax :: RSpec-style <tt>x.should == y</tt> assertions for
731
+ Minitest.
732
+ minitest-shouldify :: Adding all manner of shoulds to Minitest (bad
733
+ idea)
734
+ minitest-snail :: Print a list of tests that take too long
735
+ minitest-spec-context :: Provides rspec-ish context method to
736
+ Minitest::Spec.
737
+ minitest-spec-expect :: Expect syntax for Minitest::Spec (e.g.
738
+ expect(sequences).to_include :celery_man).
739
+ minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond.
740
+ minitest-spec-rails :: Drop in Minitest::Spec superclass for
741
+ ActiveSupport::TestCase.
742
+ minitest-sprint :: Runs (Get it? It's fast!) your tests and makes
743
+ it easier to rerun individual failures.
744
+ minitest-stately :: Find leaking state between tests
745
+ minitest-stub_any_instance :: Stub any instance of a method on the given class
746
+ for the duration of a block.
747
+ minitest-stub-const :: Stub constants for the duration of a block.
748
+ minitest-tags :: Add tags for minitest.
749
+ minitest-unordered :: Adds a new assertion to minitest for checking the
750
+ contents of a collection, ignoring element order.
751
+ minitest-vcr :: Automatic cassette management with Minitest::Spec
752
+ and VCR.
753
+ minitest_log :: Adds structured logging, data explication, and verdicts.
754
+ minitest_owrapper :: Get tests results as a TestResult object.
755
+ minitest_should :: Shoulda style syntax for minitest test::unit.
756
+ minitest_tu_shim :: Bridges between test/unit and minitest.
757
+ mongoid-minitest :: Minitest matchers for Mongoid.
758
+ mutant-minitest :: Minitest integration for mutant.
759
+ pry-rescue :: A pry plugin w/ minitest support. See
760
+ pry-rescue/minitest.rb.
761
+ rematch :: Declutter your test files from large hardcoded data
762
+ and update them automatically when your code changes.
763
+ rspec2minitest :: Easily translate any RSpec matchers to Minitest
764
+ assertions and expectations.
765
+ stubberry :: Multiple stubbing 'berries', sweet and useful
766
+ stub helpers and assertions. ( stub_must,
767
+ assert_method_called, stubbing ORM objects by id )
768
+
769
+ == Unknown Extensions:
770
+
771
+ Authors... Please send me a pull request with a description of your minitest extension.
772
+
773
+ * assay-minitest
774
+ * detroit-minitest
775
+ * em-minitest-spec
776
+ * flexmock-minitest
777
+ * guard-minitest
778
+ * guard-minitest-decisiv
779
+ * minitest-activemodel
780
+ * minitest-ar-assertions
781
+ * minitest-capybara-unit
782
+ * minitest-colorer
783
+ * minitest-deluxe
784
+ * minitest-extra-assertions
785
+ * minitest-rails-shoulda
786
+ * minitest-spec
787
+ * minitest-spec-should
788
+ * minitest-sugar
789
+ * spork-minitest
790
+
791
+ == Minitest related goods
792
+
793
+ * minitest/pride fabric: https://www.spoonflower.com/fabric/3928730-again-by-katie_allen
794
+
795
+ == REQUIREMENTS:
796
+
797
+ * Ruby 2.3+. No magic is involved. I hope.
798
+
799
+ == INSTALL:
800
+
801
+ sudo gem install minitest
802
+
803
+ On 1.9, you already have it. To get newer candy you can still install
804
+ the gem, and then requiring "minitest/autorun" should automatically
805
+ pull it in. If not, you'll need to do it yourself:
806
+
807
+ gem "minitest" # ensures you"re using the gem, and not the built-in MT
808
+ require "minitest/autorun"
809
+
810
+ # ... usual testing stuffs ...
811
+
812
+ DO NOTE: There is a serious problem with the way that ruby 1.9/2.0
813
+ packages their own gems. They install a gem specification file, but
814
+ don't install the gem contents in the gem path. This messes up
815
+ Gem.find_files and many other things (gem which, gem contents, etc).
816
+
817
+ Just install minitest as a gem for real and you'll be happier.
818
+
819
+ == LICENSE:
820
+
821
+ (The MIT License)
822
+
823
+ Copyright (c) Ryan Davis, seattle.rb
824
+
825
+ Permission is hereby granted, free of charge, to any person obtaining
826
+ a copy of this software and associated documentation files (the
827
+ 'Software'), to deal in the Software without restriction, including
828
+ without limitation the rights to use, copy, modify, merge, publish,
829
+ distribute, sublicense, and/or sell copies of the Software, and to
830
+ permit persons to whom the Software is furnished to do so, subject to
831
+ the following conditions:
832
+
833
+ The above copyright notice and this permission notice shall be
834
+ included in all copies or substantial portions of the Software.
835
+
836
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
837
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
838
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
839
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
840
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
841
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
842
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.