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.
- checksums.yaml +5 -5
- data/.gs/bin/rake +12 -8
- data/.gs/specifications/rake-10.5.0.gemspec +24 -28
- data/.tool-versions +1 -0
- data/lib/mercadopago/custom_checkout/version.rb +1 -1
- data/mercadopago-custom-checkout.gemspec +3 -3
- metadata +14 -125
- data/.gs/cache/faraday-0.9.2.gem +0 -0
- data/.gs/cache/minitest-5.9.0.gem +0 -0
- data/.gs/cache/multi_json-1.12.1.gem +0 -0
- data/.gs/cache/multipart-post-2.0.0.gem +0 -0
- data/.gs/gems/faraday-0.9.2/LICENSE.md +0 -20
- data/.gs/gems/faraday-0.9.2/README.md +0 -245
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http.rb +0 -237
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http_ssl_patch.rb +0 -56
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -66
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony.rb +0 -100
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/excon.rb +0 -81
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/httpclient.rb +0 -117
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb +0 -130
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http_persistent.rb +0 -49
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/patron.rb +0 -78
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/rack.rb +0 -58
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/test.rb +0 -162
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/typhoeus.rb +0 -123
- data/.gs/gems/faraday-0.9.2/lib/faraday/adapter.rb +0 -46
- data/.gs/gems/faraday-0.9.2/lib/faraday/autoload.rb +0 -84
- data/.gs/gems/faraday-0.9.2/lib/faraday/connection.rb +0 -437
- data/.gs/gems/faraday-0.9.2/lib/faraday/error.rb +0 -53
- data/.gs/gems/faraday-0.9.2/lib/faraday/middleware.rb +0 -37
- data/.gs/gems/faraday-0.9.2/lib/faraday/options.rb +0 -359
- data/.gs/gems/faraday-0.9.2/lib/faraday/parameters.rb +0 -197
- data/.gs/gems/faraday-0.9.2/lib/faraday/rack_builder.rb +0 -213
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/authorization.rb +0 -42
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/basic_authentication.rb +0 -13
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/instrumentation.rb +0 -36
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/multipart.rb +0 -63
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/retry.rb +0 -154
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/token_authentication.rb +0 -15
- data/.gs/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb +0 -36
- data/.gs/gems/faraday-0.9.2/lib/faraday/request.rb +0 -92
- data/.gs/gems/faraday-0.9.2/lib/faraday/response/logger.rb +0 -59
- data/.gs/gems/faraday-0.9.2/lib/faraday/response/raise_error.rb +0 -21
- data/.gs/gems/faraday-0.9.2/lib/faraday/response.rb +0 -93
- data/.gs/gems/faraday-0.9.2/lib/faraday/upload_io.rb +0 -67
- data/.gs/gems/faraday-0.9.2/lib/faraday/utils.rb +0 -309
- data/.gs/gems/faraday-0.9.2/lib/faraday.rb +0 -268
- data/.gs/gems/minitest-5.9.0/.autotest +0 -34
- data/.gs/gems/minitest-5.9.0/History.rdoc +0 -1176
- data/.gs/gems/minitest-5.9.0/Manifest.txt +0 -26
- data/.gs/gems/minitest-5.9.0/README.rdoc +0 -656
- data/.gs/gems/minitest-5.9.0/Rakefile +0 -72
- data/.gs/gems/minitest-5.9.0/design_rationale.rb +0 -52
- data/.gs/gems/minitest-5.9.0/lib/hoe/minitest.rb +0 -26
- data/.gs/gems/minitest-5.9.0/lib/minitest/assertions.rb +0 -674
- data/.gs/gems/minitest-5.9.0/lib/minitest/autorun.rb +0 -13
- data/.gs/gems/minitest-5.9.0/lib/minitest/benchmark.rb +0 -424
- data/.gs/gems/minitest-5.9.0/lib/minitest/expectations.rb +0 -284
- data/.gs/gems/minitest-5.9.0/lib/minitest/hell.rb +0 -17
- data/.gs/gems/minitest-5.9.0/lib/minitest/mock.rb +0 -232
- data/.gs/gems/minitest-5.9.0/lib/minitest/parallel.rb +0 -69
- data/.gs/gems/minitest-5.9.0/lib/minitest/pride.rb +0 -4
- data/.gs/gems/minitest-5.9.0/lib/minitest/pride_plugin.rb +0 -142
- data/.gs/gems/minitest-5.9.0/lib/minitest/spec.rb +0 -331
- data/.gs/gems/minitest-5.9.0/lib/minitest/test.rb +0 -284
- data/.gs/gems/minitest-5.9.0/lib/minitest/unit.rb +0 -45
- data/.gs/gems/minitest-5.9.0/lib/minitest.rb +0 -815
- data/.gs/gems/minitest-5.9.0/test/minitest/metametameta.rb +0 -90
- data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_benchmark.rb +0 -137
- data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_mock.rb +0 -512
- data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_reporter.rb +0 -281
- data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_spec.rb +0 -967
- data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_test.rb +0 -1983
- data/.gs/gems/multi_json-1.12.1/CHANGELOG.md +0 -245
- data/.gs/gems/multi_json-1.12.1/CONTRIBUTING.md +0 -46
- data/.gs/gems/multi_json-1.12.1/LICENSE.md +0 -20
- data/.gs/gems/multi_json-1.12.1/README.md +0 -121
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter.rb +0 -49
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter_error.rb +0 -15
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/gson.rb +0 -20
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/jr_jackson.rb +0 -25
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_common.rb +0 -23
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_gem.rb +0 -11
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_pure.rb +0 -11
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/nsjsonserialization.rb +0 -32
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/oj.rb +0 -25
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/ok_json.rb +0 -23
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/yajl.rb +0 -19
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/convertible_hash_keys.rb +0 -43
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/options.rb +0 -39
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/options_cache.rb +0 -29
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/parse_error.rb +0 -17
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/vendor/okjson.rb +0 -606
- data/.gs/gems/multi_json-1.12.1/lib/multi_json/version.rb +0 -17
- data/.gs/gems/multi_json-1.12.1/lib/multi_json.rb +0 -161
- data/.gs/gems/multi_json-1.12.1/multi_json.gemspec +0 -20
- data/.gs/gems/multipart-post-2.0.0/.gitignore +0 -6
- data/.gs/gems/multipart-post-2.0.0/.travis.yml +0 -7
- data/.gs/gems/multipart-post-2.0.0/Gemfile +0 -14
- data/.gs/gems/multipart-post-2.0.0/History.txt +0 -60
- data/.gs/gems/multipart-post-2.0.0/Manifest.txt +0 -9
- data/.gs/gems/multipart-post-2.0.0/README.md +0 -77
- data/.gs/gems/multipart-post-2.0.0/Rakefile +0 -9
- data/.gs/gems/multipart-post-2.0.0/lib/composite_io.rb +0 -108
- data/.gs/gems/multipart-post-2.0.0/lib/multipart_post.rb +0 -9
- data/.gs/gems/multipart-post-2.0.0/lib/multipartable.rb +0 -29
- data/.gs/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +0 -27
- data/.gs/gems/multipart-post-2.0.0/lib/parts.rb +0 -96
- data/.gs/gems/multipart-post-2.0.0/multipart-post.gemspec +0 -22
- data/.gs/gems/multipart-post-2.0.0/test/multibyte.txt +0 -1
- data/.gs/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +0 -110
- data/.gs/gems/multipart-post-2.0.0/test/test_composite_io.rb +0 -115
- data/.gs/gems/multipart-post-2.0.0/test/test_parts.rb +0 -86
- data/.gs/specifications/faraday-0.9.2.gemspec +0 -31
- data/.gs/specifications/minitest-5.9.0.gemspec +0 -39
- data/.gs/specifications/multi_json-1.12.1.gemspec +0 -33
- data/.gs/specifications/multipart-post-2.0.0.gemspec +0 -22
- data/.ruby-version +0 -1
@@ -1,967 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "minitest/autorun"
|
3
|
-
require "stringio"
|
4
|
-
|
5
|
-
class MiniSpecA < Minitest::Spec; end
|
6
|
-
class MiniSpecB < Minitest::Test; 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
|
11
|
-
class ExampleA; end
|
12
|
-
class ExampleB < ExampleA; end
|
13
|
-
|
14
|
-
describe Minitest::Spec do
|
15
|
-
# do not parallelize this suite... it just can"t handle it.
|
16
|
-
|
17
|
-
def assert_triggered expected = "blah", klass = Minitest::Assertion
|
18
|
-
@assertion_count += 1
|
19
|
-
|
20
|
-
e = assert_raises(klass) do
|
21
|
-
yield
|
22
|
-
end
|
23
|
-
|
24
|
-
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
25
|
-
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
26
|
-
msg.gsub!(/@.+>/, "@PATH>")
|
27
|
-
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
28
|
-
msg.gsub!(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
|
29
|
-
|
30
|
-
if expected
|
31
|
-
@assertion_count += 1
|
32
|
-
case expected
|
33
|
-
when String then
|
34
|
-
assert_equal expected, msg
|
35
|
-
when Regexp then
|
36
|
-
@assertion_count += 1
|
37
|
-
assert_match expected, msg
|
38
|
-
else
|
39
|
-
flunk "Unknown: #{expected.inspect}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
before do
|
45
|
-
@assertion_count = 4
|
46
|
-
end
|
47
|
-
|
48
|
-
after do
|
49
|
-
_(self.assertions).must_equal @assertion_count if passed? and not skipped?
|
50
|
-
end
|
51
|
-
|
52
|
-
it "needs to be able to catch a Minitest::Assertion exception" do
|
53
|
-
@assertion_count = 1
|
54
|
-
|
55
|
-
assert_triggered "Expected 1 to not be equal to 1." do
|
56
|
-
1.wont_equal 1
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
it "needs to be sensible about must_include order" do
|
61
|
-
@assertion_count += 3 # must_include is 2 assertions
|
62
|
-
|
63
|
-
[1, 2, 3].must_include(2).must_equal true
|
64
|
-
|
65
|
-
assert_triggered "Expected [1, 2, 3] to include 5." do
|
66
|
-
[1, 2, 3].must_include 5
|
67
|
-
end
|
68
|
-
|
69
|
-
assert_triggered "msg.\nExpected [1, 2, 3] to include 5." do
|
70
|
-
[1, 2, 3].must_include 5, "msg"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
it "needs to be sensible about wont_include order" do
|
75
|
-
@assertion_count += 3 # wont_include is 2 assertions
|
76
|
-
|
77
|
-
[1, 2, 3].wont_include(5).must_equal false
|
78
|
-
|
79
|
-
assert_triggered "Expected [1, 2, 3] to not include 2." do
|
80
|
-
[1, 2, 3].wont_include 2
|
81
|
-
end
|
82
|
-
|
83
|
-
assert_triggered "msg.\nExpected [1, 2, 3] to not include 2." do
|
84
|
-
[1, 2, 3].wont_include 2, "msg"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "needs to catch an expected exception" do
|
89
|
-
@assertion_count = 2
|
90
|
-
|
91
|
-
proc { raise "blah" }.must_raise RuntimeError
|
92
|
-
proc { raise Minitest::Assertion }.must_raise Minitest::Assertion
|
93
|
-
end
|
94
|
-
|
95
|
-
it "needs to catch an unexpected exception" do
|
96
|
-
@assertion_count -= 2 # no positive
|
97
|
-
|
98
|
-
msg = <<-EOM.gsub(/^ {6}/, "").chomp
|
99
|
-
[RuntimeError] exception expected, not
|
100
|
-
Class: <StandardError>
|
101
|
-
Message: <"woot">
|
102
|
-
---Backtrace---
|
103
|
-
EOM
|
104
|
-
|
105
|
-
assert_triggered msg do
|
106
|
-
proc { raise StandardError, "woot" }.must_raise RuntimeError
|
107
|
-
end
|
108
|
-
|
109
|
-
assert_triggered "msg.\n#{msg}" do
|
110
|
-
proc { raise StandardError, "woot" }.must_raise RuntimeError, "msg"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it "needs to ensure silence" do
|
115
|
-
@assertion_count -= 1 # no msg
|
116
|
-
@assertion_count += 2 # assert_output is 2 assertions
|
117
|
-
|
118
|
-
proc { }.must_be_silent.must_equal true
|
119
|
-
|
120
|
-
assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
|
121
|
-
proc { print "xxx" }.must_be_silent
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "needs to have all methods named well" do
|
126
|
-
@assertion_count = 2
|
127
|
-
|
128
|
-
methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
|
129
|
-
methods.map!(&:to_s) if Symbol === methods.first
|
130
|
-
|
131
|
-
musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
|
132
|
-
|
133
|
-
expected_musts = %w[must_be
|
134
|
-
must_be_close_to
|
135
|
-
must_be_empty
|
136
|
-
must_be_instance_of
|
137
|
-
must_be_kind_of
|
138
|
-
must_be_nil
|
139
|
-
must_be_same_as
|
140
|
-
must_be_silent
|
141
|
-
must_be_within_delta
|
142
|
-
must_be_within_epsilon
|
143
|
-
must_equal
|
144
|
-
must_include
|
145
|
-
must_match
|
146
|
-
must_output
|
147
|
-
must_raise
|
148
|
-
must_respond_to
|
149
|
-
must_throw]
|
150
|
-
|
151
|
-
bad = %w[not raise throw send output be_silent]
|
152
|
-
|
153
|
-
expected_wonts = expected_musts.map { |m| m.sub(/^must/, "wont") }
|
154
|
-
expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
|
155
|
-
|
156
|
-
musts.must_equal expected_musts
|
157
|
-
wonts.must_equal expected_wonts
|
158
|
-
end
|
159
|
-
|
160
|
-
it "needs to raise if an expected exception is not raised" do
|
161
|
-
@assertion_count -= 2 # no positive test
|
162
|
-
|
163
|
-
assert_triggered "RuntimeError expected but nothing was raised." do
|
164
|
-
proc { 42 }.must_raise RuntimeError
|
165
|
-
end
|
166
|
-
|
167
|
-
assert_triggered "msg.\nRuntimeError expected but nothing was raised." do
|
168
|
-
proc { 42 }.must_raise RuntimeError, "msg"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
it "needs to verify binary messages" do
|
173
|
-
42.wont_be(:<, 24).must_equal false
|
174
|
-
|
175
|
-
assert_triggered "Expected 24 to not be < 42." do
|
176
|
-
24.wont_be :<, 42
|
177
|
-
end
|
178
|
-
|
179
|
-
assert_triggered "msg.\nExpected 24 to not be < 42." do
|
180
|
-
24.wont_be :<, 42, "msg"
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
it "needs to verify emptyness" do
|
185
|
-
@assertion_count += 3 # empty is 2 assertions
|
186
|
-
|
187
|
-
[].must_be_empty.must_equal true
|
188
|
-
|
189
|
-
assert_triggered "Expected [42] to be empty." do
|
190
|
-
[42].must_be_empty
|
191
|
-
end
|
192
|
-
|
193
|
-
assert_triggered "msg.\nExpected [42] to be empty." do
|
194
|
-
[42].must_be_empty "msg"
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
it "needs to verify equality" do
|
199
|
-
@assertion_count += 1
|
200
|
-
|
201
|
-
(6 * 7).must_equal(42).must_equal true
|
202
|
-
|
203
|
-
assert_triggered "Expected: 42\n Actual: 54" do
|
204
|
-
(6 * 9).must_equal 42
|
205
|
-
end
|
206
|
-
|
207
|
-
assert_triggered "msg.\nExpected: 42\n Actual: 54" do
|
208
|
-
(6 * 9).must_equal 42, "msg"
|
209
|
-
end
|
210
|
-
|
211
|
-
assert_triggered(/^-42\n\+#<Proc:0xXXXXXX@PATH>\n/) do
|
212
|
-
proc { 42 }.must_equal 42 # proc isn't called, so expectation fails
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
it "needs to verify floats outside a delta" do
|
217
|
-
@assertion_count += 1 # extra test
|
218
|
-
|
219
|
-
24.wont_be_close_to(42).must_equal false
|
220
|
-
|
221
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.001." do
|
222
|
-
(6 * 7.0).wont_be_close_to 42
|
223
|
-
end
|
224
|
-
|
225
|
-
x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
|
226
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
227
|
-
(6 * 7.0).wont_be_close_to 42, 0.00001
|
228
|
-
end
|
229
|
-
|
230
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
|
231
|
-
(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
it "needs to verify floats outside an epsilon" do
|
236
|
-
@assertion_count += 1 # extra test
|
237
|
-
|
238
|
-
24.wont_be_within_epsilon(42).must_equal false
|
239
|
-
|
240
|
-
x = maglev? ? "0.042000000000000003" : "0.042"
|
241
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
242
|
-
(6 * 7.0).wont_be_within_epsilon 42
|
243
|
-
end
|
244
|
-
|
245
|
-
x = maglev? ? "0.00042000000000000002" : "0.00042"
|
246
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
247
|
-
(6 * 7.0).wont_be_within_epsilon 42, 0.00001
|
248
|
-
end
|
249
|
-
|
250
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
|
251
|
-
(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
it "needs to verify floats within a delta" do
|
256
|
-
@assertion_count += 1 # extra test
|
257
|
-
|
258
|
-
(6.0 * 7).must_be_close_to(42.0).must_equal true
|
259
|
-
|
260
|
-
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.001." do
|
261
|
-
(1.0 / 100).must_be_close_to 0.0
|
262
|
-
end
|
263
|
-
|
264
|
-
x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
|
265
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
266
|
-
(1.0 / 1000).must_be_close_to 0.0, 0.000001
|
267
|
-
end
|
268
|
-
|
269
|
-
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
270
|
-
(1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
it "needs to verify floats within an epsilon" do
|
275
|
-
@assertion_count += 1 # extra test
|
276
|
-
|
277
|
-
(6.0 * 7).must_be_within_epsilon(42.0).must_equal true
|
278
|
-
|
279
|
-
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.0." do
|
280
|
-
(1.0 / 100).must_be_within_epsilon 0.0
|
281
|
-
end
|
282
|
-
|
283
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 0.0." do
|
284
|
-
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001
|
285
|
-
end
|
286
|
-
|
287
|
-
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 0.0." do
|
288
|
-
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001, "msg"
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
it "needs to verify identity" do
|
293
|
-
1.must_be_same_as(1).must_equal true
|
294
|
-
|
295
|
-
assert_triggered "Expected 1 (oid=N) to be the same as 2 (oid=N)." do
|
296
|
-
1.must_be_same_as 2
|
297
|
-
end
|
298
|
-
|
299
|
-
assert_triggered "msg.\nExpected 1 (oid=N) to be the same as 2 (oid=N)." do
|
300
|
-
1.must_be_same_as 2, "msg"
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
it "needs to verify inequality" do
|
305
|
-
@assertion_count += 2
|
306
|
-
42.wont_equal(6 * 9).must_equal false
|
307
|
-
proc{}.wont_equal(42).must_equal false
|
308
|
-
|
309
|
-
assert_triggered "Expected 1 to not be equal to 1." do
|
310
|
-
1.wont_equal 1
|
311
|
-
end
|
312
|
-
|
313
|
-
assert_triggered "msg.\nExpected 1 to not be equal to 1." do
|
314
|
-
1.wont_equal 1, "msg"
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
it "needs to verify instances of a class" do
|
319
|
-
42.wont_be_instance_of(String).must_equal false
|
320
|
-
|
321
|
-
assert_triggered "Expected 42 to not be an instance of Fixnum." do
|
322
|
-
42.wont_be_instance_of Fixnum
|
323
|
-
end
|
324
|
-
|
325
|
-
assert_triggered "msg.\nExpected 42 to not be an instance of Fixnum." do
|
326
|
-
42.wont_be_instance_of Fixnum, "msg"
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
it "needs to verify kinds of a class" do
|
331
|
-
@assertion_count += 2
|
332
|
-
|
333
|
-
42.wont_be_kind_of(String).must_equal false
|
334
|
-
proc{}.wont_be_kind_of(String).must_equal false
|
335
|
-
|
336
|
-
assert_triggered "Expected 42 to not be a kind of Integer." do
|
337
|
-
42.wont_be_kind_of Integer
|
338
|
-
end
|
339
|
-
|
340
|
-
assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
|
341
|
-
42.wont_be_kind_of Integer, "msg"
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
it "needs to verify kinds of objects" do
|
346
|
-
@assertion_count += 3 # extra test
|
347
|
-
|
348
|
-
(6 * 7).must_be_kind_of(Fixnum).must_equal true
|
349
|
-
(6 * 7).must_be_kind_of(Numeric).must_equal true
|
350
|
-
|
351
|
-
assert_triggered "Expected 42 to be a kind of String, not Fixnum." do
|
352
|
-
(6 * 7).must_be_kind_of String
|
353
|
-
end
|
354
|
-
|
355
|
-
assert_triggered "msg.\nExpected 42 to be a kind of String, not Fixnum." do
|
356
|
-
(6 * 7).must_be_kind_of String, "msg"
|
357
|
-
end
|
358
|
-
|
359
|
-
exp = "Expected #<Proc:0xXXXXXX@PATH> to be a kind of String, not Proc."
|
360
|
-
assert_triggered exp do
|
361
|
-
proc{}.must_be_kind_of String
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
it "needs to verify mismatch" do
|
366
|
-
@assertion_count += 3 # match is 2
|
367
|
-
|
368
|
-
"blah".wont_match(/\d+/).must_equal false
|
369
|
-
|
370
|
-
assert_triggered "Expected /\\w+/ to not match \"blah\"." do
|
371
|
-
"blah".wont_match(/\w+/)
|
372
|
-
end
|
373
|
-
|
374
|
-
assert_triggered "msg.\nExpected /\\w+/ to not match \"blah\"." do
|
375
|
-
"blah".wont_match(/\w+/, "msg")
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
it "needs to verify nil" do
|
380
|
-
nil.must_be_nil.must_equal true
|
381
|
-
|
382
|
-
assert_triggered "Expected 42 to be nil." do
|
383
|
-
42.must_be_nil
|
384
|
-
end
|
385
|
-
|
386
|
-
assert_triggered "msg.\nExpected 42 to be nil." do
|
387
|
-
42.must_be_nil "msg"
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
it "needs to verify non-emptyness" do
|
392
|
-
@assertion_count += 3 # empty is 2 assertions
|
393
|
-
|
394
|
-
["some item"].wont_be_empty.must_equal false
|
395
|
-
|
396
|
-
assert_triggered "Expected [] to not be empty." do
|
397
|
-
[].wont_be_empty
|
398
|
-
end
|
399
|
-
|
400
|
-
assert_triggered "msg.\nExpected [] to not be empty." do
|
401
|
-
[].wont_be_empty "msg"
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
it "needs to verify non-identity" do
|
406
|
-
1.wont_be_same_as(2).must_equal false
|
407
|
-
|
408
|
-
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
409
|
-
1.wont_be_same_as 1
|
410
|
-
end
|
411
|
-
|
412
|
-
assert_triggered "msg.\nExpected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
413
|
-
1.wont_be_same_as 1, "msg"
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
it "needs to verify non-nil" do
|
418
|
-
42.wont_be_nil.must_equal false
|
419
|
-
|
420
|
-
assert_triggered "Expected nil to not be nil." do
|
421
|
-
nil.wont_be_nil
|
422
|
-
end
|
423
|
-
|
424
|
-
assert_triggered "msg.\nExpected nil to not be nil." do
|
425
|
-
nil.wont_be_nil "msg"
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
it "needs to verify objects not responding to a message" do
|
430
|
-
"".wont_respond_to(:woot!).must_equal false
|
431
|
-
|
432
|
-
assert_triggered "Expected \"\" to not respond to to_s." do
|
433
|
-
"".wont_respond_to :to_s
|
434
|
-
end
|
435
|
-
|
436
|
-
assert_triggered "msg.\nExpected \"\" to not respond to to_s." do
|
437
|
-
"".wont_respond_to :to_s, "msg"
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
it "needs to verify output in stderr" do
|
442
|
-
@assertion_count -= 1 # no msg
|
443
|
-
|
444
|
-
proc { $stderr.print "blah" }.must_output(nil, "blah").must_equal true
|
445
|
-
|
446
|
-
assert_triggered "In stderr.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
447
|
-
proc { $stderr.print "xxx" }.must_output(nil, "blah")
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
it "needs to verify output in stdout" do
|
452
|
-
@assertion_count -= 1 # no msg
|
453
|
-
|
454
|
-
proc { print "blah" }.must_output("blah").must_equal true
|
455
|
-
|
456
|
-
assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
457
|
-
proc { print "xxx" }.must_output("blah")
|
458
|
-
end
|
459
|
-
end
|
460
|
-
|
461
|
-
it "needs to verify regexp matches" do
|
462
|
-
@assertion_count += 3 # must_match is 2 assertions
|
463
|
-
|
464
|
-
"blah".must_match(/\w+/).must_equal true
|
465
|
-
|
466
|
-
assert_triggered "Expected /\\d+/ to match \"blah\"." do
|
467
|
-
"blah".must_match(/\d+/)
|
468
|
-
end
|
469
|
-
|
470
|
-
assert_triggered "msg.\nExpected /\\d+/ to match \"blah\"." do
|
471
|
-
"blah".must_match(/\d+/, "msg")
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
|
-
describe "expect" do
|
476
|
-
before do
|
477
|
-
@assertion_count -= 3
|
478
|
-
end
|
479
|
-
|
480
|
-
it "can use expect" do
|
481
|
-
_(1 + 1).must_equal 2
|
482
|
-
end
|
483
|
-
|
484
|
-
it "can use expect with a lambda" do
|
485
|
-
_ { raise "blah" }.must_raise RuntimeError
|
486
|
-
end
|
487
|
-
|
488
|
-
it "can use expect in a thread" do
|
489
|
-
Thread.new { _(1 + 1).must_equal 2 }.join
|
490
|
-
end
|
491
|
-
|
492
|
-
it "can NOT use must_equal in a thread. It must use expect in a thread" do
|
493
|
-
assert_raises NoMethodError do
|
494
|
-
Thread.new { (1 + 1).must_equal 2 }.join
|
495
|
-
end
|
496
|
-
end
|
497
|
-
end
|
498
|
-
|
499
|
-
it "needs to verify throw" do
|
500
|
-
@assertion_count += 2 # 2 extra tests
|
501
|
-
|
502
|
-
proc { throw :blah }.must_throw(:blah).must_equal true
|
503
|
-
|
504
|
-
assert_triggered "Expected :blah to have been thrown." do
|
505
|
-
proc { }.must_throw :blah
|
506
|
-
end
|
507
|
-
|
508
|
-
assert_triggered "Expected :blah to have been thrown, not :xxx." do
|
509
|
-
proc { throw :xxx }.must_throw :blah
|
510
|
-
end
|
511
|
-
|
512
|
-
assert_triggered "msg.\nExpected :blah to have been thrown." do
|
513
|
-
proc { }.must_throw :blah, "msg"
|
514
|
-
end
|
515
|
-
|
516
|
-
assert_triggered "msg.\nExpected :blah to have been thrown, not :xxx." do
|
517
|
-
proc { throw :xxx }.must_throw :blah, "msg"
|
518
|
-
end
|
519
|
-
end
|
520
|
-
|
521
|
-
it "needs to verify types of objects" do
|
522
|
-
(6 * 7).must_be_instance_of(Fixnum).must_equal true
|
523
|
-
|
524
|
-
exp = "Expected 42 to be an instance of String, not Fixnum."
|
525
|
-
|
526
|
-
assert_triggered exp do
|
527
|
-
(6 * 7).must_be_instance_of String
|
528
|
-
end
|
529
|
-
|
530
|
-
assert_triggered "msg.\n#{exp}" do
|
531
|
-
(6 * 7).must_be_instance_of String, "msg"
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
it "needs to verify using any (negative) predicate" do
|
536
|
-
@assertion_count -= 1 # doesn"t take a message
|
537
|
-
|
538
|
-
"blah".wont_be(:empty?).must_equal false
|
539
|
-
|
540
|
-
assert_triggered "Expected \"\" to not be empty?." do
|
541
|
-
"".wont_be :empty?
|
542
|
-
end
|
543
|
-
end
|
544
|
-
|
545
|
-
it "needs to verify using any binary operator" do
|
546
|
-
@assertion_count -= 1 # no msg
|
547
|
-
|
548
|
-
41.must_be(:<, 42).must_equal true
|
549
|
-
|
550
|
-
assert_triggered "Expected 42 to be < 41." do
|
551
|
-
42.must_be(:<, 41)
|
552
|
-
end
|
553
|
-
end
|
554
|
-
|
555
|
-
it "needs to verify using any predicate" do
|
556
|
-
@assertion_count -= 1 # no msg
|
557
|
-
|
558
|
-
"".must_be(:empty?).must_equal true
|
559
|
-
|
560
|
-
assert_triggered "Expected \"blah\" to be empty?." do
|
561
|
-
"blah".must_be :empty?
|
562
|
-
end
|
563
|
-
end
|
564
|
-
|
565
|
-
it "needs to verify using respond_to" do
|
566
|
-
42.must_respond_to(:+).must_equal true
|
567
|
-
|
568
|
-
assert_triggered "Expected 42 (Fixnum) to respond to #clear." do
|
569
|
-
42.must_respond_to :clear
|
570
|
-
end
|
571
|
-
|
572
|
-
assert_triggered "msg.\nExpected 42 (Fixnum) to respond to #clear." do
|
573
|
-
42.must_respond_to :clear, "msg"
|
574
|
-
end
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
describe Minitest::Spec, :let do
|
579
|
-
i_suck_and_my_tests_are_order_dependent!
|
580
|
-
|
581
|
-
def _count
|
582
|
-
$let_count ||= 0
|
583
|
-
end
|
584
|
-
|
585
|
-
let :count do
|
586
|
-
$let_count += 1
|
587
|
-
$let_count
|
588
|
-
end
|
589
|
-
|
590
|
-
it "is evaluated once per example" do
|
591
|
-
_count.must_equal 0
|
592
|
-
|
593
|
-
count.must_equal 1
|
594
|
-
count.must_equal 1
|
595
|
-
|
596
|
-
_count.must_equal 1
|
597
|
-
end
|
598
|
-
|
599
|
-
it "is REALLY evaluated once per example" do
|
600
|
-
_count.must_equal 1
|
601
|
-
|
602
|
-
count.must_equal 2
|
603
|
-
count.must_equal 2
|
604
|
-
|
605
|
-
_count.must_equal 2
|
606
|
-
end
|
607
|
-
|
608
|
-
it 'raises an error if the name begins with "test"' do
|
609
|
-
proc { self.class.let(:test_value) { true } }.must_raise ArgumentError
|
610
|
-
end
|
611
|
-
|
612
|
-
it "raises an error if the name shadows a normal instance method" do
|
613
|
-
proc { self.class.let(:message) { true } }.must_raise ArgumentError
|
614
|
-
end
|
615
|
-
|
616
|
-
it "doesn't raise an error if it is just another let" do
|
617
|
-
proc do
|
618
|
-
describe :outer do
|
619
|
-
let(:bar)
|
620
|
-
describe :inner do
|
621
|
-
let(:bar)
|
622
|
-
end
|
623
|
-
end
|
624
|
-
:good
|
625
|
-
end.call.must_equal :good
|
626
|
-
end
|
627
|
-
|
628
|
-
it "procs come after dont_flip" do
|
629
|
-
p = proc { }
|
630
|
-
assert_respond_to p, :call
|
631
|
-
p.must_respond_to :call
|
632
|
-
end
|
633
|
-
end
|
634
|
-
|
635
|
-
describe Minitest::Spec, :subject do
|
636
|
-
attr_reader :subject_evaluation_count
|
637
|
-
|
638
|
-
subject do
|
639
|
-
@subject_evaluation_count ||= 0
|
640
|
-
@subject_evaluation_count += 1
|
641
|
-
@subject_evaluation_count
|
642
|
-
end
|
643
|
-
|
644
|
-
it "is evaluated once per example" do
|
645
|
-
subject.must_equal 1
|
646
|
-
subject.must_equal 1
|
647
|
-
subject_evaluation_count.must_equal 1
|
648
|
-
end
|
649
|
-
end
|
650
|
-
|
651
|
-
class TestMetaStatic < Minitest::Test
|
652
|
-
def test_children
|
653
|
-
Minitest::Spec.children.clear # prevents parallel run
|
654
|
-
|
655
|
-
y = z = nil
|
656
|
-
x = describe "top-level thingy" do
|
657
|
-
y = describe "first thingy" do end
|
658
|
-
|
659
|
-
it "top-level-it" do end
|
660
|
-
|
661
|
-
z = describe "second thingy" do end
|
662
|
-
end
|
663
|
-
|
664
|
-
assert_equal [x], Minitest::Spec.children
|
665
|
-
assert_equal [y, z], x.children
|
666
|
-
assert_equal [], y.children
|
667
|
-
assert_equal [], z.children
|
668
|
-
end
|
669
|
-
|
670
|
-
def test_it_wont_remove_existing_child_test_methods
|
671
|
-
Minitest::Spec.children.clear # prevents parallel run
|
672
|
-
|
673
|
-
inner = nil
|
674
|
-
outer = describe "outer" do
|
675
|
-
inner = describe "inner" do
|
676
|
-
it do
|
677
|
-
assert true
|
678
|
-
end
|
679
|
-
end
|
680
|
-
it do
|
681
|
-
assert true
|
682
|
-
end
|
683
|
-
end
|
684
|
-
|
685
|
-
assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
|
686
|
-
assert_equal 1, inner.public_instance_methods.grep(/^test_/).count
|
687
|
-
end
|
688
|
-
|
689
|
-
def test_it_wont_add_test_methods_to_children
|
690
|
-
Minitest::Spec.children.clear # prevents parallel run
|
691
|
-
|
692
|
-
inner = nil
|
693
|
-
outer = describe "outer" do
|
694
|
-
inner = describe "inner" do end
|
695
|
-
it do
|
696
|
-
assert true
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
|
701
|
-
assert_equal 0, inner.public_instance_methods.grep(/^test_/).count
|
702
|
-
end
|
703
|
-
end
|
704
|
-
|
705
|
-
require "minitest/metametameta"
|
706
|
-
|
707
|
-
class TestMeta < MetaMetaMetaTestCase
|
708
|
-
parallelize_me!
|
709
|
-
|
710
|
-
def util_structure
|
711
|
-
y = z = nil
|
712
|
-
before_list = []
|
713
|
-
after_list = []
|
714
|
-
x = describe "top-level thingy" do
|
715
|
-
before { before_list << 1 }
|
716
|
-
after { after_list << 1 }
|
717
|
-
|
718
|
-
it "top-level-it" do end
|
719
|
-
|
720
|
-
y = describe "inner thingy" do
|
721
|
-
before { before_list << 2 }
|
722
|
-
after { after_list << 2 }
|
723
|
-
it "inner-it" do end
|
724
|
-
|
725
|
-
z = describe "very inner thingy" do
|
726
|
-
before { before_list << 3 }
|
727
|
-
after { after_list << 3 }
|
728
|
-
it "inner-it" do end
|
729
|
-
|
730
|
-
it { } # ignore me
|
731
|
-
specify { } # anonymous it
|
732
|
-
end
|
733
|
-
end
|
734
|
-
end
|
735
|
-
|
736
|
-
return x, y, z, before_list, after_list
|
737
|
-
end
|
738
|
-
|
739
|
-
def test_register_spec_type
|
740
|
-
original_types = Minitest::Spec::TYPES.dup
|
741
|
-
|
742
|
-
assert_includes Minitest::Spec::TYPES, [//, Minitest::Spec]
|
743
|
-
|
744
|
-
Minitest::Spec.register_spec_type(/woot/, TestMeta)
|
745
|
-
|
746
|
-
p = lambda do |_| true end
|
747
|
-
Minitest::Spec.register_spec_type TestMeta, &p
|
748
|
-
|
749
|
-
keys = Minitest::Spec::TYPES.map(&:first)
|
750
|
-
|
751
|
-
assert_includes keys, /woot/
|
752
|
-
assert_includes keys, p
|
753
|
-
ensure
|
754
|
-
Minitest::Spec::TYPES.replace original_types
|
755
|
-
end
|
756
|
-
|
757
|
-
def test_spec_type
|
758
|
-
original_types = Minitest::Spec::TYPES.dup
|
759
|
-
|
760
|
-
Minitest::Spec.register_spec_type(/A$/, MiniSpecA)
|
761
|
-
Minitest::Spec.register_spec_type MiniSpecB do |desc|
|
762
|
-
desc.superclass == ExampleA
|
763
|
-
end
|
764
|
-
Minitest::Spec.register_spec_type MiniSpecC do |_desc, *addl|
|
765
|
-
addl.include? :woot
|
766
|
-
end
|
767
|
-
|
768
|
-
assert_equal MiniSpecA, Minitest::Spec.spec_type(ExampleA)
|
769
|
-
assert_equal MiniSpecB, Minitest::Spec.spec_type(ExampleB)
|
770
|
-
assert_equal MiniSpecC, Minitest::Spec.spec_type(ExampleB, :woot)
|
771
|
-
ensure
|
772
|
-
Minitest::Spec::TYPES.replace original_types
|
773
|
-
end
|
774
|
-
|
775
|
-
def test_bug_dsl_expectations
|
776
|
-
spec_class = Class.new MiniSpecB do
|
777
|
-
it "should work" do
|
778
|
-
0.must_equal 0
|
779
|
-
end
|
780
|
-
end
|
781
|
-
|
782
|
-
test_name = spec_class.instance_methods.sort.grep(/test/).first
|
783
|
-
|
784
|
-
spec = spec_class.new test_name
|
785
|
-
|
786
|
-
result = spec.run
|
787
|
-
|
788
|
-
assert spec.passed?
|
789
|
-
assert result.passed?
|
790
|
-
assert_equal 1, result.assertions
|
791
|
-
end
|
792
|
-
|
793
|
-
def test_name
|
794
|
-
spec_a = describe ExampleA do; end
|
795
|
-
spec_b = describe ExampleB, :random_method do; end
|
796
|
-
spec_c = describe ExampleB, :random_method, :addl_context do; end
|
797
|
-
|
798
|
-
assert_equal "ExampleA", spec_a.name
|
799
|
-
assert_equal "ExampleB::random_method", spec_b.name
|
800
|
-
assert_equal "ExampleB::random_method::addl_context", spec_c.name
|
801
|
-
end
|
802
|
-
|
803
|
-
def test_name2
|
804
|
-
assert_equal "NamedExampleA", NamedExampleA.name
|
805
|
-
assert_equal "NamedExampleB", NamedExampleB.name
|
806
|
-
assert_equal "NamedExampleC", NamedExampleC.name
|
807
|
-
|
808
|
-
spec_a = describe ExampleA do; end
|
809
|
-
spec_b = describe ExampleB, :random_method do; end
|
810
|
-
|
811
|
-
assert_equal "ExampleA", spec_a.name
|
812
|
-
assert_equal "ExampleB::random_method", spec_b.name
|
813
|
-
end
|
814
|
-
|
815
|
-
def test_structure
|
816
|
-
x, y, z, * = util_structure
|
817
|
-
|
818
|
-
assert_equal "top-level thingy", x.to_s
|
819
|
-
assert_equal "top-level thingy::inner thingy", y.to_s
|
820
|
-
assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s
|
821
|
-
|
822
|
-
assert_equal "top-level thingy", x.desc
|
823
|
-
assert_equal "inner thingy", y.desc
|
824
|
-
assert_equal "very inner thingy", z.desc
|
825
|
-
|
826
|
-
top_methods = %w[setup teardown test_0001_top-level-it]
|
827
|
-
inner_methods1 = %w[setup teardown test_0001_inner-it]
|
828
|
-
inner_methods2 = inner_methods1 +
|
829
|
-
%w[test_0002_anonymous test_0003_anonymous]
|
830
|
-
|
831
|
-
assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
|
832
|
-
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
|
833
|
-
assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
|
834
|
-
end
|
835
|
-
|
836
|
-
def test_structure_postfix_it
|
837
|
-
z = nil
|
838
|
-
y = describe "outer" do
|
839
|
-
# NOT here, below the inner-describe!
|
840
|
-
# it "inner-it" do end
|
841
|
-
|
842
|
-
z = describe "inner" do
|
843
|
-
it "inner-it" do end
|
844
|
-
end
|
845
|
-
|
846
|
-
# defined AFTER inner describe means we'll try to wipe out the inner-it
|
847
|
-
it "inner-it" do end
|
848
|
-
end
|
849
|
-
|
850
|
-
assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s)
|
851
|
-
assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s)
|
852
|
-
end
|
853
|
-
|
854
|
-
def test_setup_teardown_behavior
|
855
|
-
_, _, z, before_list, after_list = util_structure
|
856
|
-
|
857
|
-
@tu = z
|
858
|
-
|
859
|
-
run_tu_with_fresh_reporter
|
860
|
-
|
861
|
-
size = z.runnable_methods.size
|
862
|
-
assert_equal [1, 2, 3] * size, before_list
|
863
|
-
assert_equal [3, 2, 1] * size, after_list
|
864
|
-
end
|
865
|
-
|
866
|
-
def test_describe_first_structure
|
867
|
-
x1 = x2 = y = z = nil
|
868
|
-
x = describe "top-level thingy" do
|
869
|
-
y = describe "first thingy" do end
|
870
|
-
|
871
|
-
x1 = it "top level it" do end
|
872
|
-
x2 = it "не латинские &いった α, β, γ, δ, ε hello!!! world" do end
|
873
|
-
|
874
|
-
z = describe "second thingy" do end
|
875
|
-
end
|
876
|
-
|
877
|
-
test_methods = ["test_0001_top level it",
|
878
|
-
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
|
879
|
-
].sort
|
880
|
-
|
881
|
-
assert_equal test_methods, [x1, x2]
|
882
|
-
assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort
|
883
|
-
assert_equal [], y.instance_methods.grep(/^test/)
|
884
|
-
assert_equal [], z.instance_methods.grep(/^test/)
|
885
|
-
end
|
886
|
-
|
887
|
-
def test_structure_subclasses
|
888
|
-
z = nil
|
889
|
-
x = Class.new Minitest::Spec do
|
890
|
-
def xyz; end
|
891
|
-
end
|
892
|
-
y = Class.new x do
|
893
|
-
z = describe("inner") { }
|
894
|
-
end
|
895
|
-
|
896
|
-
assert_respond_to x.new(nil), "xyz"
|
897
|
-
assert_respond_to y.new(nil), "xyz"
|
898
|
-
assert_respond_to z.new(nil), "xyz"
|
899
|
-
end
|
900
|
-
end
|
901
|
-
|
902
|
-
class TestSpecInTestCase < MetaMetaMetaTestCase
|
903
|
-
def setup
|
904
|
-
super
|
905
|
-
|
906
|
-
Thread.current[:current_spec] = self
|
907
|
-
@tc = self
|
908
|
-
@assertion_count = 2
|
909
|
-
end
|
910
|
-
|
911
|
-
def assert_triggered expected, klass = Minitest::Assertion
|
912
|
-
@assertion_count += 1
|
913
|
-
|
914
|
-
e = assert_raises klass do
|
915
|
-
yield
|
916
|
-
end
|
917
|
-
|
918
|
-
msg = e.message.sub(/(---Backtrace---).*/m, "\1")
|
919
|
-
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
920
|
-
|
921
|
-
assert_equal expected, msg
|
922
|
-
end
|
923
|
-
|
924
|
-
def teardown
|
925
|
-
msg = "expected #{@assertion_count} assertions, not #{@tc.assertions}"
|
926
|
-
assert_equal @assertion_count, @tc.assertions, msg
|
927
|
-
end
|
928
|
-
|
929
|
-
def test_expectation
|
930
|
-
@tc.assert_equal true, 1.must_equal(1)
|
931
|
-
end
|
932
|
-
|
933
|
-
def test_expectation_triggered
|
934
|
-
assert_triggered "Expected: 2\n Actual: 1" do
|
935
|
-
1.must_equal 2
|
936
|
-
end
|
937
|
-
end
|
938
|
-
|
939
|
-
def test_expectation_with_a_message
|
940
|
-
assert_triggered "woot.\nExpected: 2\n Actual: 1" do
|
941
|
-
1.must_equal 2, "woot"
|
942
|
-
end
|
943
|
-
end
|
944
|
-
end
|
945
|
-
|
946
|
-
class ValueMonadTest < Minitest::Test
|
947
|
-
attr_accessor :struct
|
948
|
-
|
949
|
-
def setup
|
950
|
-
@struct = { :_ => 'a', :value => 'b', :expect => 'c' }
|
951
|
-
def @struct.method_missing k # think openstruct
|
952
|
-
self[k]
|
953
|
-
end
|
954
|
-
end
|
955
|
-
|
956
|
-
def test_value_monad_method
|
957
|
-
assert_equal 'a', struct._
|
958
|
-
end
|
959
|
-
|
960
|
-
def test_value_monad_value_alias
|
961
|
-
assert_equal 'b', struct.value
|
962
|
-
end
|
963
|
-
|
964
|
-
def test_value_monad_expect_alias
|
965
|
-
assert_equal 'c', struct.expect
|
966
|
-
end
|
967
|
-
end
|