assert 2.18.4 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ed950be1bca18deac9277678d40abc99072df13d5e23d21460c7e9b72a1c4ab
4
- data.tar.gz: cd7c0eec0a939400f384c6e8d69b7fbb27856f3ed9fdfca25ae1ab48404c822f
3
+ metadata.gz: 9486fb389a6e45657eaf3c79f7c2cfea3e8cd6d9b8593c28597b716f9316c86b
4
+ data.tar.gz: dea0bd1b5061630fddad2f2feaa43e3faf0e64504bf444599747035b3ca8e40f
5
5
  SHA512:
6
- metadata.gz: 9a0334a2851a5b2742bab2ed51b6583e8ff47c9a89c605dfd10d84f0a20a6f17a16ba59179c53bf89b1dd0ed40673fb3909966c7476410d8ee1a52e580ec5766
7
- data.tar.gz: a6f1f6db5d115e7e535ec0305d62970480f7b831eb8026e940011db2fcb3576244084fbf121f1ec499c61853d03dac3a76034dd7bdd3c187b778795ce0a3b5fd
6
+ metadata.gz: c6e57f7df5c6b7273a3ccb190ecc77f014fe597fa15fb6cc72f4bdadd77a12066736e9dffc12cc02d4854f7cf92751fe1994d5142ad24c44eb196906eb079d64
7
+ data.tar.gz: cd2c4c0ef5c647abab8a9aac3340d17219ccd5b9d8eed5df34f47238296187122ee4b0df2c09aa9989e7dc8ddcb5d0529e3c615f539cf22e3e4f5d35a8b81575
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.required_ruby_version = "~> 2.5"
22
22
 
23
- gem.add_dependency("much-factory", ["~> 0.1.0"])
24
- gem.add_dependency("much-stub", ["~> 0.1.4"])
23
+ gem.add_dependency("much-factory", ["~> 0.1.0"])
24
+ gem.add_dependency("much-not-given", ["~> 0.1.0"])
25
+ gem.add_dependency("much-stub", ["~> 0.1.4"])
25
26
  end
@@ -1,9 +1,12 @@
1
+ require "much-not-given"
1
2
  require "much-stub"
2
3
 
3
4
  module Assert; end
4
5
  class Assert::ActualValue
5
- def initialize(value, context:)
6
- @value = value
6
+ include MuchNotGiven
7
+
8
+ def initialize(value = self.class.not_given, context:, &value_block)
9
+ @value = self.class.given?(value) ? value : value_block
7
10
  @context = context
8
11
  end
9
12
 
@@ -23,6 +26,14 @@ class Assert::ActualValue
23
26
  @context.assert_nothing_raised(*expected_exceptions, &@value)
24
27
  end
25
28
 
29
+ def changes(*args)
30
+ @context.assert_changes(*args, &@value)
31
+ end
32
+
33
+ def does_not_change(*args)
34
+ @context.assert_not_changes(*args, &@value)
35
+ end
36
+
26
37
  def is_a_kind_of(expected_class, *args)
27
38
  @context.assert_kind_of(expected_class, @value, *args)
28
39
  end
@@ -54,10 +65,12 @@ class Assert::ActualValue
54
65
  def is_the_same_as(expected_object, *args)
55
66
  @context.assert_same(expected_object, @value, *args)
56
67
  end
68
+ alias_method :is, :is_the_same_as
57
69
 
58
70
  def is_not_the_same_as(expected_object, *args)
59
71
  @context.assert_not_same(expected_object, @value, *args)
60
72
  end
73
+ alias_method :is_not, :is_not_the_same_as
61
74
 
62
75
  def equals(expected_value, *args)
63
76
  @context.assert_equal(expected_value, @value, *args)
@@ -198,6 +198,75 @@ module Assert
198
198
  alias_method :assert_not_raises, :assert_nothing_raised
199
199
  alias_method :assert_not_raise, :assert_nothing_raised
200
200
 
201
+ def assert_changes(
202
+ ruby_string_to_eval,
203
+ desc: nil,
204
+ from: Assert::ActualValue.not_given,
205
+ to: Assert::ActualValue.not_given,
206
+ &block
207
+ )
208
+ desc_msg = desc ? "#{desc}\n" : ""
209
+ from_eval = instance_eval(ruby_string_to_eval)
210
+ if Assert::ActualValue.given?(from)
211
+ assert_equal(
212
+ from,
213
+ from_eval,
214
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change from `#{from.inspect}`."
215
+ )
216
+ end
217
+
218
+ block.call
219
+
220
+ to_eval = instance_eval(ruby_string_to_eval)
221
+ if Assert::ActualValue.given?(to)
222
+ assert_equal(
223
+ to,
224
+ to_eval,
225
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change to `#{to.inspect}`."
226
+ )
227
+ end
228
+
229
+ if (
230
+ Assert::ActualValue.not_given?(from) &&
231
+ Assert::ActualValue.not_given?(to)
232
+ )
233
+ assert_not_equal(
234
+ from_eval,
235
+ to_eval,
236
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change; "\
237
+ "it was `#{from_eval.inspect}` and didn't change."
238
+ )
239
+ end
240
+ end
241
+
242
+ def assert_not_changes(
243
+ ruby_string_to_eval,
244
+ desc: nil,
245
+ from: Assert::ActualValue.not_given,
246
+ &block
247
+ )
248
+ desc_msg = desc ? "#{desc}\n" : ""
249
+ from_eval = instance_eval(ruby_string_to_eval)
250
+ if Assert::ActualValue.given?(from)
251
+ assert_equal(
252
+ from,
253
+ from_eval,
254
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change from `#{from.inspect}`."
255
+ )
256
+ end
257
+
258
+ block.call
259
+
260
+ to_eval = instance_eval(ruby_string_to_eval)
261
+ assert_equal(
262
+ from_eval,
263
+ to_eval,
264
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change; "\
265
+ "it was `#{from_eval.inspect}` and changed to `#{to_eval.inspect}`."
266
+ )
267
+ end
268
+ alias_method :refute_changes, :assert_not_changes
269
+
201
270
  def assert_respond_to(method, object, desc = nil)
202
271
  assert(object.respond_to?(method), desc) do
203
272
  "Expected #{Assert::U.show(object, __assert_config__)} (#{object.class})"\
@@ -13,8 +13,13 @@ require "assert/suite"
13
13
  require "assert/utils"
14
14
 
15
15
  module Assert
16
+ # A Context is a scope for tests to run in. Contexts have setup and teardown
17
+ # blocks, subjects, and descriptions. Tests are run in the scope of a Context
18
+ # instance. Therefore, a Context should have minimal base
19
+ # logic/methods/instance_vars. The instance should remain pure to not pollute
20
+ # test scopes.
16
21
  class Context
17
- # put all logic in DSL methods to keep context instances pure for running tests
22
+ # Put all logic in DSL methods to keep context instances pure.
18
23
  extend SetupDSL
19
24
  extend SubjectDSL
20
25
  extend SuiteDSL
@@ -24,33 +29,6 @@ module Assert
24
29
  include Assert::Assertions
25
30
  include Assert::Macros::Methods
26
31
 
27
- # a Context is a scope for tests to run in. Contexts have setup and
28
- # teardown blocks, subjects, and descriptions. Tests are run in the
29
- # scope of a Context instance. Therefore, a Context should have
30
- # minimal base logic/methods/instance_vars. The instance should remain
31
- # pure to not pollute test scopes.
32
-
33
- # if a test method is added to a context manually (not using a context helper):
34
- # capture any context info, build a test obj, and add it to the suite
35
- def self.method_added(method_name)
36
- if method_name.to_s =~ Suite::TEST_METHOD_REGEX
37
- klass_method_name = "#{self}##{method_name}"
38
-
39
- if self.suite.test_methods.include?(klass_method_name)
40
- puts "WARNING: redefining "#{klass_method_name}""
41
- puts " from: #{caller_locations(1,1)}"
42
- else
43
- self.suite.test_methods << klass_method_name
44
- end
45
-
46
- self.suite.on_test(Test.for_method(
47
- method_name.to_s,
48
- ContextInfo.new(self, nil, caller_locations(1,1)),
49
- self.suite.config
50
- ))
51
- end
52
- end
53
-
54
32
  def initialize(running_test, config, result_callback)
55
33
  @__assert_running_test__ = running_test
56
34
  @__assert_config__ = config
@@ -92,8 +70,11 @@ module Assert
92
70
  end
93
71
  alias_method :refute, :assert_not
94
72
 
95
- def assert_that(actual_value)
96
- Assert::ActualValue.new(actual_value, context: self)
73
+ def assert_that(
74
+ actual_value = Assert::ActualValue.not_given,
75
+ &actual_value_block
76
+ )
77
+ Assert::ActualValue.new(actual_value, context: self, &actual_value_block)
97
78
  end
98
79
 
99
80
  # adds a Pass result to the end of the test's results
@@ -102,8 +83,10 @@ module Assert
102
83
  if @__assert_pending__ == 0
103
84
  capture_result(Assert::Result::Pass, pass_msg)
104
85
  else
105
- capture_result(Assert::Result::Fail, "Pending pass (make it "\
106
- "not pending)")
86
+ capture_result(
87
+ Assert::Result::Fail,
88
+ "Pending pass (make it not pending)"
89
+ )
107
90
  end
108
91
  end
109
92
 
@@ -129,7 +129,11 @@ module Assert::Result
129
129
  end
130
130
 
131
131
  def ==(other_result)
132
- self.type == other_result.type && self.message == other_result.message
132
+ if other_result.is_a?(self.class)
133
+ self.type == other_result.type && self.message == other_result.message
134
+ else
135
+ super
136
+ end
133
137
  end
134
138
 
135
139
  def inspect
@@ -10,22 +10,19 @@ module Assert
10
10
  class Suite
11
11
  include Assert::ConfigHelpers
12
12
 
13
- TEST_METHOD_REGEX = /^test./.freeze
14
-
15
13
  # A suite is a set of tests to run. When a test class subclasses
16
14
  # the Context class, that test class is pushed to the suite.
17
15
 
18
- attr_reader :config, :test_methods, :setups, :teardowns
16
+ attr_reader :config, :setups, :teardowns
19
17
  attr_accessor :start_time, :end_time
20
18
 
21
19
  def initialize(config)
22
- @config = config
23
- @tests = []
24
- @test_methods = []
25
- @setups = []
26
- @teardowns = []
27
- @start_time = Time.now
28
- @end_time = @start_time
20
+ @config = config
21
+ @tests = []
22
+ @setups = []
23
+ @teardowns = []
24
+ @start_time = Time.now
25
+ @end_time = @start_time
29
26
  end
30
27
 
31
28
  def suite; self; end
@@ -20,14 +20,6 @@ module Assert
20
20
  }))
21
21
  end
22
22
 
23
- def self.for_method(method_name, context_info, config)
24
- self.new(self.name_file_line_context_data(context_info, method_name).merge({
25
- :context_info => context_info,
26
- :config => config,
27
- :code => proc{ self.send(method_name) }
28
- }))
29
- end
30
-
31
23
  def initialize(build_data = nil)
32
24
  @build_data = build_data || {}
33
25
  @result_callback = nil
@@ -1,3 +1,3 @@
1
1
  module Assert
2
- VERSION = "2.18.4"
2
+ VERSION = "2.19.0"
3
3
  end
@@ -54,27 +54,27 @@ class Assert::Stub
54
54
  end
55
55
 
56
56
  should "not allow stubbing methods with invalid arity" do
57
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
57
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
58
58
 
59
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
60
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
59
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
60
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
61
61
 
62
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
63
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
62
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
63
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
64
64
 
65
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
65
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
66
66
  end
67
67
 
68
68
  should "not allow calling methods with invalid arity" do
69
- assert_that(-> { subject.noargs(1) }).raises
69
+ assert_that { subject.noargs(1) }.raises
70
70
 
71
- assert_that(-> { subject.withargs }).raises
72
- assert_that(-> { subject.withargs(1, 2) }).raises
71
+ assert_that { subject.withargs }.raises
72
+ assert_that { subject.withargs(1, 2) }.raises
73
73
 
74
- assert_that(-> { subject.minargs }).raises
75
- assert_that(-> { subject.minargs(1) }).raises
74
+ assert_that { subject.minargs }.raises
75
+ assert_that { subject.minargs(1) }.raises
76
76
 
77
- assert_that(-> { subject.withblock(1) }).raises
77
+ assert_that { subject.withblock(1) }.raises
78
78
  end
79
79
  end
80
80
 
@@ -127,27 +127,27 @@ class Assert::Stub
127
127
  end
128
128
 
129
129
  should "not allow stubbing methods with invalid arity" do
130
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
130
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
131
131
 
132
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
133
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
132
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
133
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
134
134
 
135
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
136
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
135
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
136
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
137
137
 
138
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
138
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
139
139
  end
140
140
 
141
141
  should "not allow calling methods with invalid arity" do
142
- assert_that(-> { subject.noargs(1) }).raises
142
+ assert_that { subject.noargs(1) }.raises
143
143
 
144
- assert_that(-> { subject.withargs }).raises
145
- assert_that(-> { subject.withargs(1, 2) }).raises
144
+ assert_that { subject.withargs }.raises
145
+ assert_that { subject.withargs(1, 2) }.raises
146
146
 
147
- assert_that(-> { subject.minargs }).raises
148
- assert_that(-> { subject.minargs(1) }).raises
147
+ assert_that { subject.minargs }.raises
148
+ assert_that { subject.minargs(1) }.raises
149
149
 
150
- assert_that(-> { subject.withblock(1) }).raises
150
+ assert_that { subject.withblock(1) }.raises
151
151
  end
152
152
  end
153
153
 
@@ -200,27 +200,27 @@ class Assert::Stub
200
200
  end
201
201
 
202
202
  should "not allow stubbing methods with invalid arity" do
203
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
203
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
204
204
 
205
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
206
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
205
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
206
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
207
207
 
208
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
209
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
208
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
209
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
210
210
 
211
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
211
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
212
212
  end
213
213
 
214
214
  should "not allow calling methods with invalid arity" do
215
- assert_that(-> { subject.noargs(1) }).raises
215
+ assert_that { subject.noargs(1) }.raises
216
216
 
217
- assert_that(-> { subject.withargs }).raises
218
- assert_that(-> { subject.withargs(1, 2) }).raises
217
+ assert_that { subject.withargs }.raises
218
+ assert_that { subject.withargs(1, 2) }.raises
219
219
 
220
- assert_that(-> { subject.minargs }).raises
221
- assert_that(-> { subject.minargs(1) }).raises
220
+ assert_that { subject.minargs }.raises
221
+ assert_that { subject.minargs(1) }.raises
222
222
 
223
- assert_that(-> { subject.withblock(1) }).raises
223
+ assert_that { subject.withblock(1) }.raises
224
224
  end
225
225
  end
226
226
 
@@ -273,27 +273,27 @@ class Assert::Stub
273
273
  end
274
274
 
275
275
  should "not allow stubbing methods with invalid arity" do
276
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
276
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
277
277
 
278
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
279
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
278
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
279
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
280
280
 
281
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
282
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
281
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
282
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
283
283
 
284
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
284
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
285
285
  end
286
286
 
287
287
  should "not allow calling methods with invalid arity" do
288
- assert_that(-> { subject.noargs(1) }).raises
288
+ assert_that { subject.noargs(1) }.raises
289
289
 
290
- assert_that(-> { subject.withargs }).raises
291
- assert_that(-> { subject.withargs(1, 2) }).raises
290
+ assert_that { subject.withargs }.raises
291
+ assert_that { subject.withargs(1, 2) }.raises
292
292
 
293
- assert_that(-> { subject.minargs }).raises
294
- assert_that(-> { subject.minargs(1) }).raises
293
+ assert_that { subject.minargs }.raises
294
+ assert_that { subject.minargs(1) }.raises
295
295
 
296
- assert_that(-> { subject.withblock(1) }).raises
296
+ assert_that { subject.withblock(1) }.raises
297
297
  end
298
298
  end
299
299
 
@@ -348,27 +348,27 @@ class Assert::Stub
348
348
  end
349
349
 
350
350
  should "not allow stubbing methods with invalid arity" do
351
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
351
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
352
352
 
353
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
354
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
353
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
354
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
355
355
 
356
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
357
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
356
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
357
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
358
358
 
359
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
359
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
360
360
  end
361
361
 
362
362
  should "not allow calling methods with invalid arity" do
363
- assert_that(-> { subject.noargs(1) }).raises
363
+ assert_that { subject.noargs(1) }.raises
364
364
 
365
- assert_that(-> { subject.withargs }).raises
366
- assert_that(-> { subject.withargs(1, 2) }).raises
365
+ assert_that { subject.withargs }.raises
366
+ assert_that { subject.withargs(1, 2) }.raises
367
367
 
368
- assert_that(-> { subject.minargs }).raises
369
- assert_that(-> { subject.minargs(1) }).raises
368
+ assert_that { subject.minargs }.raises
369
+ assert_that { subject.minargs(1) }.raises
370
370
 
371
- assert_that(-> { subject.withblock(1) }).raises
371
+ assert_that { subject.withblock(1) }.raises
372
372
  end
373
373
  end
374
374
 
@@ -421,27 +421,27 @@ class Assert::Stub
421
421
  end
422
422
 
423
423
  should "not allow stubbing methods with invalid arity" do
424
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
424
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
425
425
 
426
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
427
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
426
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
427
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
428
428
 
429
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
430
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
429
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
430
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
431
431
 
432
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
432
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
433
433
  end
434
434
 
435
435
  should "not allow calling methods with invalid arity" do
436
- assert_that(-> { subject.noargs(1) }).raises
436
+ assert_that { subject.noargs(1) }.raises
437
437
 
438
- assert_that(-> { subject.withargs }).raises
439
- assert_that(-> { subject.withargs(1, 2) }).raises
438
+ assert_that { subject.withargs }.raises
439
+ assert_that { subject.withargs(1, 2) }.raises
440
440
 
441
- assert_that(-> { subject.minargs }).raises
442
- assert_that(-> { subject.minargs(1) }).raises
441
+ assert_that { subject.minargs }.raises
442
+ assert_that { subject.minargs(1) }.raises
443
443
 
444
- assert_that(-> { subject.withblock(1) }).raises
444
+ assert_that { subject.withblock(1) }.raises
445
445
  end
446
446
  end
447
447
 
@@ -494,27 +494,27 @@ class Assert::Stub
494
494
  end
495
495
 
496
496
  should "not allow stubbing methods with invalid arity" do
497
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
497
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
498
498
 
499
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
500
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
499
+ assert_that { Assert.stub(subject, :withargs).with{ } }.raises
500
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
501
501
 
502
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
503
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
502
+ assert_that { Assert.stub(subject, :minargs).with{ } }.raises
503
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
504
504
 
505
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
505
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
506
506
  end
507
507
 
508
508
  should "not allow calling methods with invalid arity" do
509
- assert_that(-> { subject.noargs(1) }).raises
509
+ assert_that { subject.noargs(1) }.raises
510
510
 
511
- assert_that(-> { subject.withargs }).raises
512
- assert_that(-> { subject.withargs(1, 2) }).raises
511
+ assert_that { subject.withargs }.raises
512
+ assert_that { subject.withargs(1, 2) }.raises
513
513
 
514
- assert_that(-> { subject.minargs }).raises
515
- assert_that(-> { subject.minargs(1) }).raises
514
+ assert_that { subject.minargs }.raises
515
+ assert_that { subject.minargs(1) }.raises
516
516
 
517
- assert_that(-> { subject.withblock(1) }).raises
517
+ assert_that { subject.withblock(1) }.raises
518
518
  end
519
519
  end
520
520
 
@@ -567,27 +567,27 @@ class Assert::Stub
567
567
  end
568
568
 
569
569
  should "allow stubbing methods with invalid arity" do
570
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).does_not_raise
570
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.does_not_raise
571
571
 
572
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).does_not_raise
573
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).does_not_raise
572
+ assert_that { Assert.stub(subject, :withargs).with{ } }.does_not_raise
573
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.does_not_raise
574
574
 
575
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).does_not_raise
576
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).does_not_raise
575
+ assert_that { Assert.stub(subject, :minargs).with{ } }.does_not_raise
576
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.does_not_raise
577
577
 
578
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).does_not_raise
578
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.does_not_raise
579
579
  end
580
580
 
581
581
  should "allow calling methods with invalid arity" do
582
- assert_that(-> { subject.noargs(1) }).does_not_raise
582
+ assert_that { subject.noargs(1) }.does_not_raise
583
583
 
584
- assert_that(-> { subject.withargs }).does_not_raise
585
- assert_that(-> { subject.withargs(1, 2) }).does_not_raise
584
+ assert_that { subject.withargs }.does_not_raise
585
+ assert_that { subject.withargs(1, 2) }.does_not_raise
586
586
 
587
- assert_that(-> { subject.minargs }).does_not_raise
588
- assert_that(-> { subject.minargs(1) }).does_not_raise
587
+ assert_that { subject.minargs }.does_not_raise
588
+ assert_that { subject.minargs(1) }.does_not_raise
589
589
 
590
- assert_that(-> { subject.withblock(1) }).does_not_raise
590
+ assert_that { subject.withblock(1) }.does_not_raise
591
591
  end
592
592
  end
593
593
 
@@ -640,27 +640,27 @@ class Assert::Stub
640
640
  end
641
641
 
642
642
  should "allow stubbing methods with invalid arity" do
643
- assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).does_not_raise
643
+ assert_that { Assert.stub(subject, :noargs).with(1){ } }.does_not_raise
644
644
 
645
- assert_that(-> { Assert.stub(subject, :withargs).with{ } }).does_not_raise
646
- assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).does_not_raise
645
+ assert_that { Assert.stub(subject, :withargs).with{ } }.does_not_raise
646
+ assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.does_not_raise
647
647
 
648
- assert_that(-> { Assert.stub(subject, :minargs).with{ } }).does_not_raise
649
- assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).does_not_raise
648
+ assert_that { Assert.stub(subject, :minargs).with{ } }.does_not_raise
649
+ assert_that { Assert.stub(subject, :minargs).with(1){ } }.does_not_raise
650
650
 
651
- assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).does_not_raise
651
+ assert_that { Assert.stub(subject, :withblock).with(1){ } }.does_not_raise
652
652
  end
653
653
 
654
654
  should "allow calling methods with invalid arity" do
655
- assert_that(-> { subject.noargs(1) }).does_not_raise
655
+ assert_that { subject.noargs(1) }.does_not_raise
656
656
 
657
- assert_that(-> { subject.withargs }).does_not_raise
658
- assert_that(-> { subject.withargs(1, 2) }).does_not_raise
657
+ assert_that { subject.withargs }.does_not_raise
658
+ assert_that { subject.withargs(1, 2) }.does_not_raise
659
659
 
660
- assert_that(-> { subject.minargs }).does_not_raise
661
- assert_that(-> { subject.minargs(1) }).does_not_raise
660
+ assert_that { subject.minargs }.does_not_raise
661
+ assert_that { subject.minargs(1) }.does_not_raise
662
662
 
663
- assert_that(-> { subject.withblock(1) }).does_not_raise
663
+ assert_that { subject.withblock(1) }.does_not_raise
664
664
  end
665
665
  end
666
666
 
@@ -18,12 +18,14 @@ class Assert::ActualValue
18
18
 
19
19
  should have_imeths :returns_true, :does_not_return_true
20
20
  should have_imeths :raises, :does_not_raise
21
+ should have_imeths :changes, :does_not_change
21
22
  should have_imeths :is_a_kind_of, :is_not_a_kind_of
22
23
  should have_imeths :is_kind_of, :is_not_kind_of
23
24
  should have_imeths :is_an_instance_of, :is_not_an_instance_of
24
25
  should have_imeths :is_instance_of, :is_not_instance_of
25
26
  should have_imeths :responds_to, :does_not_respond_to
26
27
  should have_imeths :is_the_same_as, :is_not_the_same_as
28
+ should have_imeths :is, :is_not
27
29
  should have_imeths :equals, :does_not_equal
28
30
  should have_imeths :is_equal_to, :is_not_equal_to
29
31
  should have_imeths :matches, :does_not_match
@@ -78,6 +80,24 @@ class Assert::ActualValue
78
80
  assert_equal value, call.block
79
81
  end
80
82
 
83
+ assert_calls(
84
+ :assert_changes,
85
+ when_calling: :changes,
86
+ on_value: -> {}
87
+ ) do |value, call|
88
+ assert_equal args1, call.args
89
+ assert_equal value, call.block
90
+ end
91
+
92
+ assert_calls(
93
+ :assert_not_changes,
94
+ when_calling: :does_not_change,
95
+ on_value: -> {}
96
+ ) do |value, call|
97
+ assert_equal args1, call.args
98
+ assert_equal value, call.block
99
+ end
100
+
81
101
  assert_calls(
82
102
  :assert_kind_of,
83
103
  when_calling: [:is_a_kind_of, String],
@@ -166,6 +186,14 @@ class Assert::ActualValue
166
186
  assert_equal ["something", value, *args1], call.args
167
187
  end
168
188
 
189
+ assert_calls(
190
+ :assert_same,
191
+ when_calling: [:is, "something"],
192
+ on_value: actual_value1
193
+ ) do |value, call|
194
+ assert_equal ["something", value, *args1], call.args
195
+ end
196
+
169
197
  assert_calls(
170
198
  :assert_not_same,
171
199
  when_calling: [:is_not_the_same_as, "something"],
@@ -174,6 +202,14 @@ class Assert::ActualValue
174
202
  assert_equal ["something", value, *args1], call.args
175
203
  end
176
204
 
205
+ assert_calls(
206
+ :assert_not_same,
207
+ when_calling: [:is_not, "something"],
208
+ on_value: actual_value1
209
+ ) do |value, call|
210
+ assert_equal ["something", value, *args1], call.args
211
+ end
212
+
177
213
  assert_calls(
178
214
  :assert_equal,
179
215
  when_calling: [:equals, "something"],
@@ -19,9 +19,9 @@ module Assert
19
19
  end
20
20
 
21
21
  should "map its view, suite and runner to its config" do
22
- assert_that(subject.view).is_the_same_as(subject.config.view)
23
- assert_that(subject.suite).is_the_same_as(subject.config.suite)
24
- assert_that(subject.runner).is_the_same_as(subject.config.runner)
22
+ assert_that(subject.view).is(subject.config.view)
23
+ assert_that(subject.suite).is(subject.config.suite)
24
+ assert_that(subject.runner).is(subject.config.runner)
25
25
  end
26
26
 
27
27
  # Note: don't really need to explicitly test the configure method as
@@ -29,18 +29,6 @@ module Assert
29
29
  end
30
30
 
31
31
  class StubTests < UnitTests
32
- # setup do
33
- # orig_value1 = Factory.string
34
- # stub_value1 = Factory.string
35
-
36
- # @myclass =
37
- # Class.new do
38
- # def initialize(value); @value = value; end
39
- # def mymeth; @value; end
40
- # end
41
- # object1 = @myclass.new(orig_value1)
42
- # end
43
-
44
32
  let(:class1) {
45
33
  Class.new do
46
34
  def initialize(value); @value = value; end
@@ -71,12 +59,12 @@ module Assert
71
59
  should "lookup stubs that have been called before" do
72
60
  stub1 = Assert.stub(object1, :mymeth)
73
61
  stub2 = Assert.stub(object1, :mymeth)
74
- assert_that(stub2).is_the_same_as(stub1)
62
+ assert_that(stub2).is(stub1)
75
63
  end
76
64
 
77
65
  should "set the stub's do block if given a block" do
78
66
  Assert.stub(object1, :mymeth)
79
- assert_that(-> { object1.mymeth }).raises(MuchStub::NotStubbedError)
67
+ assert_that { object1.mymeth }.raises(MuchStub::NotStubbedError)
80
68
  Assert.stub(object1, :mymeth){ stub_value1 }
81
69
  assert_that(object1.mymeth).equals(stub_value1)
82
70
  end
@@ -121,8 +109,9 @@ module Assert
121
109
 
122
110
  should "be able to call a stub's original method" do
123
111
  err =
124
- assert_that(-> { Assert.stub_send(object1, :mymeth) }).
125
- raises(MuchStub::NotStubbedError)
112
+ assert_that {
113
+ Assert.stub_send(object1, :mymeth)
114
+ }.raises(MuchStub::NotStubbedError)
126
115
  assert_that(err.message).includes("not stubbed.")
127
116
  assert_that(err.backtrace.first).includes("test/unit/assert_tests.rb")
128
117
 
@@ -0,0 +1,97 @@
1
+ require "assert"
2
+ require "assert/assertions"
3
+
4
+ module Assert::Assertions
5
+ class AssertChangesTests < Assert::Context
6
+ include Assert::Test::TestHelpers
7
+
8
+ desc "`assert_changes`"
9
+ subject {
10
+ desc = desc1
11
+ Factory.test do
12
+ @my_var = 1
13
+ assert_changes("@my_var", from: 1, to: 2) { @my_var = 2 } # pass
14
+ @my_var = 1
15
+ assert_changes("@my_var", from: 1) { @my_var = 2 } # pass
16
+ @my_var = 1
17
+ assert_changes("@my_var", to: 2) { @my_var = 2 } # pass
18
+ @my_var = 1
19
+ assert_changes("@my_var", desc: desc) { @my_var = 2 } # pass
20
+
21
+ @my_var = 1
22
+ assert_changes("@my_var", from: 2, to: 1) { @my_var = 2 } # fail
23
+ @my_var = 1
24
+ assert_changes("@my_var", from: 2) { @my_var = 2 } # fail
25
+ @my_var = 1
26
+ assert_changes("@my_var", to: 1) { @my_var = 2 } # fail
27
+ @my_var = 1
28
+ assert_changes("@my_var", desc: desc) { @my_var = 1 } # fail
29
+ end
30
+ }
31
+
32
+ let(:desc1) { "assert changes fail desc" }
33
+
34
+ should "produce results as expected" do
35
+ subject.run(&test_run_callback)
36
+
37
+ assert_that(test_run_result_count).equals(10)
38
+ assert_that(test_run_result_count(:pass)).equals(5)
39
+ assert_that(test_run_result_count(:fail)).equals(5)
40
+
41
+ exp =
42
+ [
43
+ "Expected `@my_var` to change from `2`",
44
+ "Expected `@my_var` to change to `1`",
45
+ "Expected `@my_var` to change from `2`",
46
+ "Expected `@my_var` to change to `1`",
47
+ "#{desc1}\nExpected `@my_var` to change; "\
48
+ "it was `1` and didn't change",
49
+ ]
50
+ messages = test_run_results(:fail).map(&:message)
51
+ messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
52
+ end
53
+ end
54
+
55
+ class AssertNotChangesTests < Assert::Context
56
+ include Assert::Test::TestHelpers
57
+
58
+ desc "`assert_changes`"
59
+ subject {
60
+ desc = desc1
61
+ Factory.test do
62
+ @my_var = 1
63
+ assert_not_changes("@my_var", from: 1) { @my_var = 1 } # pass
64
+ @my_var = 1
65
+ assert_not_changes("@my_var", desc: desc) { @my_var = 1 } # pass
66
+
67
+ @my_var = 1
68
+ assert_not_changes("@my_var", from: 2) { @my_var = 1 } # fail
69
+ @my_var = 1
70
+ assert_not_changes("@my_var", from: 1) { @my_var = 2 } # fail
71
+ @my_var = 1
72
+ assert_not_changes("@my_var", desc: desc) { @my_var = 2 } # fail
73
+ end
74
+ }
75
+
76
+ let(:desc1) { "assert not changes fail desc" }
77
+
78
+ should "produce results as expected" do
79
+ subject.run(&test_run_callback)
80
+
81
+ assert_that(test_run_result_count).equals(8)
82
+ assert_that(test_run_result_count(:pass)).equals(5)
83
+ assert_that(test_run_result_count(:fail)).equals(3)
84
+
85
+ exp =
86
+ [
87
+ "Expected `@my_var` to not change from `2`",
88
+ "Expected `@my_var` to not change; "\
89
+ "it was `1` and changed to `2`",
90
+ "#{desc1}\nExpected `@my_var` to not change; "\
91
+ "it was `1` and changed to `2`",
92
+ ]
93
+ messages = test_run_results(:fail).map(&:message)
94
+ messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
95
+ end
96
+ end
97
+ end
@@ -69,8 +69,28 @@ module Assert::Assertions
69
69
 
70
70
  desc "with objects that define custom equality operators"
71
71
 
72
- let(:is_class) { Class.new do; def ==(other); true; end; end }
73
- let(:is_not_class) { Class.new do; def ==(other); false; end; end }
72
+ let(:is_class) {
73
+ Class.new do
74
+ def ==(other)
75
+ if other.is_a?(Assert::ActualValue.not_given.class)
76
+ super
77
+ else
78
+ true
79
+ end
80
+ end
81
+ end
82
+ }
83
+ let(:is_not_class) {
84
+ Class.new do
85
+ def ==(other)
86
+ if other.is_a?(Assert::ActualValue.not_given.class)
87
+ super
88
+ else
89
+ false
90
+ end
91
+ end
92
+ end
93
+ }
74
94
 
75
95
  let(:is1) { is_class.new }
76
96
  let(:is_not1) { is_not_class.new }
@@ -27,10 +27,11 @@ module Assert::Assertions
27
27
  assert_that(test_run_result_count(:fail)).equals(4)
28
28
 
29
29
  exp =
30
- [ "#{desc1}\nStandardError or RuntimeError exception expected, not:",
30
+ [
31
+ "#{desc1}\nStandardError or RuntimeError exception expected, not:",
31
32
  "#{desc1}\nRuntimeError exception expected, not:",
32
33
  "#{desc1}\nRuntimeError exception expected but nothing raised.",
33
- "#{desc1}\nAn exception expected but nothing raised."
34
+ "#{desc1}\nAn exception expected but nothing raised.",
34
35
  ]
35
36
  messages = test_run_results(:fail).map(&:message)
36
37
  messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
@@ -81,8 +82,9 @@ module Assert::Assertions
81
82
  assert_that(test_run_result_count(:fail)).equals(2)
82
83
 
83
84
  exp =
84
- [ "#{desc1}\nStandardError or RuntimeError exception not expected, but raised:",
85
- "#{desc1}\nAn exception not expected, but raised:"
85
+ [
86
+ "#{desc1}\nStandardError or RuntimeError exception not expected, but raised:",
87
+ "#{desc1}\nAn exception not expected, but raised:",
86
88
  ]
87
89
  messages = test_run_results(:fail).map(&:message)
88
90
  messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
@@ -12,24 +12,25 @@ module Assert::Assertions
12
12
  let(:test1) { Factory.test }
13
13
 
14
14
  should have_imeths :assert_block, :assert_not_block, :refute_block
15
- should have_imeths :assert_raises, :assert_not_raises
16
- should have_imeths :assert_raise, :assert_not_raise, :assert_nothing_raised
17
- should have_imeths :assert_kind_of, :assert_not_kind_of, :refute_kind_of
18
- should have_imeths :assert_instance_of, :assert_not_instance_of, :refute_instance_of
19
- should have_imeths :assert_respond_to, :assert_responds_to
20
- should have_imeths :assert_not_respond_to, :assert_not_responds_to
21
- should have_imeths :refute_respond_to, :refute_responds_to
22
- should have_imeths :assert_same, :assert_not_same, :refute_same
23
- should have_imeths :assert_equal, :assert_not_equal, :refute_equal
24
- should have_imeths :assert_match, :assert_not_match, :assert_no_match, :refute_match
25
15
  should have_imeths :assert_empty, :assert_not_empty, :refute_empty
16
+ should have_imeths :assert_equal, :assert_not_equal, :refute_equal
17
+ should have_imeths :assert_file_exists, :assert_not_file_exists, :refute_file_exists
26
18
  should have_imeths :assert_includes, :assert_not_includes
27
19
  should have_imeths :assert_included, :assert_not_included
28
20
  should have_imeths :refute_includes, :refute_included
21
+ should have_imeths :assert_instance_of, :assert_not_instance_of, :refute_instance_of
22
+ should have_imeths :assert_kind_of, :assert_not_kind_of, :refute_kind_of
23
+ should have_imeths :assert_match, :assert_not_match, :assert_no_match, :refute_match
29
24
  should have_imeths :assert_nil, :assert_not_nil, :refute_nil
30
25
  should have_imeths :assert_true, :assert_not_true, :refute_true
31
26
  should have_imeths :assert_false, :assert_not_false, :refute_false
32
- should have_imeths :assert_file_exists, :assert_not_file_exists, :refute_file_exists
27
+ should have_imeths :assert_raises, :assert_not_raises
28
+ should have_imeths :assert_raise, :assert_not_raise, :assert_nothing_raised
29
+ should have_imeths :assert_changes, :assert_not_changes, :refute_changes
30
+ should have_imeths :assert_respond_to, :assert_responds_to
31
+ should have_imeths :assert_not_respond_to, :assert_not_responds_to
32
+ should have_imeths :refute_respond_to, :refute_responds_to
33
+ should have_imeths :assert_same, :assert_not_same, :refute_same
33
34
  end
34
35
 
35
36
  class IgnoredTests < UnitTests
@@ -49,10 +49,10 @@ module Assert::ConfigHelpers
49
49
  end
50
50
 
51
51
  should "know if it is in single test mode" do
52
- Assert.stub(subject.config, :single_test?){ true }
52
+ Assert.stub(subject.config, :single_test?) { true }
53
53
  assert_that(subject.single_test?).is_true
54
54
 
55
- Assert.stub(subject.config, :single_test?){ false }
55
+ Assert.stub(subject.config, :single_test?) { false }
56
56
  assert_that(subject.single_test?).is_false
57
57
  end
58
58
 
@@ -124,8 +124,9 @@ module Assert::Context::TestDSL
124
124
  context, test = build_eval_context{ test_eventually(m) }
125
125
 
126
126
  assert_that(context.class.suite.tests_to_run_count).equals(1)
127
- assert_that(-> { context.instance_eval(&test.code) }).
128
- raises(Assert::Result::TestSkipped)
127
+ assert_that {
128
+ context.instance_eval(&test.code)
129
+ }.raises(Assert::Result::TestSkipped)
129
130
  end
130
131
 
131
132
  should "build a test that skips from a macro using `should_eventually`" do
@@ -134,8 +135,9 @@ module Assert::Context::TestDSL
134
135
  context, test = build_eval_context{ should_eventually(m) }
135
136
 
136
137
  assert_that(context.class.suite.tests_to_run_count).equals(1)
137
- assert_that(-> { context.instance_eval(&test.code) }).
138
- raises(Assert::Result::TestSkipped)
138
+ assert_that {
139
+ context.instance_eval(&test.code)
140
+ }.raises(Assert::Result::TestSkipped)
139
141
  end
140
142
 
141
143
  private
@@ -31,7 +31,7 @@ class Assert::Macro
31
31
  end
32
32
 
33
33
  should "complain if you create a macro without a block" do
34
- assert_that(-> { unit_class.new }).raises(ArgumentError)
34
+ assert_that { unit_class.new }.raises(ArgumentError)
35
35
  end
36
36
  end
37
37
 
@@ -302,7 +302,7 @@ module Assert::Result
302
302
  end
303
303
 
304
304
  should "not allow creating for a test with non-TestFailure exceptions" do
305
- assert_that(-> { Fail.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
305
+ assert_that { Fail.for_test(test1, RuntimeError.new) }.raises(ArgumentError)
306
306
  end
307
307
  end
308
308
 
@@ -348,7 +348,7 @@ module Assert::Result
348
348
  end
349
349
 
350
350
  should "not allow creating for a test with non-TestSkipped exceptions" do
351
- assert_that(-> { Skip.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
351
+ assert_that { Skip.for_test(test1, RuntimeError.new) }.raises(ArgumentError)
352
352
  end
353
353
  end
354
354
 
@@ -375,7 +375,7 @@ module Assert::Result
375
375
  end
376
376
 
377
377
  should "not allow creating for a test without an exception" do
378
- assert_that(-> { Error.for_test(test1, Factory.string) }).raises(ArgumentError)
378
+ assert_that { Error.for_test(test1, Factory.string) }.raises(ArgumentError)
379
379
  end
380
380
  end
381
381
 
@@ -15,11 +15,6 @@ class Assert::Suite
15
15
  should "include the config helpers" do
16
16
  assert_that(subject).includes(Assert::ConfigHelpers)
17
17
  end
18
-
19
- should "know its test method regex" do
20
- assert_that(subject::TEST_METHOD_REGEX).matches("test#{Factory.string}")
21
- assert_that(subject::TEST_METHOD_REGEX).does_not_match("#{Factory.string}test")
22
- end
23
18
  end
24
19
 
25
20
  class InitTests < UnitTests
@@ -28,7 +23,7 @@ class Assert::Suite
28
23
 
29
24
  let(:config1) { Factory.modes_off_config }
30
25
 
31
- should have_readers :config, :test_methods, :setups, :teardowns
26
+ should have_readers :config, :setups, :teardowns
32
27
  should have_accessors :start_time, :end_time
33
28
  should have_imeths :suite, :setup, :startup, :teardown, :shutdown
34
29
  should have_imeths :tests_to_run?, :tests_to_run_count, :clear_tests_to_run
@@ -46,7 +41,6 @@ class Assert::Suite
46
41
  end
47
42
 
48
43
  should "default its attrs" do
49
- assert_that(subject.test_methods).equals([])
50
44
  assert_that(subject.setups).equals([])
51
45
  assert_that(subject.teardowns).equals([])
52
46
 
@@ -134,14 +128,14 @@ class Assert::Suite
134
128
 
135
129
  should "find a test to run given a file line" do
136
130
  test = tests1.sample
137
- assert_that(subject.find_test_to_run(test.file_line)).is_the_same_as(test)
131
+ assert_that(subject.find_test_to_run(test.file_line)).is(test)
138
132
  end
139
133
 
140
134
  should "know its sorted tests to run" do
141
135
  sorted_tests = subject.sorted_tests_to_run{ 1 }
142
136
  assert_that(sorted_tests.size).equals(tests1.size)
143
137
  assert_that(sorted_tests.first).is_kind_of(Assert::Test)
144
- assert_that(subject.sorted_tests_to_run{ 1 }.first).is_the_same_as(sorted_tests.first)
138
+ assert_that(subject.sorted_tests_to_run{ 1 }.first).is(sorted_tests.first)
145
139
  end
146
140
  end
147
141
  end
@@ -17,7 +17,7 @@ class Assert::Test
17
17
  let(:config1) { Factory.modes_off_config }
18
18
  let(:test_code1) { proc { assert(true) } }
19
19
 
20
- should have_imeths :name_file_line_context_data, :for_block, :for_method
20
+ should have_imeths :name_file_line_context_data, :for_block
21
21
 
22
22
  should "know how to build the name and file line given context" do
23
23
  test_name = Factory.string
@@ -44,28 +44,6 @@ class Assert::Test
44
44
  assert_that(test.config).equals(config1)
45
45
  assert_that(test.code).equals(test_code1)
46
46
  end
47
-
48
- should "build tests for a method" do
49
- meth = "a_test_method"
50
- test = subject.for_method(meth, context_info1, config1)
51
-
52
- exp = Assert::FileLine.parse(context_info1.called_from)
53
- assert_that(test.file_line).equals(exp)
54
-
55
- exp = context_info1.test_name(meth)
56
- assert_that(test.name).equals(exp)
57
-
58
- assert_that(test.context_info).equals(context_info1)
59
- assert_that(test.config).equals(config1)
60
-
61
- assert_that(test.code).is_kind_of(Proc)
62
- self.instance_eval(&test.code)
63
- assert_that(@a_test_method_called).is_true
64
- end
65
-
66
- def a_test_method
67
- @a_test_method_called = true
68
- end
69
47
  end
70
48
 
71
49
  class InitWithDataTests < UnitTests
@@ -315,21 +293,21 @@ class Assert::Test
315
293
  raise SignalException, "USR1"
316
294
  end
317
295
 
318
- assert_that(-> { test.run }).raises(SignalException)
296
+ assert_that { test.run }.raises(SignalException)
319
297
  end
320
298
 
321
299
  should "raises signal exceptions in the context setup" do
322
300
  test = Factory.test("setup signal test", context_info1){ }
323
301
  test.context_class.setup{ raise SignalException, "INT" }
324
302
 
325
- assert_that(-> { test.run }).raises(SignalException)
303
+ assert_that { test.run }.raises(SignalException)
326
304
  end
327
305
 
328
306
  should "raises signal exceptions in the context teardown" do
329
307
  test = Factory.test("teardown signal test", context_info1){ }
330
308
  test.context_class.teardown{ raise SignalException, "TERM" }
331
309
 
332
- assert_that(-> { test.run }).raises(SignalException)
310
+ assert_that { test.run }.raises(SignalException)
333
311
  end
334
312
  end
335
313
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.4
4
+ version: 2.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-07 00:00:00.000000000 Z
12
+ date: 2020-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: much-factory
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.1.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: much-not-given
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.1.0
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: much-stub
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +109,7 @@ files:
95
109
  - test/unit/actual_value_tests.rb
96
110
  - test/unit/assert_tests.rb
97
111
  - test/unit/assertions/assert_block_tests.rb
112
+ - test/unit/assertions/assert_changes_tests.rb
98
113
  - test/unit/assertions/assert_empty_tests.rb
99
114
  - test/unit/assertions/assert_equal_tests.rb
100
115
  - test/unit/assertions/assert_file_exists_tests.rb
@@ -163,6 +178,7 @@ test_files:
163
178
  - test/unit/actual_value_tests.rb
164
179
  - test/unit/assert_tests.rb
165
180
  - test/unit/assertions/assert_block_tests.rb
181
+ - test/unit/assertions/assert_changes_tests.rb
166
182
  - test/unit/assertions/assert_empty_tests.rb
167
183
  - test/unit/assertions/assert_equal_tests.rb
168
184
  - test/unit/assertions/assert_file_exists_tests.rb