assert 2.18.2 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/assert.gemspec +1 -1
  4. data/lib/assert/actual_value.rb +127 -0
  5. data/lib/assert/assertions.rb +11 -20
  6. data/lib/assert/context.rb +13 -5
  7. data/lib/assert/context/let_dsl.rb +13 -0
  8. data/lib/assert/context/method_missing.rb +19 -0
  9. data/lib/assert/macros/methods.rb +4 -4
  10. data/lib/assert/stub.rb +4 -0
  11. data/lib/assert/version.rb +1 -1
  12. data/test/helper.rb +23 -25
  13. data/test/support/factory.rb +15 -0
  14. data/test/system/stub_tests.rb +348 -333
  15. data/test/system/test_tests.rb +111 -109
  16. data/test/unit/actual_value_tests.rb +335 -0
  17. data/test/unit/assert_tests.rb +84 -59
  18. data/test/unit/assertions/assert_block_tests.rb +32 -31
  19. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  20. data/test/unit/assertions/assert_equal_tests.rb +81 -75
  21. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  22. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  23. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  24. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  25. data/test/unit/assertions/assert_match_tests.rb +36 -33
  26. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  27. data/test/unit/assertions/assert_raises_tests.rb +55 -55
  28. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  29. data/test/unit/assertions/assert_same_tests.rb +91 -80
  30. data/test/unit/assertions/assert_true_false_tests.rb +64 -60
  31. data/test/unit/assertions_tests.rb +15 -13
  32. data/test/unit/config_helpers_tests.rb +36 -35
  33. data/test/unit/config_tests.rb +33 -34
  34. data/test/unit/context/let_dsl_tests.rb +10 -0
  35. data/test/unit/context/setup_dsl_tests.rb +70 -81
  36. data/test/unit/context/subject_dsl_tests.rb +16 -43
  37. data/test/unit/context/suite_dsl_tests.rb +16 -16
  38. data/test/unit/context/test_dsl_tests.rb +50 -54
  39. data/test/unit/context_info_tests.rb +16 -15
  40. data/test/unit/context_tests.rb +170 -157
  41. data/test/unit/default_runner_tests.rb +2 -5
  42. data/test/unit/default_suite_tests.rb +51 -53
  43. data/test/unit/factory_tests.rb +3 -3
  44. data/test/unit/file_line_tests.rb +31 -33
  45. data/test/unit/macro_tests.rb +9 -10
  46. data/test/unit/result_tests.rb +150 -163
  47. data/test/unit/runner_tests.rb +63 -63
  48. data/test/unit/suite_tests.rb +57 -54
  49. data/test/unit/test_tests.rb +134 -126
  50. data/test/unit/utils_tests.rb +41 -45
  51. data/test/unit/view_helpers_tests.rb +55 -52
  52. data/test/unit/view_tests.rb +20 -22
  53. metadata +11 -4
@@ -8,45 +8,46 @@ class Assert::ContextInfo
8
8
  desc "Assert::ContextInfo"
9
9
  setup do
10
10
  @caller = caller
11
- @klass = Assert::Context
12
- @info = Assert::ContextInfo.new(@klass, nil, @caller.first)
13
11
  end
14
- subject{ @info }
12
+ subject { info1 }
13
+
14
+ let(:context1) { Assert::Context }
15
+ let(:info1) { Assert::ContextInfo.new(context1, nil, @caller.first) }
15
16
 
16
17
  should have_readers :called_from, :klass, :file
17
18
  should have_imeths :test_name
18
19
 
19
20
  should "set its klass on init" do
20
- assert_equal @klass, subject.klass
21
+ assert_that(subject.klass).equals(context1)
21
22
  end
22
23
 
23
24
  should "set its called_from to the called_from or first caller on init" do
24
- info = Assert::ContextInfo.new(@klass, @caller.first, nil)
25
- assert_equal @caller.first, info.called_from
25
+ info = Assert::ContextInfo.new(context1, @caller.first, nil)
26
+ assert_that(info.called_from).equals(@caller.first)
26
27
 
27
- info = Assert::ContextInfo.new(@klass, nil, @caller.first)
28
- assert_equal @caller.first, info.called_from
28
+ info = Assert::ContextInfo.new(context1, nil, @caller.first)
29
+ assert_that(info.called_from).equals(@caller.first)
29
30
  end
30
31
 
31
32
  should "set its file from caller info on init" do
32
- assert_equal @caller.first.gsub(/\:[0-9]+.*$/, ""), subject.file
33
+ assert_that(subject.file).equals(@caller.first.gsub(/\:[0-9]+.*$/, ""))
33
34
  end
34
35
 
35
36
  should "not have any file info if no caller is given" do
36
- info = Assert::ContextInfo.new(@klass)
37
- assert_nil info.file
37
+ info = Assert::ContextInfo.new(context1)
38
+ assert_that(info.file).is_nil
38
39
  end
39
40
 
40
41
  should "know how to build the contextual test name for a given name" do
41
42
  desc = Factory.string
42
43
  name = Factory.string
43
44
 
44
- assert_equal name, subject.test_name(name)
45
- assert_equal "", subject.test_name("")
46
- assert_equal "", subject.test_name(nil)
45
+ assert_that(subject.test_name(name)).equals(name)
46
+ assert_that(subject.test_name("")).equals("")
47
+ assert_that(subject.test_name(nil)).equals("")
47
48
 
48
49
  Assert.stub(subject.klass, :description){ desc }
49
- assert_equal "#{desc} #{name}", subject.test_name(name)
50
+ assert_that(subject.test_name(name)).equals("#{desc} #{name}")
50
51
  end
51
52
  end
52
53
  end
@@ -8,21 +8,24 @@ require "assert/utils"
8
8
  class Assert::Context
9
9
  class UnitTests < Assert::Context
10
10
  desc "Assert::Context"
11
+ subject { context1 }
12
+
11
13
  setup do
12
- @test = Factory.test
13
- @context_class = @test.context_class
14
14
  @callback_result = nil
15
- @test_results = []
16
- @result_callback = proc do |result|
17
- @callback_result = result
18
- @test_results << result
19
- end
20
- @context = @context_class.new(@test, @test.config, @result_callback)
21
15
  end
22
- subject{ @context }
16
+
17
+ let(:test1) { Factory.test }
18
+ let(:context_class1) { test1.context_class }
19
+ let(:test_results1) { [] }
20
+ let(:result_callback1) {
21
+ proc { |result| @callback_result = result; test_results1 << result }
22
+ }
23
+ let(:context1) { context_class1.new(test1, test1.config, result_callback1) }
24
+ let(:halt_config1) { Assert::Config.new(:halt_on_fail => true) }
25
+ let(:msg1) { Factory.string }
23
26
 
24
27
  # DSL methods
25
- should have_cmeths :description, :desc, :describe, :subject, :suite
28
+ should have_cmeths :description, :desc, :describe, :subject, :suite, :let
26
29
  should have_cmeths :setup_once, :before_once, :startup
27
30
  should have_cmeths :teardown_once, :after_once, :shutdown
28
31
  should have_cmeths :setup, :before, :setups, :run_setups
@@ -31,322 +34,331 @@ class Assert::Context
31
34
  should have_cmeths :test, :test_eventually, :test_skip
32
35
  should have_cmeths :should, :should_eventually, :should_skip
33
36
 
34
- should have_imeths :assert, :assert_not, :refute
37
+ should have_imeths :assert, :assert_not, :refute, :assert_that
35
38
  should have_imeths :pass, :ignore, :fail, :flunk, :skip
36
39
  should have_imeths :pending, :with_backtrace, :subject
37
40
 
38
41
  should "collect context info" do
39
42
  test = @__assert_running_test__
40
- assert_match(/test\/unit\/context_tests.rb$/, test.context_info.file)
41
- assert_equal self.class, test.context_info.klass
43
+ assert_that(test.context_info.file).matches(/test\/unit\/context_tests.rb$/)
44
+ assert_that(test.context_info.klass).equals(self.class)
42
45
  end
46
+
43
47
  private
44
48
 
45
49
  ASSERT_TEST_PATH_REGEX = /\A#{File.join(ROOT_PATH, "test", "")}/
46
50
 
47
51
  def assert_with_bt_set(exp_with_bt, result)
48
52
  with_backtrace(caller) do
49
- assert_true result.with_bt_set?
53
+ assert_that(result.with_bt_set?).is_true
50
54
 
51
55
  exp = Assert::Result::Backtrace.to_s(exp_with_bt+[(result.backtrace.filtered.first)])
52
- assert_equal exp, result.trace
53
- assert_equal exp_with_bt.first, result.src_line
56
+ assert_that(result.trace).equals(exp)
57
+ assert_that(result.src_line).equals(exp_with_bt.first)
54
58
  end
55
59
  end
56
60
 
57
61
  def assert_not_with_bt_set(result)
58
62
  with_backtrace(caller) do
59
- assert_false result.with_bt_set?
63
+ assert_that(result.with_bt_set?).is_false
60
64
 
61
- assert_equal result.src_line, result.trace
62
- assert_equal result.backtrace.filtered.first.to_s, result.src_line
65
+ assert_that(result.trace).equals(result.src_line)
66
+ assert_that(result.src_line).equals(result.backtrace.filtered.first.to_s)
63
67
  end
64
68
  end
65
69
  end
66
70
 
67
71
  class SkipTests < UnitTests
68
72
  desc "skip method"
73
+ subject { @result }
74
+
69
75
  setup do
70
- @skip_msg = "I need to implement this in the future."
71
- begin; @context.skip(@skip_msg); rescue StandardError => @exception; end
76
+ begin; context1.skip(msg1); rescue StandardError => @exception; end
72
77
  @result = Factory.skip_result(@exception)
73
78
  end
74
- subject{ @result }
75
79
 
76
80
  should "raise a test skipped exception and set its message" do
77
- assert_kind_of Assert::Result::TestSkipped, @exception
78
- assert_equal @skip_msg, @exception.message
79
- assert_equal @skip_msg, subject.message
81
+ assert_that(@exception).is_kind_of(Assert::Result::TestSkipped)
82
+ assert_that(@exception.message).equals(msg1)
83
+ assert_that(subject.message).equals(msg1)
80
84
  end
81
85
 
82
86
  should "not call the result callback" do
83
- assert_nil @callback_result
87
+ assert_that(@callback_result).is_nil
84
88
  end
85
89
 
86
90
  should "use any given called from arg as the exception backtrace" do
87
- assert_not_equal 1, @exception.backtrace.size
91
+ assert_that(@exception.backtrace.size).does_not_equal(1)
88
92
 
89
93
  called_from = Factory.string
90
- begin; @context.skip(@skip_msg, called_from); rescue StandardError => exception; end
91
- assert_equal 1, exception.backtrace.size
92
- assert_equal called_from, exception.backtrace.first
94
+ begin; context1.skip(msg1, called_from); rescue StandardError => exception; end
95
+ assert_that(exception.backtrace.size).equals(1)
96
+ assert_that(exception.backtrace.first).equals(called_from)
93
97
  end
94
98
  end
95
99
 
96
100
  class IgnoreTests < UnitTests
97
101
  desc "ignore method"
102
+ subject { @result }
103
+
98
104
  setup do
99
- @ignore_msg = "Ignore this for now, will do later."
100
- @result = @context.ignore(@ignore_msg)
105
+ @result = context1.ignore(msg1)
101
106
  end
102
- subject{ @result }
103
107
 
104
108
  should "create an ignore result and set its message" do
105
- assert_kind_of Assert::Result::Ignore, subject
106
- assert_equal @ignore_msg, subject.message
109
+ assert_that(subject).is_kind_of(Assert::Result::Ignore)
110
+ assert_that(subject.message).equals(msg1)
107
111
  end
108
112
 
109
113
  should "call the result callback" do
110
- assert_equal @result, @callback_result
114
+ assert_that(@callback_result).equals(@result)
111
115
  end
112
116
  end
113
117
 
114
118
  class PassTests < UnitTests
115
119
  desc "pass method"
120
+ subject { @result }
121
+
116
122
  setup do
117
- @pass_msg = "That's right, it works."
118
- @result = @context.pass(@pass_msg)
123
+ @result = context1.pass(msg1)
119
124
  end
120
- subject{ @result }
121
125
 
122
126
  should "create a pass result and set its message" do
123
- assert_kind_of Assert::Result::Pass, subject
124
- assert_equal @pass_msg, subject.message
127
+ assert_that(subject).is_kind_of(Assert::Result::Pass)
128
+ assert_that(subject.message).equals(msg1)
125
129
  end
126
130
 
127
131
  should "call the result callback" do
128
- assert_equal @result, @callback_result
132
+ assert_that(@callback_result).equals(@result)
129
133
  end
130
134
  end
131
135
 
132
136
  class FlunkTests < UnitTests
133
137
  desc "flunk method"
138
+ subject { @result }
139
+
134
140
  setup do
135
- @flunk_msg = "It flunked."
136
- @result = @context.flunk(@flunk_msg)
141
+ @result = context1.flunk(msg1)
137
142
  end
138
- subject{ @result }
139
143
 
140
144
  should "create a fail result and set its message" do
141
- assert_kind_of Assert::Result::Fail, subject
142
- assert_equal @flunk_msg, subject.message
145
+ assert_that(subject).is_kind_of(Assert::Result::Fail)
146
+ assert_that(subject.message).equals(msg1)
143
147
  end
144
148
 
145
149
  should "call the result callback" do
146
- assert_equal @result, @callback_result
150
+ assert_that(@callback_result).equals(@result)
147
151
  end
148
152
  end
149
153
 
150
154
  class FailTests < UnitTests
151
155
  desc "fail method"
156
+ subject { @result }
157
+
152
158
  setup do
153
- @result = @context.fail
159
+ @result = context1.fail
154
160
  end
155
- subject{ @result }
156
161
 
157
162
  should "create a fail result and set its backtrace" do
158
- assert_kind_of Assert::Result::Fail, subject
159
- assert_equal subject.backtrace.filtered.first.to_s, subject.trace
160
- assert_kind_of Array, subject.backtrace
163
+ assert_that(subject).is_kind_of(Assert::Result::Fail)
164
+ assert_that(subject.trace).equals(subject.backtrace.filtered.first.to_s)
165
+ assert_that(subject.backtrace).is_kind_of(Array)
161
166
  end
162
167
 
163
168
  should "set any given result message" do
164
- fail_msg = "Didn't work"
165
- result = @context.fail(fail_msg)
166
- assert_equal fail_msg, result.message
169
+ result = context1.fail(msg1)
170
+ assert_that(result.message).equals(msg1)
167
171
  end
168
172
 
169
173
  should "call the result callback" do
170
- assert_equal @result, @callback_result
174
+ assert_that(@callback_result).equals(@result)
171
175
  end
172
176
  end
173
177
 
174
178
  class HaltOnFailTests < UnitTests
175
179
  desc "failing when halting on fails"
176
- setup do
177
- @halt_config = Assert::Config.new(:halt_on_fail => true)
178
- @context = @context_class.new(@test, @halt_config, @result_callback)
179
- @fail_msg = "something failed"
180
- end
181
- subject{ @result }
180
+ subject { @result }
181
+
182
+ let(:context1) { context_class1.new(test1, halt_config1, result_callback1) }
182
183
 
183
184
  should "raise an exception with the failure's message" do
184
- begin; @context.fail(@fail_msg); rescue StandardError => err; end
185
- assert_kind_of Assert::Result::TestFailure, err
186
- assert_equal @fail_msg, err.message
185
+ begin; context1.fail(msg1); rescue StandardError => err; end
186
+ assert_that(err).is_kind_of(Assert::Result::TestFailure)
187
+ assert_that(err.message).equals(msg1)
187
188
 
188
189
  result = Assert::Result::Fail.for_test(Factory.test("something"), err)
189
- assert_equal @fail_msg, result.message
190
+ assert_that(result.message).equals(msg1)
190
191
  end
191
192
 
192
193
  should "not call the result callback" do
193
- assert_nil @callback_result
194
+ assert_that(@callback_result).is_nil
194
195
  end
195
196
  end
196
197
 
197
198
  class AssertTests < UnitTests
198
199
  desc "assert method"
199
- setup do
200
- @fail_desc = "my fail desc"
201
- @what_failed = "what failed"
202
- end
200
+
201
+ let(:what_failed) { Factory.string }
203
202
 
204
203
  should "return a pass result given a `true` assertion" do
205
- result = subject.assert(true, @fail_desc){ @what_failed }
206
- assert_kind_of Assert::Result::Pass, result
207
- assert_equal "", result.message
204
+ result = subject.assert(true, msg1){ what_failed }
205
+ assert_that(result).is_kind_of(Assert::Result::Pass)
206
+ assert_that(result.message).equals("")
208
207
  end
209
208
 
210
209
  should "return a fail result given a `false` assertion" do
211
- result = subject.assert(false, @fail_desc){ @what_failed }
212
- assert_kind_of Assert::Result::Fail, result
210
+ result = subject.assert(false, msg1){ what_failed }
211
+ assert_that(result).is_kind_of(Assert::Result::Fail)
213
212
  end
214
213
 
215
214
  should "pp the assertion value in the fail message by default" do
216
- exp_def_what = "Failed assert: assertion was `#{Assert::U.show(false, @test.config)}`."
217
- result = subject.assert(false, @fail_desc)
215
+ exp_def_what = "Failed assert: assertion was `#{Assert::U.show(false, test1.config)}`."
216
+ result = subject.assert(false, msg1)
218
217
 
219
- assert_equal [@fail_desc, exp_def_what].join("\n"), result.message
218
+ assert_that(result.message).equals([msg1, exp_def_what].join("\n"))
220
219
  end
221
220
 
222
221
  should "use a custom fail message if one is given" do
223
- result = subject.assert(false, @fail_desc){ @what_failed }
224
- assert_equal [@fail_desc, @what_failed].join("\n"), result.message
222
+ result = subject.assert(false, msg1){ what_failed }
223
+ assert_that(result.message).equals([msg1, what_failed].join("\n"))
225
224
  end
226
225
 
227
226
  should "return a pass result given a \"truthy\" assertion" do
228
- assert_kind_of Assert::Result::Pass, subject.assert(34)
227
+ assert_that(subject.assert(34)).is_kind_of(Assert::Result::Pass)
229
228
  end
230
229
 
231
230
  should "return a fail result gievn a `nil` assertion" do
232
- assert_kind_of Assert::Result::Fail, subject.assert(nil)
231
+ assert_that(subject.assert(nil)).is_kind_of(Assert::Result::Fail)
233
232
  end
234
233
  end
235
234
 
236
235
  class AssertNotTests < UnitTests
237
236
  desc "assert_not method"
238
- setup do
239
- @fail_desc = "my fail desc"
240
- end
241
237
 
242
238
  should "return a pass result given a `false` assertion" do
243
- result = subject.assert_not(false, @fail_desc)
244
- assert_kind_of Assert::Result::Pass, result
245
- assert_equal "", result.message
239
+ result = subject.assert_not(false, msg1)
240
+ assert_that(result).is_kind_of(Assert::Result::Pass)
241
+ assert_that(result.message).equals("")
246
242
  end
247
243
 
248
244
  should "return a fail result given a `true` assertion" do
249
- result = subject.assert_not(true, @fail_desc)
250
- assert_kind_of Assert::Result::Fail, result
245
+ result = subject.assert_not(true, msg1)
246
+ assert_that(result).is_kind_of(Assert::Result::Fail)
251
247
  end
252
248
 
253
249
  should "pp the assertion value in the fail message by default" do
254
- exp_def_what = "Failed assert_not: assertion was `#{Assert::U.show(true, @test.config)}`."
255
- result = subject.assert_not(true, @fail_desc)
250
+ exp_def_what = "Failed assert_not: assertion was `#{Assert::U.show(true, test1.config)}`."
251
+ result = subject.assert_not(true, msg1)
256
252
 
257
- assert_equal [@fail_desc, exp_def_what].join("\n"), result.message
253
+ assert_that(result.message).equals([msg1, exp_def_what].join("\n"))
258
254
  end
259
255
 
260
256
  should "return a fail result given a \"truthy\" assertion" do
261
- assert_kind_of Assert::Result::Fail, subject.assert_not(34)
257
+ assert_that(subject.assert_not(34)).is_kind_of(Assert::Result::Fail)
262
258
  end
263
259
 
264
260
  should "return a pass result given a `nil` assertion" do
265
- assert_kind_of Assert::Result::Pass, subject.assert_not(nil)
261
+ assert_that(subject.assert_not(nil)).is_kind_of(Assert::Result::Pass)
262
+ end
263
+ end
264
+
265
+ class AssertThatTests < UnitTests
266
+ desc "`assert_that` method"
267
+
268
+ setup do
269
+ Assert.stub_tap_on_call(Assert::ActualValue, :new) { |_, call|
270
+ @actual_value_new_call = call
271
+ }
272
+ end
273
+
274
+ let(:actual_value) { Factory.string }
275
+
276
+ should "build an Assert::ActualValue" do
277
+ assert_instance_of Assert::ActualValue, subject.assert_that(actual_value)
278
+ assert_equal [actual_value], @actual_value_new_call.pargs
279
+ assert_equal({ context: context1 }, @actual_value_new_call.kargs)
266
280
  end
267
281
  end
268
282
 
269
283
  class SubjectTests < UnitTests
270
284
  desc "subject method"
285
+ subject { @subject }
286
+
271
287
  setup do
272
- expected = @expected = "amazing"
273
- @context_class = Factory.modes_off_context_class do
274
- subject{ @something = expected }
275
- end
276
- @context = @context_class.new(@test, @test.config, proc{ |result| })
277
- @subject = @context.subject
288
+ expected = expected1
289
+ context_class1.subject { @something = expected }
290
+ @subject = context1.subject
278
291
  end
279
- subject{ @subject }
292
+
293
+ let(:context_class1) { Factory.modes_off_context_class }
294
+ let(:context1) { context_class1.new(test1, test1.config, proc{ |result| }) }
295
+ let(:expected1) { Factory.string }
280
296
 
281
297
  should "instance evaluate the block set with the class setup method" do
282
- assert_equal @expected, subject
298
+ assert_that(subject).equals(expected1)
283
299
  end
284
300
  end
285
301
 
286
302
  class PendingTests < UnitTests
287
303
  desc "`pending` method"
288
- setup do
289
- block2 = proc { fail; pass; }
290
- @block1 = proc { pending(&block2) } # test nesting
291
- end
304
+
305
+ let(:block2) { proc { fail; pass; } }
306
+ let(:block1) { block = block2; proc { pending(&block) } } # test nesting
292
307
 
293
308
  should "make fails skips and make passes fails" do
294
- @context.fail "not affected"
295
- @context.pass
296
- @context.pending(&@block1)
309
+ context1.fail "not affected"
310
+ context1.pass
311
+ context1.pending(&block1)
297
312
 
298
- assert_equal 4, @test_results.size
299
- norm_fail, norm_pass, pending_fail, pending_pass = @test_results
313
+ assert_that(test_results1.size).equals(4)
314
+ norm_fail, norm_pass, pending_fail, pending_pass = test_results1
300
315
 
301
- assert_kind_of Assert::Result::Fail, norm_fail
302
- assert_kind_of Assert::Result::Pass, norm_pass
316
+ assert_that(norm_fail).is_kind_of(Assert::Result::Fail)
317
+ assert_that(norm_pass).is_kind_of(Assert::Result::Pass)
303
318
 
304
- assert_kind_of Assert::Result::Skip, pending_fail
305
- assert_includes "Pending fail", pending_fail.message
319
+ assert_that(pending_fail).is_kind_of(Assert::Result::Skip)
320
+ assert_that(pending_fail.message).includes("Pending fail")
306
321
 
307
- assert_kind_of Assert::Result::Fail, pending_pass
308
- assert_includes "Pending pass", pending_pass.message
322
+ assert_that(pending_pass).is_kind_of(Assert::Result::Fail)
323
+ assert_that(pending_pass.message).includes("Pending pass")
309
324
  end
310
325
  end
311
326
 
312
327
  class PendingWithHaltOnFailTests < PendingTests
313
328
  desc "when halting on fails"
314
- setup do
315
- @halt_config = Assert::Config.new(:halt_on_fail => true)
316
- @context = @context_class.new(@test, @halt_config, @result_callback)
317
- end
318
- subject{ @result }
329
+ subject { @result }
330
+
331
+ let(:context1) { context_class1.new(test1, halt_config1, result_callback1) }
319
332
 
320
333
  should "make fails skips and stop the test" do
321
- begin; @context.pending(&@block1); rescue StandardError => err; end
322
- assert_kind_of Assert::Result::TestSkipped, err
323
- assert_includes "Pending fail", err.message
334
+ begin; context1.pending(&block1); rescue StandardError => err; end
335
+ assert_that(err).is_kind_of(Assert::Result::TestSkipped)
336
+ assert_that(err.message).includes("Pending fail")
324
337
 
325
- assert_equal 0, @test_results.size # it halted before the pending pass
338
+ assert_that(test_results1.size).equals(0) # it halted before the pending pass
326
339
  end
327
340
  end
328
341
 
329
342
  class WithBacktraceTests < UnitTests
330
343
  desc "`with_backtrace` method"
331
- setup do
332
- @from_bt = ["called_from_here", Factory.string]
333
- @from_block = proc { ignore; fail; pass; skip "todo"; }
334
- end
344
+
345
+ let(:from_bt1) { ["called_from_here", Factory.string] }
346
+ let(:from_block1) { proc { ignore; fail; pass; skip "todo"; } }
335
347
 
336
348
  should "alter non-error block results' bt with given bt's first line" do
337
- @context.fail "not affected"
349
+ context1.fail "not affected"
338
350
  begin
339
- @context.with_backtrace(@from_bt, &@from_block)
351
+ context1.with_backtrace(from_bt1, &from_block1)
340
352
  rescue Assert::Result::TestSkipped => e
341
- @test_results << Assert::Result::Skip.for_test(@test, e)
353
+ test_results1 << Assert::Result::Skip.for_test(test1, e)
342
354
  end
343
355
 
344
- assert_equal 5, @test_results.size
345
- norm_fail, with_ignore, with_fail, with_pass, _with_skip = @test_results
356
+ assert_that(test_results1.size).equals(5)
357
+ norm_fail, with_ignore, with_fail, with_pass, _with_skip = test_results1
346
358
 
347
359
  assert_not_with_bt_set norm_fail
348
360
 
349
- exp = [@from_bt.first]
361
+ exp = [from_bt1.first]
350
362
  assert_with_bt_set exp, with_ignore
351
363
  assert_with_bt_set exp, with_fail
352
364
  assert_with_bt_set exp, with_pass
@@ -356,28 +368,30 @@ class Assert::Context
356
368
 
357
369
  class WithNestedBacktraceTests < UnitTests
358
370
  desc "`with_backtrace` method nested"
359
- setup do
360
- @from_bt1 = ["called_from_here 1", Factory.string]
361
- @from_bt2 = from_bt2 = ["called_from_here 2", Factory.string]
362
371
 
363
- from_block2 = proc { ignore; fail; pass; skip "todo"; }
364
- @from_block1 = proc { with_backtrace(from_bt2, &from_block2) }
365
- end
372
+ let(:from_bt1) { ["called_from_here 1", Factory.string] }
373
+ let(:from_bt2) { ["called_from_here 2", Factory.string] }
374
+ let(:from_block2) { proc { ignore; fail; pass; skip "todo"; } }
375
+ let(:from_block1) {
376
+ from_bt = from_bt2
377
+ from_block = from_block2
378
+ proc { with_backtrace(from_bt, &from_block) }
379
+ }
366
380
 
367
381
  should "alter non-error block results' bt with nested wbt accrued first lines" do
368
- @context.fail "not affected"
382
+ context1.fail "not affected"
369
383
  begin
370
- @context.with_backtrace(@from_bt1, &@from_block1)
384
+ context1.with_backtrace(from_bt1, &from_block1)
371
385
  rescue Assert::Result::TestSkipped => e
372
- @test_results << Assert::Result::Skip.for_test(@test, e)
386
+ test_results1 << Assert::Result::Skip.for_test(test1, e)
373
387
  end
374
388
 
375
- assert_equal 5, @test_results.size
376
- norm_fail, with_ignore, with_fail, with_pass, with_skip = @test_results
389
+ assert_that(test_results1.size).equals(5)
390
+ norm_fail, with_ignore, with_fail, with_pass, _with_skip = test_results1
377
391
 
378
392
  assert_not_with_bt_set norm_fail
379
393
 
380
- exp = [@from_bt1.first, @from_bt2.first]
394
+ exp = [from_bt1.first, from_bt2.first]
381
395
  assert_with_bt_set exp, with_ignore
382
396
  assert_with_bt_set exp, with_fail
383
397
  assert_with_bt_set exp, with_pass
@@ -387,14 +401,13 @@ class Assert::Context
387
401
 
388
402
  class InspectTests < UnitTests
389
403
  desc "inspect method"
390
- setup do
391
- @expected = "#<#{@context.class}>"
392
- @inspect = @context.inspect
393
- end
394
- subject{ @inspect }
404
+ subject { inspect1 }
405
+
406
+ let(:inspect1) { context1.inspect }
395
407
 
396
408
  should "just show the name of the class" do
397
- assert_equal @expected, subject
409
+ exp = "#<#{context1.class}>"
410
+ assert_that(subject).equals(exp)
398
411
  end
399
412
  end
400
413
  end