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,512 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
|
3
|
-
class TestMinitestMock < Minitest::Test
|
4
|
-
parallelize_me!
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@mock = Minitest::Mock.new.expect(:foo, nil)
|
8
|
-
@mock.expect(:meaning_of_life, 42)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_create_stub_method
|
12
|
-
assert_nil @mock.foo
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_allow_return_value_specification
|
16
|
-
assert_equal 42, @mock.meaning_of_life
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_blow_up_if_not_called
|
20
|
-
@mock.foo
|
21
|
-
|
22
|
-
util_verify_bad "expected meaning_of_life() => 42"
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_not_blow_up_if_everything_called
|
26
|
-
@mock.foo
|
27
|
-
@mock.meaning_of_life
|
28
|
-
|
29
|
-
assert_mock @mock
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_allow_expectations_to_be_added_after_creation
|
33
|
-
@mock.expect(:bar, true)
|
34
|
-
assert @mock.bar
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_not_verify_if_new_expected_method_is_not_called
|
38
|
-
@mock.foo
|
39
|
-
@mock.meaning_of_life
|
40
|
-
@mock.expect(:bar, true)
|
41
|
-
|
42
|
-
util_verify_bad "expected bar() => true"
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_blow_up_on_wrong_number_of_arguments
|
46
|
-
@mock.foo
|
47
|
-
@mock.meaning_of_life
|
48
|
-
@mock.expect(:sum, 3, [1, 2])
|
49
|
-
|
50
|
-
e = assert_raises ArgumentError do
|
51
|
-
@mock.sum
|
52
|
-
end
|
53
|
-
|
54
|
-
assert_equal "mocked method :sum expects 2 arguments, got 0", e.message
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_return_mock_does_not_raise
|
58
|
-
retval = Minitest::Mock.new
|
59
|
-
mock = Minitest::Mock.new
|
60
|
-
mock.expect(:foo, retval)
|
61
|
-
mock.foo
|
62
|
-
|
63
|
-
assert_mock mock
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_mock_args_does_not_raise
|
67
|
-
skip "non-opaque use of ==" if maglev?
|
68
|
-
|
69
|
-
arg = Minitest::Mock.new
|
70
|
-
mock = Minitest::Mock.new
|
71
|
-
mock.expect(:foo, nil, [arg])
|
72
|
-
mock.foo(arg)
|
73
|
-
|
74
|
-
assert_mock mock
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_set_expectation_on_special_methods
|
78
|
-
mock = Minitest::Mock.new
|
79
|
-
|
80
|
-
mock.expect :object_id, "received object_id"
|
81
|
-
assert_equal "received object_id", mock.object_id
|
82
|
-
|
83
|
-
mock.expect :respond_to_missing?, "received respond_to_missing?"
|
84
|
-
assert_equal "received respond_to_missing?", mock.respond_to_missing?
|
85
|
-
|
86
|
-
mock.expect :===, "received ==="
|
87
|
-
assert_equal "received ===", mock.===
|
88
|
-
|
89
|
-
mock.expect :inspect, "received inspect"
|
90
|
-
assert_equal "received inspect", mock.inspect
|
91
|
-
|
92
|
-
mock.expect :to_s, "received to_s"
|
93
|
-
assert_equal "received to_s", mock.to_s
|
94
|
-
|
95
|
-
mock.expect :public_send, "received public_send"
|
96
|
-
assert_equal "received public_send", mock.public_send
|
97
|
-
|
98
|
-
mock.expect :send, "received send"
|
99
|
-
assert_equal "received send", mock.send
|
100
|
-
|
101
|
-
assert_mock mock
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_expectations_can_be_satisfied_via_send
|
105
|
-
@mock.send :foo
|
106
|
-
@mock.send :meaning_of_life
|
107
|
-
|
108
|
-
assert_mock @mock
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_expectations_can_be_satisfied_via_public_send
|
112
|
-
skip "Doesn't run on 1.8" if RUBY_VERSION < "1.9"
|
113
|
-
|
114
|
-
@mock.public_send :foo
|
115
|
-
@mock.public_send :meaning_of_life
|
116
|
-
|
117
|
-
assert_mock @mock
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_blow_up_on_wrong_arguments
|
121
|
-
@mock.foo
|
122
|
-
@mock.meaning_of_life
|
123
|
-
@mock.expect(:sum, 3, [1, 2])
|
124
|
-
|
125
|
-
e = assert_raises MockExpectationError do
|
126
|
-
@mock.sum(2, 4)
|
127
|
-
end
|
128
|
-
|
129
|
-
exp = "mocked method :sum called with unexpected arguments [2, 4]"
|
130
|
-
assert_equal exp, e.message
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_expect_with_non_array_args
|
134
|
-
e = assert_raises ArgumentError do
|
135
|
-
@mock.expect :blah, 3, false
|
136
|
-
end
|
137
|
-
|
138
|
-
assert_equal "args must be an array", e.message
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_respond_appropriately
|
142
|
-
assert @mock.respond_to?(:foo)
|
143
|
-
assert @mock.respond_to?(:foo, true)
|
144
|
-
assert @mock.respond_to?("foo")
|
145
|
-
assert !@mock.respond_to?(:bar)
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_no_method_error_on_unexpected_methods
|
149
|
-
e = assert_raises NoMethodError do
|
150
|
-
@mock.bar
|
151
|
-
end
|
152
|
-
|
153
|
-
expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
|
154
|
-
|
155
|
-
assert_equal expected, e.message
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_assign_per_mock_return_values
|
159
|
-
a = Minitest::Mock.new
|
160
|
-
b = Minitest::Mock.new
|
161
|
-
|
162
|
-
a.expect(:foo, :a)
|
163
|
-
b.expect(:foo, :b)
|
164
|
-
|
165
|
-
assert_equal :a, a.foo
|
166
|
-
assert_equal :b, b.foo
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_do_not_create_stub_method_on_new_mocks
|
170
|
-
a = Minitest::Mock.new
|
171
|
-
a.expect(:foo, :a)
|
172
|
-
|
173
|
-
assert !Minitest::Mock.new.respond_to?(:foo)
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_mock_is_a_blank_slate
|
177
|
-
@mock.expect :kind_of?, true, [Fixnum]
|
178
|
-
@mock.expect :==, true, [1]
|
179
|
-
|
180
|
-
assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?"
|
181
|
-
assert @mock == 1, "didn't mock :=="
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_verify_allows_called_args_to_be_loosely_specified
|
185
|
-
mock = Minitest::Mock.new
|
186
|
-
mock.expect :loose_expectation, true, [Integer]
|
187
|
-
mock.loose_expectation 1
|
188
|
-
|
189
|
-
assert_mock mock
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_verify_raises_with_strict_args
|
193
|
-
mock = Minitest::Mock.new
|
194
|
-
mock.expect :strict_expectation, true, [2]
|
195
|
-
|
196
|
-
e = assert_raises MockExpectationError do
|
197
|
-
mock.strict_expectation 1
|
198
|
-
end
|
199
|
-
|
200
|
-
exp = "mocked method :strict_expectation called with unexpected arguments [1]"
|
201
|
-
assert_equal exp, e.message
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_method_missing_empty
|
205
|
-
mock = Minitest::Mock.new
|
206
|
-
|
207
|
-
mock.expect :a, nil
|
208
|
-
|
209
|
-
mock.a
|
210
|
-
|
211
|
-
e = assert_raises MockExpectationError do
|
212
|
-
mock.a
|
213
|
-
end
|
214
|
-
|
215
|
-
assert_equal "No more expects available for :a: []", e.message
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_same_method_expects_are_verified_when_all_called
|
219
|
-
mock = Minitest::Mock.new
|
220
|
-
mock.expect :foo, nil, [:bar]
|
221
|
-
mock.expect :foo, nil, [:baz]
|
222
|
-
|
223
|
-
mock.foo :bar
|
224
|
-
mock.foo :baz
|
225
|
-
|
226
|
-
assert_mock mock
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_same_method_expects_blow_up_when_not_all_called
|
230
|
-
mock = Minitest::Mock.new
|
231
|
-
mock.expect :foo, nil, [:bar]
|
232
|
-
mock.expect :foo, nil, [:baz]
|
233
|
-
|
234
|
-
mock.foo :bar
|
235
|
-
|
236
|
-
e = assert_raises(MockExpectationError) { mock.verify }
|
237
|
-
|
238
|
-
exp = "expected foo(:baz) => nil, got [foo(:bar) => nil]"
|
239
|
-
|
240
|
-
assert_equal exp, e.message
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_same_method_expects_with_same_args_blow_up_when_not_all_called
|
244
|
-
mock = Minitest::Mock.new
|
245
|
-
mock.expect :foo, nil, [:bar]
|
246
|
-
mock.expect :foo, nil, [:bar]
|
247
|
-
|
248
|
-
mock.foo :bar
|
249
|
-
|
250
|
-
e = assert_raises(MockExpectationError) { mock.verify }
|
251
|
-
|
252
|
-
exp = "expected foo(:bar) => nil, got [foo(:bar) => nil]"
|
253
|
-
|
254
|
-
assert_equal exp, e.message
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_verify_passes_when_mock_block_returns_true
|
258
|
-
mock = Minitest::Mock.new
|
259
|
-
mock.expect :foo, nil do
|
260
|
-
true
|
261
|
-
end
|
262
|
-
|
263
|
-
mock.foo
|
264
|
-
|
265
|
-
assert_mock mock
|
266
|
-
end
|
267
|
-
|
268
|
-
def test_mock_block_is_passed_function_params
|
269
|
-
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
|
270
|
-
mock = Minitest::Mock.new
|
271
|
-
mock.expect :foo, nil do |a1, a2, a3|
|
272
|
-
a1 == arg1 && a2 == arg2 && a3 == arg3
|
273
|
-
end
|
274
|
-
|
275
|
-
mock.foo arg1, arg2, arg3
|
276
|
-
|
277
|
-
assert_mock mock
|
278
|
-
end
|
279
|
-
|
280
|
-
def test_mock_block_is_passed_function_block
|
281
|
-
mock = Minitest::Mock.new
|
282
|
-
block = proc { "bar" }
|
283
|
-
mock.expect :foo, nil do |arg, &blk|
|
284
|
-
arg == "foo" &&
|
285
|
-
blk == block
|
286
|
-
end
|
287
|
-
mock.foo "foo", &block
|
288
|
-
assert_mock mock
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_verify_fails_when_mock_block_returns_false
|
292
|
-
mock = Minitest::Mock.new
|
293
|
-
mock.expect :foo, nil do
|
294
|
-
false
|
295
|
-
end
|
296
|
-
|
297
|
-
e = assert_raises(MockExpectationError) { mock.foo }
|
298
|
-
exp = "mocked method :foo failed block w/ []"
|
299
|
-
|
300
|
-
assert_equal exp, e.message
|
301
|
-
end
|
302
|
-
|
303
|
-
def test_mock_block_throws_if_args_passed
|
304
|
-
mock = Minitest::Mock.new
|
305
|
-
|
306
|
-
e = assert_raises(ArgumentError) do
|
307
|
-
mock.expect :foo, nil, [:a, :b, :c] do
|
308
|
-
true
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
exp = "args ignored when block given"
|
313
|
-
|
314
|
-
assert_equal exp, e.message
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_mock_returns_retval_when_called_with_block
|
318
|
-
mock = Minitest::Mock.new
|
319
|
-
mock.expect(:foo, 32) do
|
320
|
-
true
|
321
|
-
end
|
322
|
-
|
323
|
-
rs = mock.foo
|
324
|
-
|
325
|
-
assert_equal rs, 32
|
326
|
-
end
|
327
|
-
|
328
|
-
def util_verify_bad exp
|
329
|
-
e = assert_raises MockExpectationError do
|
330
|
-
@mock.verify
|
331
|
-
end
|
332
|
-
|
333
|
-
assert_equal exp, e.message
|
334
|
-
end
|
335
|
-
|
336
|
-
def test_mock_called_via_send
|
337
|
-
mock = Minitest::Mock.new
|
338
|
-
mock.expect(:foo, true)
|
339
|
-
|
340
|
-
mock.send :foo
|
341
|
-
assert_mock mock
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_mock_called_via___send__
|
345
|
-
mock = Minitest::Mock.new
|
346
|
-
mock.expect(:foo, true)
|
347
|
-
|
348
|
-
mock.__send__ :foo
|
349
|
-
assert_mock mock
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_mock_called_via_send_with_args
|
353
|
-
mock = Minitest::Mock.new
|
354
|
-
mock.expect(:foo, true, [1, 2, 3])
|
355
|
-
|
356
|
-
mock.send(:foo, 1, 2, 3)
|
357
|
-
assert_mock mock
|
358
|
-
end
|
359
|
-
|
360
|
-
end
|
361
|
-
|
362
|
-
require "minitest/metametameta"
|
363
|
-
|
364
|
-
class TestMinitestStub < Minitest::Test
|
365
|
-
parallelize_me!
|
366
|
-
|
367
|
-
def setup
|
368
|
-
super
|
369
|
-
Minitest::Test.reset
|
370
|
-
|
371
|
-
@tc = Minitest::Test.new "fake tc"
|
372
|
-
@assertion_count = 1
|
373
|
-
end
|
374
|
-
|
375
|
-
def teardown
|
376
|
-
super
|
377
|
-
assert_equal @assertion_count, @tc.assertions
|
378
|
-
end
|
379
|
-
|
380
|
-
class Time
|
381
|
-
def self.now
|
382
|
-
24
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def assert_stub val_or_callable
|
387
|
-
@assertion_count += 1
|
388
|
-
|
389
|
-
t = Time.now.to_i
|
390
|
-
|
391
|
-
Time.stub :now, val_or_callable do
|
392
|
-
@tc.assert_equal 42, Time.now
|
393
|
-
end
|
394
|
-
|
395
|
-
@tc.assert_operator Time.now.to_i, :>=, t
|
396
|
-
end
|
397
|
-
|
398
|
-
def test_stub_private_module_method
|
399
|
-
@assertion_count += 1
|
400
|
-
|
401
|
-
t0 = Time.now
|
402
|
-
|
403
|
-
self.stub :sleep, nil do
|
404
|
-
@tc.assert_nil sleep(10)
|
405
|
-
end
|
406
|
-
|
407
|
-
@tc.assert_operator Time.now - t0, :<=, 1
|
408
|
-
end
|
409
|
-
|
410
|
-
def test_stub_private_module_method_indirect
|
411
|
-
@assertion_count += 1
|
412
|
-
|
413
|
-
fail_clapper = Class.new do
|
414
|
-
def fail_clap
|
415
|
-
raise
|
416
|
-
:clap
|
417
|
-
end
|
418
|
-
end.new
|
419
|
-
|
420
|
-
fail_clapper.stub :raise, nil do |safe_clapper|
|
421
|
-
@tc.assert_equal :clap, safe_clapper.fail_clap # either form works
|
422
|
-
@tc.assert_equal :clap, fail_clapper.fail_clap # yay closures
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
def test_stub_public_module_method
|
427
|
-
Math.stub :log10, :stubbed do
|
428
|
-
@tc.assert_equal :stubbed, Math.log10(1000)
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
432
|
-
def test_stub_value
|
433
|
-
assert_stub 42
|
434
|
-
end
|
435
|
-
|
436
|
-
def test_stub_block
|
437
|
-
assert_stub lambda { 42 }
|
438
|
-
end
|
439
|
-
|
440
|
-
def test_stub_block_args
|
441
|
-
@assertion_count += 1
|
442
|
-
|
443
|
-
t = Time.now.to_i
|
444
|
-
|
445
|
-
Time.stub :now, lambda { |n| n * 2 } do
|
446
|
-
@tc.assert_equal 42, Time.now(21)
|
447
|
-
end
|
448
|
-
|
449
|
-
@tc.assert_operator Time.now.to_i, :>=, t
|
450
|
-
end
|
451
|
-
|
452
|
-
def test_stub_callable
|
453
|
-
obj = Object.new
|
454
|
-
|
455
|
-
def obj.call
|
456
|
-
42
|
457
|
-
end
|
458
|
-
|
459
|
-
assert_stub obj
|
460
|
-
end
|
461
|
-
|
462
|
-
def test_stub_yield_self
|
463
|
-
obj = "foo"
|
464
|
-
|
465
|
-
val = obj.stub :to_s, "bar" do |s|
|
466
|
-
s.to_s
|
467
|
-
end
|
468
|
-
|
469
|
-
@tc.assert_equal "bar", val
|
470
|
-
end
|
471
|
-
|
472
|
-
def test_dynamic_method
|
473
|
-
@assertion_count = 2
|
474
|
-
|
475
|
-
dynamic = Class.new do
|
476
|
-
def self.respond_to?(meth)
|
477
|
-
meth == :found
|
478
|
-
end
|
479
|
-
|
480
|
-
def self.method_missing(meth, *args, &block)
|
481
|
-
if meth == :found
|
482
|
-
false
|
483
|
-
else
|
484
|
-
super
|
485
|
-
end
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
val = dynamic.stub(:found, true) do |s|
|
490
|
-
s.found
|
491
|
-
end
|
492
|
-
|
493
|
-
@tc.assert_equal true, val
|
494
|
-
@tc.assert_equal false, dynamic.found
|
495
|
-
end
|
496
|
-
|
497
|
-
def test_mock_with_yield
|
498
|
-
mock = Minitest::Mock.new
|
499
|
-
mock.expect(:write, true) do
|
500
|
-
true
|
501
|
-
end
|
502
|
-
rs = nil
|
503
|
-
|
504
|
-
File.stub(:open, true, mock) do
|
505
|
-
File.open("foo.txt", "r") do |f|
|
506
|
-
rs = f.write
|
507
|
-
end
|
508
|
-
end
|
509
|
-
@tc.assert_equal true, rs
|
510
|
-
end
|
511
|
-
|
512
|
-
end
|