mercadopago-custom-checkout 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +5 -5
  2. data/.gs/bin/rake +12 -8
  3. data/.gs/specifications/rake-10.5.0.gemspec +24 -28
  4. data/.tool-versions +1 -0
  5. data/lib/mercadopago/custom_checkout/version.rb +1 -1
  6. data/mercadopago-custom-checkout.gemspec +3 -3
  7. metadata +14 -125
  8. data/.gs/cache/faraday-0.9.2.gem +0 -0
  9. data/.gs/cache/minitest-5.9.0.gem +0 -0
  10. data/.gs/cache/multi_json-1.12.1.gem +0 -0
  11. data/.gs/cache/multipart-post-2.0.0.gem +0 -0
  12. data/.gs/gems/faraday-0.9.2/LICENSE.md +0 -20
  13. data/.gs/gems/faraday-0.9.2/README.md +0 -245
  14. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http.rb +0 -237
  15. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http_ssl_patch.rb +0 -56
  16. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -66
  17. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony.rb +0 -100
  18. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/excon.rb +0 -81
  19. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/httpclient.rb +0 -117
  20. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb +0 -130
  21. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http_persistent.rb +0 -49
  22. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/patron.rb +0 -78
  23. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/rack.rb +0 -58
  24. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/test.rb +0 -162
  25. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/typhoeus.rb +0 -123
  26. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter.rb +0 -46
  27. data/.gs/gems/faraday-0.9.2/lib/faraday/autoload.rb +0 -84
  28. data/.gs/gems/faraday-0.9.2/lib/faraday/connection.rb +0 -437
  29. data/.gs/gems/faraday-0.9.2/lib/faraday/error.rb +0 -53
  30. data/.gs/gems/faraday-0.9.2/lib/faraday/middleware.rb +0 -37
  31. data/.gs/gems/faraday-0.9.2/lib/faraday/options.rb +0 -359
  32. data/.gs/gems/faraday-0.9.2/lib/faraday/parameters.rb +0 -197
  33. data/.gs/gems/faraday-0.9.2/lib/faraday/rack_builder.rb +0 -213
  34. data/.gs/gems/faraday-0.9.2/lib/faraday/request/authorization.rb +0 -42
  35. data/.gs/gems/faraday-0.9.2/lib/faraday/request/basic_authentication.rb +0 -13
  36. data/.gs/gems/faraday-0.9.2/lib/faraday/request/instrumentation.rb +0 -36
  37. data/.gs/gems/faraday-0.9.2/lib/faraday/request/multipart.rb +0 -63
  38. data/.gs/gems/faraday-0.9.2/lib/faraday/request/retry.rb +0 -154
  39. data/.gs/gems/faraday-0.9.2/lib/faraday/request/token_authentication.rb +0 -15
  40. data/.gs/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb +0 -36
  41. data/.gs/gems/faraday-0.9.2/lib/faraday/request.rb +0 -92
  42. data/.gs/gems/faraday-0.9.2/lib/faraday/response/logger.rb +0 -59
  43. data/.gs/gems/faraday-0.9.2/lib/faraday/response/raise_error.rb +0 -21
  44. data/.gs/gems/faraday-0.9.2/lib/faraday/response.rb +0 -93
  45. data/.gs/gems/faraday-0.9.2/lib/faraday/upload_io.rb +0 -67
  46. data/.gs/gems/faraday-0.9.2/lib/faraday/utils.rb +0 -309
  47. data/.gs/gems/faraday-0.9.2/lib/faraday.rb +0 -268
  48. data/.gs/gems/minitest-5.9.0/.autotest +0 -34
  49. data/.gs/gems/minitest-5.9.0/History.rdoc +0 -1176
  50. data/.gs/gems/minitest-5.9.0/Manifest.txt +0 -26
  51. data/.gs/gems/minitest-5.9.0/README.rdoc +0 -656
  52. data/.gs/gems/minitest-5.9.0/Rakefile +0 -72
  53. data/.gs/gems/minitest-5.9.0/design_rationale.rb +0 -52
  54. data/.gs/gems/minitest-5.9.0/lib/hoe/minitest.rb +0 -26
  55. data/.gs/gems/minitest-5.9.0/lib/minitest/assertions.rb +0 -674
  56. data/.gs/gems/minitest-5.9.0/lib/minitest/autorun.rb +0 -13
  57. data/.gs/gems/minitest-5.9.0/lib/minitest/benchmark.rb +0 -424
  58. data/.gs/gems/minitest-5.9.0/lib/minitest/expectations.rb +0 -284
  59. data/.gs/gems/minitest-5.9.0/lib/minitest/hell.rb +0 -17
  60. data/.gs/gems/minitest-5.9.0/lib/minitest/mock.rb +0 -232
  61. data/.gs/gems/minitest-5.9.0/lib/minitest/parallel.rb +0 -69
  62. data/.gs/gems/minitest-5.9.0/lib/minitest/pride.rb +0 -4
  63. data/.gs/gems/minitest-5.9.0/lib/minitest/pride_plugin.rb +0 -142
  64. data/.gs/gems/minitest-5.9.0/lib/minitest/spec.rb +0 -331
  65. data/.gs/gems/minitest-5.9.0/lib/minitest/test.rb +0 -284
  66. data/.gs/gems/minitest-5.9.0/lib/minitest/unit.rb +0 -45
  67. data/.gs/gems/minitest-5.9.0/lib/minitest.rb +0 -815
  68. data/.gs/gems/minitest-5.9.0/test/minitest/metametameta.rb +0 -90
  69. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_benchmark.rb +0 -137
  70. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_mock.rb +0 -512
  71. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_reporter.rb +0 -281
  72. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_spec.rb +0 -967
  73. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_test.rb +0 -1983
  74. data/.gs/gems/multi_json-1.12.1/CHANGELOG.md +0 -245
  75. data/.gs/gems/multi_json-1.12.1/CONTRIBUTING.md +0 -46
  76. data/.gs/gems/multi_json-1.12.1/LICENSE.md +0 -20
  77. data/.gs/gems/multi_json-1.12.1/README.md +0 -121
  78. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter.rb +0 -49
  79. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter_error.rb +0 -15
  80. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/gson.rb +0 -20
  81. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/jr_jackson.rb +0 -25
  82. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_common.rb +0 -23
  83. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_gem.rb +0 -11
  84. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_pure.rb +0 -11
  85. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/nsjsonserialization.rb +0 -32
  86. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/oj.rb +0 -25
  87. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/ok_json.rb +0 -23
  88. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/yajl.rb +0 -19
  89. data/.gs/gems/multi_json-1.12.1/lib/multi_json/convertible_hash_keys.rb +0 -43
  90. data/.gs/gems/multi_json-1.12.1/lib/multi_json/options.rb +0 -39
  91. data/.gs/gems/multi_json-1.12.1/lib/multi_json/options_cache.rb +0 -29
  92. data/.gs/gems/multi_json-1.12.1/lib/multi_json/parse_error.rb +0 -17
  93. data/.gs/gems/multi_json-1.12.1/lib/multi_json/vendor/okjson.rb +0 -606
  94. data/.gs/gems/multi_json-1.12.1/lib/multi_json/version.rb +0 -17
  95. data/.gs/gems/multi_json-1.12.1/lib/multi_json.rb +0 -161
  96. data/.gs/gems/multi_json-1.12.1/multi_json.gemspec +0 -20
  97. data/.gs/gems/multipart-post-2.0.0/.gitignore +0 -6
  98. data/.gs/gems/multipart-post-2.0.0/.travis.yml +0 -7
  99. data/.gs/gems/multipart-post-2.0.0/Gemfile +0 -14
  100. data/.gs/gems/multipart-post-2.0.0/History.txt +0 -60
  101. data/.gs/gems/multipart-post-2.0.0/Manifest.txt +0 -9
  102. data/.gs/gems/multipart-post-2.0.0/README.md +0 -77
  103. data/.gs/gems/multipart-post-2.0.0/Rakefile +0 -9
  104. data/.gs/gems/multipart-post-2.0.0/lib/composite_io.rb +0 -108
  105. data/.gs/gems/multipart-post-2.0.0/lib/multipart_post.rb +0 -9
  106. data/.gs/gems/multipart-post-2.0.0/lib/multipartable.rb +0 -29
  107. data/.gs/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +0 -27
  108. data/.gs/gems/multipart-post-2.0.0/lib/parts.rb +0 -96
  109. data/.gs/gems/multipart-post-2.0.0/multipart-post.gemspec +0 -22
  110. data/.gs/gems/multipart-post-2.0.0/test/multibyte.txt +0 -1
  111. data/.gs/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +0 -110
  112. data/.gs/gems/multipart-post-2.0.0/test/test_composite_io.rb +0 -115
  113. data/.gs/gems/multipart-post-2.0.0/test/test_parts.rb +0 -86
  114. data/.gs/specifications/faraday-0.9.2.gemspec +0 -31
  115. data/.gs/specifications/minitest-5.9.0.gemspec +0 -39
  116. data/.gs/specifications/multi_json-1.12.1.gemspec +0 -33
  117. data/.gs/specifications/multipart-post-2.0.0.gemspec +0 -22
  118. data/.ruby-version +0 -1
@@ -1,674 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require "rbconfig"
4
- require "tempfile"
5
- require "stringio"
6
-
7
- module Minitest
8
- ##
9
- # Minitest Assertions. All assertion methods accept a +msg+ which is
10
- # printed if the assertion fails.
11
- #
12
- # Protocol: Nearly everything here boils up to +assert+, which
13
- # expects to be able to increment an instance accessor named
14
- # +assertions+. This is not provided by Assertions and must be
15
- # provided by the thing including Assertions. See Minitest::Runnable
16
- # for an example.
17
-
18
- module Assertions
19
- UNDEFINED = Object.new # :nodoc:
20
-
21
- def UNDEFINED.inspect # :nodoc:
22
- "UNDEFINED" # again with the rdoc bugs... :(
23
- end
24
-
25
- ##
26
- # Returns the diff command to use in #diff. Tries to intelligently
27
- # figure out what diff to use.
28
-
29
- def self.diff
30
- @diff = if (RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ &&
31
- system("diff.exe", __FILE__, __FILE__)) then
32
- "diff.exe -u"
33
- elsif Minitest::Test.maglev? then
34
- "diff -u"
35
- elsif system("gdiff", __FILE__, __FILE__)
36
- "gdiff -u" # solaris and kin suck
37
- elsif system("diff", __FILE__, __FILE__)
38
- "diff -u"
39
- else
40
- nil
41
- end unless defined? @diff
42
-
43
- @diff
44
- end
45
-
46
- ##
47
- # Set the diff command to use in #diff.
48
-
49
- def self.diff= o
50
- @diff = o
51
- end
52
-
53
- ##
54
- # Returns a diff between +exp+ and +act+. If there is no known
55
- # diff command or if it doesn't make sense to diff the output
56
- # (single line, short output), then it simply returns a basic
57
- # comparison between the two.
58
-
59
- def diff exp, act
60
- expect = mu_pp_for_diff exp
61
- butwas = mu_pp_for_diff act
62
- result = nil
63
-
64
- need_to_diff =
65
- (expect.include?("\n") ||
66
- butwas.include?("\n") ||
67
- expect.size > 30 ||
68
- butwas.size > 30 ||
69
- expect == butwas) &&
70
- Minitest::Assertions.diff
71
-
72
- return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
73
- need_to_diff
74
-
75
- Tempfile.open("expect") do |a|
76
- a.puts expect
77
- a.flush
78
-
79
- Tempfile.open("butwas") do |b|
80
- b.puts butwas
81
- b.flush
82
-
83
- result = `#{Minitest::Assertions.diff} #{a.path} #{b.path}`
84
- result.sub!(/^\-\-\- .+/, "--- expected")
85
- result.sub!(/^\+\+\+ .+/, "+++ actual")
86
-
87
- if result.empty? then
88
- klass = exp.class
89
- result = [
90
- "No visible difference in the #{klass}#inspect output.\n",
91
- "You should look at the implementation of #== on ",
92
- "#{klass} or its members.\n",
93
- expect,
94
- ].join
95
- end
96
- end
97
- end
98
-
99
- result
100
- end
101
-
102
- ##
103
- # This returns a human-readable version of +obj+. By default
104
- # #inspect is called. You can override this to use #pretty_print
105
- # if you want.
106
-
107
- def mu_pp obj
108
- s = obj.inspect
109
-
110
- if defined? Encoding then
111
- s = s.encode Encoding.default_external
112
-
113
- if String === obj && obj.encoding != Encoding.default_external then
114
- s = "# encoding: #{obj.encoding}\n#{s}"
115
- end
116
- end
117
-
118
- s
119
- end
120
-
121
- ##
122
- # This returns a diff-able human-readable version of +obj+. This
123
- # differs from the regular mu_pp because it expands escaped
124
- # newlines and makes hex-values generic (like object_ids). This
125
- # uses mu_pp to do the first pass and then cleans it up.
126
-
127
- def mu_pp_for_diff obj
128
- mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
129
- end
130
-
131
- ##
132
- # Fails unless +test+ is truthy.
133
-
134
- def assert test, msg = nil
135
- self.assertions += 1
136
- unless test then
137
- msg ||= "Expected #{mu_pp test} to be truthy."
138
- msg = msg.call if Proc === msg
139
- raise Minitest::Assertion, msg
140
- end
141
- true
142
- end
143
-
144
- def _synchronize # :nodoc:
145
- yield
146
- end
147
-
148
- ##
149
- # Fails unless +obj+ is empty.
150
-
151
- def assert_empty obj, msg = nil
152
- msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
153
- assert_respond_to obj, :empty?
154
- assert obj.empty?, msg
155
- end
156
-
157
- E = "" # :nodoc:
158
-
159
- ##
160
- # Fails unless <tt>exp == act</tt> printing the difference between
161
- # the two, if possible.
162
- #
163
- # If there is no visible difference but the assertion fails, you
164
- # should suspect that your #== is buggy, or your inspect output is
165
- # missing crucial details. For nicer structural diffing, set
166
- # Minitest::Test.make_my_diffs_pretty!
167
- #
168
- # For floats use assert_in_delta.
169
- #
170
- # See also: Minitest::Assertions.diff
171
-
172
- def assert_equal exp, act, msg = nil
173
- msg = message(msg, E) { diff exp, act }
174
- assert exp == act, msg
175
- end
176
-
177
- ##
178
- # For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
179
- # of each other.
180
- #
181
- # assert_in_delta Math::PI, (22.0 / 7.0), 0.01
182
-
183
- def assert_in_delta exp, act, delta = 0.001, msg = nil
184
- n = (exp - act).abs
185
- msg = message(msg) {
186
- "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
187
- }
188
- assert delta >= n, msg
189
- end
190
-
191
- ##
192
- # For comparing Floats. Fails unless +exp+ and +act+ have a relative
193
- # error less than +epsilon+.
194
-
195
- def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
196
- assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
197
- end
198
-
199
- ##
200
- # Fails unless +collection+ includes +obj+.
201
-
202
- def assert_includes collection, obj, msg = nil
203
- msg = message(msg) {
204
- "Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
205
- }
206
- assert_respond_to collection, :include?
207
- assert collection.include?(obj), msg
208
- end
209
-
210
- ##
211
- # Fails unless +obj+ is an instance of +cls+.
212
-
213
- def assert_instance_of cls, obj, msg = nil
214
- msg = message(msg) {
215
- "Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
216
- }
217
-
218
- assert obj.instance_of?(cls), msg
219
- end
220
-
221
- ##
222
- # Fails unless +obj+ is a kind of +cls+.
223
-
224
- def assert_kind_of cls, obj, msg = nil
225
- msg = message(msg) {
226
- "Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
227
-
228
- assert obj.kind_of?(cls), msg
229
- end
230
-
231
- ##
232
- # Fails unless +matcher+ <tt>=~</tt> +obj+.
233
-
234
- def assert_match matcher, obj, msg = nil
235
- msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
236
- assert_respond_to matcher, :"=~"
237
- matcher = Regexp.new Regexp.escape matcher if String === matcher
238
- assert matcher =~ obj, msg
239
- end
240
-
241
- ##
242
- # Fails unless +obj+ is nil
243
-
244
- def assert_nil obj, msg = nil
245
- msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
246
- assert obj.nil?, msg
247
- end
248
-
249
- ##
250
- # For testing with binary operators. Eg:
251
- #
252
- # assert_operator 5, :<=, 4
253
-
254
- def assert_operator o1, op, o2 = UNDEFINED, msg = nil
255
- return assert_predicate o1, op, msg if UNDEFINED == o2
256
- msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
257
- assert o1.__send__(op, o2), msg
258
- end
259
-
260
- ##
261
- # Fails if stdout or stderr do not output the expected results.
262
- # Pass in nil if you don't care about that streams output. Pass in
263
- # "" if you require it to be silent. Pass in a regexp if you want
264
- # to pattern match.
265
- #
266
- # assert_output(/hey/) { method_with_output }
267
- #
268
- # NOTE: this uses #capture_io, not #capture_subprocess_io.
269
- #
270
- # See also: #assert_silent
271
-
272
- def assert_output stdout = nil, stderr = nil
273
- out, err = capture_io do
274
- yield
275
- end
276
-
277
- err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
278
- out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
279
-
280
- y = send err_msg, stderr, err, "In stderr" if err_msg
281
- x = send out_msg, stdout, out, "In stdout" if out_msg
282
-
283
- (!stdout || x) && (!stderr || y)
284
- end
285
-
286
- ##
287
- # For testing with predicates. Eg:
288
- #
289
- # assert_predicate str, :empty?
290
- #
291
- # This is really meant for specs and is front-ended by assert_operator:
292
- #
293
- # str.must_be :empty?
294
-
295
- def assert_predicate o1, op, msg = nil
296
- msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
297
- assert o1.__send__(op), msg
298
- end
299
-
300
- ##
301
- # Fails unless the block raises one of +exp+. Returns the
302
- # exception matched so you can check the message, attributes, etc.
303
- #
304
- # +exp+ takes an optional message on the end to help explain
305
- # failures and defaults to StandardError if no exception class is
306
- # passed.
307
-
308
- def assert_raises *exp
309
- msg = "#{exp.pop}.\n" if String === exp.last
310
- exp << StandardError if exp.empty?
311
-
312
- begin
313
- yield
314
- rescue *exp => e
315
- pass # count assertion
316
- return e
317
- rescue Minitest::Skip, Minitest::Assertion
318
- # don't count assertion
319
- raise
320
- rescue SignalException, SystemExit
321
- raise
322
- rescue Exception => e
323
- flunk proc {
324
- exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
325
- }
326
- end
327
-
328
- exp = exp.first if exp.size == 1
329
-
330
- flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
331
- end
332
-
333
- ##
334
- # Fails unless +obj+ responds to +meth+.
335
-
336
- def assert_respond_to obj, meth, msg = nil
337
- msg = message(msg) {
338
- "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
339
- }
340
- assert obj.respond_to?(meth), msg
341
- end
342
-
343
- ##
344
- # Fails unless +exp+ and +act+ are #equal?
345
-
346
- def assert_same exp, act, msg = nil
347
- msg = message(msg) {
348
- data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
349
- "Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
350
- }
351
- assert exp.equal?(act), msg
352
- end
353
-
354
- ##
355
- # +send_ary+ is a receiver, message and arguments.
356
- #
357
- # Fails unless the call returns a true value
358
-
359
- def assert_send send_ary, m = nil
360
- recv, msg, *args = send_ary
361
- m = message(m) {
362
- "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
363
- assert recv.__send__(msg, *args), m
364
- end
365
-
366
- ##
367
- # Fails if the block outputs anything to stderr or stdout.
368
- #
369
- # See also: #assert_output
370
-
371
- def assert_silent
372
- assert_output "", "" do
373
- yield
374
- end
375
- end
376
-
377
- ##
378
- # Fails unless the block throws +sym+
379
-
380
- def assert_throws sym, msg = nil
381
- default = "Expected #{mu_pp(sym)} to have been thrown"
382
- caught = true
383
- catch(sym) do
384
- begin
385
- yield
386
- rescue ThreadError => e # wtf?!? 1.8 + threads == suck
387
- default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
388
- rescue ArgumentError => e # 1.9 exception
389
- default += ", not #{e.message.split(/ /).last}"
390
- rescue NameError => e # 1.8 exception
391
- default += ", not #{e.name.inspect}"
392
- end
393
- caught = false
394
- end
395
-
396
- assert caught, message(msg) { default }
397
- end
398
-
399
- ##
400
- # Captures $stdout and $stderr into strings:
401
- #
402
- # out, err = capture_io do
403
- # puts "Some info"
404
- # warn "You did a bad thing"
405
- # end
406
- #
407
- # assert_match %r%info%, out
408
- # assert_match %r%bad%, err
409
- #
410
- # NOTE: For efficiency, this method uses StringIO and does not
411
- # capture IO for subprocesses. Use #capture_subprocess_io for
412
- # that.
413
-
414
- def capture_io
415
- _synchronize do
416
- begin
417
- captured_stdout, captured_stderr = StringIO.new, StringIO.new
418
-
419
- orig_stdout, orig_stderr = $stdout, $stderr
420
- $stdout, $stderr = captured_stdout, captured_stderr
421
-
422
- yield
423
-
424
- return captured_stdout.string, captured_stderr.string
425
- ensure
426
- $stdout = orig_stdout
427
- $stderr = orig_stderr
428
- end
429
- end
430
- end
431
-
432
- ##
433
- # Captures $stdout and $stderr into strings, using Tempfile to
434
- # ensure that subprocess IO is captured as well.
435
- #
436
- # out, err = capture_subprocess_io do
437
- # system "echo Some info"
438
- # system "echo You did a bad thing 1>&2"
439
- # end
440
- #
441
- # assert_match %r%info%, out
442
- # assert_match %r%bad%, err
443
- #
444
- # NOTE: This method is approximately 10x slower than #capture_io so
445
- # only use it when you need to test the output of a subprocess.
446
-
447
- def capture_subprocess_io
448
- _synchronize do
449
- begin
450
- require "tempfile"
451
-
452
- captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
453
-
454
- orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
455
- $stdout.reopen captured_stdout
456
- $stderr.reopen captured_stderr
457
-
458
- yield
459
-
460
- $stdout.rewind
461
- $stderr.rewind
462
-
463
- return captured_stdout.read, captured_stderr.read
464
- ensure
465
- captured_stdout.unlink
466
- captured_stderr.unlink
467
- $stdout.reopen orig_stdout
468
- $stderr.reopen orig_stderr
469
- end
470
- end
471
- end
472
-
473
- ##
474
- # Returns details for exception +e+
475
-
476
- def exception_details e, msg
477
- [
478
- "#{msg}",
479
- "Class: <#{e.class}>",
480
- "Message: <#{e.message.inspect}>",
481
- "---Backtrace---",
482
- "#{Minitest.filter_backtrace(e.backtrace).join("\n")}",
483
- "---------------",
484
- ].join "\n"
485
- end
486
-
487
- ##
488
- # Fails with +msg+
489
-
490
- def flunk msg = nil
491
- msg ||= "Epic Fail!"
492
- assert false, msg
493
- end
494
-
495
- ##
496
- # Returns a proc that will output +msg+ along with the default message.
497
-
498
- def message msg = nil, ending = nil, &default
499
- proc {
500
- msg = msg.call.chomp(".") if Proc === msg
501
- custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
502
- "#{custom_message}#{default.call}#{ending || "."}"
503
- }
504
- end
505
-
506
- ##
507
- # used for counting assertions
508
-
509
- def pass _msg = nil
510
- assert true
511
- end
512
-
513
- ##
514
- # Fails if +test+ is truthy.
515
-
516
- def refute test, msg = nil
517
- msg ||= message { "Expected #{mu_pp(test)} to not be truthy" }
518
- not assert !test, msg
519
- end
520
-
521
- ##
522
- # Fails if +obj+ is empty.
523
-
524
- def refute_empty obj, msg = nil
525
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
526
- assert_respond_to obj, :empty?
527
- refute obj.empty?, msg
528
- end
529
-
530
- ##
531
- # Fails if <tt>exp == act</tt>.
532
- #
533
- # For floats use refute_in_delta.
534
-
535
- def refute_equal exp, act, msg = nil
536
- msg = message(msg) {
537
- "Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
538
- }
539
- refute exp == act, msg
540
- end
541
-
542
- ##
543
- # For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
544
- #
545
- # refute_in_delta Math::PI, (22.0 / 7.0)
546
-
547
- def refute_in_delta exp, act, delta = 0.001, msg = nil
548
- n = (exp - act).abs
549
- msg = message(msg) {
550
- "Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
551
- }
552
- refute delta >= n, msg
553
- end
554
-
555
- ##
556
- # For comparing Floats. Fails if +exp+ and +act+ have a relative error
557
- # less than +epsilon+.
558
-
559
- def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
560
- refute_in_delta a, b, a * epsilon, msg
561
- end
562
-
563
- ##
564
- # Fails if +collection+ includes +obj+.
565
-
566
- def refute_includes collection, obj, msg = nil
567
- msg = message(msg) {
568
- "Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
569
- }
570
- assert_respond_to collection, :include?
571
- refute collection.include?(obj), msg
572
- end
573
-
574
- ##
575
- # Fails if +obj+ is an instance of +cls+.
576
-
577
- def refute_instance_of cls, obj, msg = nil
578
- msg = message(msg) {
579
- "Expected #{mu_pp(obj)} to not be an instance of #{cls}"
580
- }
581
- refute obj.instance_of?(cls), msg
582
- end
583
-
584
- ##
585
- # Fails if +obj+ is a kind of +cls+.
586
-
587
- def refute_kind_of cls, obj, msg = nil
588
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
589
- refute obj.kind_of?(cls), msg
590
- end
591
-
592
- ##
593
- # Fails if +matcher+ <tt>=~</tt> +obj+.
594
-
595
- def refute_match matcher, obj, msg = nil
596
- msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
597
- assert_respond_to matcher, :"=~"
598
- matcher = Regexp.new Regexp.escape matcher if String === matcher
599
- refute matcher =~ obj, msg
600
- end
601
-
602
- ##
603
- # Fails if +obj+ is nil.
604
-
605
- def refute_nil obj, msg = nil
606
- msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
607
- refute obj.nil?, msg
608
- end
609
-
610
- ##
611
- # Fails if +o1+ is not +op+ +o2+. Eg:
612
- #
613
- # refute_operator 1, :>, 2 #=> pass
614
- # refute_operator 1, :<, 2 #=> fail
615
-
616
- def refute_operator o1, op, o2 = UNDEFINED, msg = nil
617
- return refute_predicate o1, op, msg if UNDEFINED == o2
618
- msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}" }
619
- refute o1.__send__(op, o2), msg
620
- end
621
-
622
- ##
623
- # For testing with predicates.
624
- #
625
- # refute_predicate str, :empty?
626
- #
627
- # This is really meant for specs and is front-ended by refute_operator:
628
- #
629
- # str.wont_be :empty?
630
-
631
- def refute_predicate o1, op, msg = nil
632
- msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
633
- refute o1.__send__(op), msg
634
- end
635
-
636
- ##
637
- # Fails if +obj+ responds to the message +meth+.
638
-
639
- def refute_respond_to obj, meth, msg = nil
640
- msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
641
-
642
- refute obj.respond_to?(meth), msg
643
- end
644
-
645
- ##
646
- # Fails if +exp+ is the same (by object identity) as +act+.
647
-
648
- def refute_same exp, act, msg = nil
649
- msg = message(msg) {
650
- data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
651
- "Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
652
- }
653
- refute exp.equal?(act), msg
654
- end
655
-
656
- ##
657
- # Skips the current run. If run in verbose-mode, the skipped run
658
- # gets listed at the end of the run but doesn't cause a failure
659
- # exit code.
660
-
661
- def skip msg = nil, bt = caller
662
- msg ||= "Skipped, no message given"
663
- @skip = true
664
- raise Minitest::Skip, msg, bt
665
- end
666
-
667
- ##
668
- # Was this testcase skipped? Meant for #teardown.
669
-
670
- def skipped?
671
- defined?(@skip) and @skip
672
- end
673
- end
674
- end
@@ -1,13 +0,0 @@
1
- begin
2
- require "rubygems"
3
- gem "minitest"
4
- rescue Gem::LoadError
5
- # do nothing
6
- end
7
-
8
- require "minitest"
9
- require "minitest/spec"
10
- require "minitest/mock"
11
- require "minitest/hell" if ENV["MT_HELL"]
12
-
13
- Minitest.autorun