assert 2.18.4 → 2.19.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/assert.gemspec +11 -5
  4. data/bin/assert +1 -0
  5. data/lib/assert.rb +20 -6
  6. data/lib/assert/actual_value.rb +26 -8
  7. data/lib/assert/assert_runner.rb +38 -17
  8. data/lib/assert/assertions.rb +145 -41
  9. data/lib/assert/cli.rb +19 -66
  10. data/lib/assert/clirb.rb +55 -0
  11. data/lib/assert/config.rb +22 -8
  12. data/lib/assert/config_helpers.rb +57 -22
  13. data/lib/assert/context.rb +28 -47
  14. data/lib/assert/context/let_dsl.rb +8 -2
  15. data/lib/assert/context/method_missing.rb +3 -0
  16. data/lib/assert/context/setup_dsl.rb +24 -16
  17. data/lib/assert/context/subject_dsl.rb +9 -7
  18. data/lib/assert/context/suite_dsl.rb +5 -1
  19. data/lib/assert/context/test_dsl.rb +58 -19
  20. data/lib/assert/context_info.rb +2 -0
  21. data/lib/assert/default_runner.rb +2 -0
  22. data/lib/assert/default_suite.rb +27 -15
  23. data/lib/assert/default_view.rb +49 -30
  24. data/lib/assert/factory.rb +2 -0
  25. data/lib/assert/file_line.rb +8 -6
  26. data/lib/assert/macro.rb +3 -1
  27. data/lib/assert/macros/methods.rb +73 -45
  28. data/lib/assert/result.rb +117 -61
  29. data/lib/assert/runner.rb +70 -51
  30. data/lib/assert/stub.rb +44 -3
  31. data/lib/assert/suite.rb +76 -38
  32. data/lib/assert/test.rb +43 -44
  33. data/lib/assert/utils.rb +22 -11
  34. data/lib/assert/version.rb +3 -1
  35. data/lib/assert/view.rb +46 -18
  36. data/lib/assert/view_helpers.rb +102 -92
  37. data/test/helper.rb +8 -4
  38. data/test/support/factory.rb +40 -21
  39. data/test/support/inherited_stuff.rb +2 -0
  40. data/test/system/stub_tests.rb +182 -144
  41. data/test/system/test_tests.rb +88 -60
  42. data/test/unit/actual_value_tests.rb +103 -46
  43. data/test/unit/assert_tests.rb +48 -40
  44. data/test/unit/assertions/assert_block_tests.rb +12 -10
  45. data/test/unit/assertions/assert_changes_tests.rb +103 -0
  46. data/test/unit/assertions/assert_empty_tests.rb +16 -12
  47. data/test/unit/assertions/assert_equal_tests.rb +46 -24
  48. data/test/unit/assertions/assert_file_exists_tests.rb +17 -13
  49. data/test/unit/assertions/assert_includes_tests.rb +12 -10
  50. data/test/unit/assertions/assert_instance_of_tests.rb +16 -14
  51. data/test/unit/assertions/assert_is_a_tests.rb +128 -0
  52. data/test/unit/assertions/assert_match_tests.rb +12 -10
  53. data/test/unit/assertions/assert_nil_tests.rb +18 -12
  54. data/test/unit/assertions/assert_raises_tests.rb +34 -23
  55. data/test/unit/assertions/assert_respond_to_tests.rb +12 -10
  56. data/test/unit/assertions/assert_same_tests.rb +26 -24
  57. data/test/unit/assertions/assert_true_false_tests.rb +34 -24
  58. data/test/unit/assertions_tests.rb +25 -17
  59. data/test/unit/config_helpers_tests.rb +15 -8
  60. data/test/unit/config_tests.rb +36 -9
  61. data/test/unit/context/let_dsl_tests.rb +2 -0
  62. data/test/unit/context/setup_dsl_tests.rb +26 -14
  63. data/test/unit/context/subject_dsl_tests.rb +5 -3
  64. data/test/unit/context/suite_dsl_tests.rb +6 -4
  65. data/test/unit/context/test_dsl_tests.rb +43 -19
  66. data/test/unit/context_info_tests.rb +6 -4
  67. data/test/unit/context_tests.rb +112 -54
  68. data/test/unit/default_runner_tests.rb +2 -0
  69. data/test/unit/default_suite_tests.rb +12 -6
  70. data/test/unit/factory_tests.rb +4 -2
  71. data/test/unit/file_line_tests.rb +9 -7
  72. data/test/unit/macro_tests.rb +13 -11
  73. data/test/unit/result_tests.rb +49 -41
  74. data/test/unit/runner_tests.rb +33 -18
  75. data/test/unit/suite_tests.rb +42 -24
  76. data/test/unit/test_tests.rb +66 -73
  77. data/test/unit/utils_tests.rb +52 -37
  78. data/test/unit/view_helpers_tests.rb +23 -14
  79. data/test/unit/view_tests.rb +7 -5
  80. metadata +40 -9
  81. data/test/unit/assertions/assert_kind_of_tests.rb +0 -66
@@ -1,17 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/macro"
3
5
 
4
6
  class Assert::Macro
5
7
  class UnitTests < Assert::Context
6
8
  desc "Assert::Macro"
7
- subject { unit_class }
9
+ subject{ unit_class }
8
10
 
9
- let(:unit_class) { Assert::Macro }
11
+ let(:unit_class){ Assert::Macro }
10
12
  end
11
13
 
12
14
  class InitTests < UnitTests
13
15
  desc "when init"
14
- subject { unit_class.new {} }
16
+ subject{ unit_class.new{} }
15
17
 
16
18
  should "have an accessor for its (optional) name" do
17
19
  assert_that(subject).responds_to(:name)
@@ -19,11 +21,11 @@ class Assert::Macro
19
21
  end
20
22
 
21
23
  should "default its name if no given" do
22
- assert_that((unit_class.new {}).name).equals("run this macro")
24
+ assert_that((unit_class.new{}).name).equals("run this macro")
23
25
  end
24
26
 
25
27
  should "initialize with a given name" do
26
- assert_that((unit_class.new("test") {}).name).equals("test")
28
+ assert_that((unit_class.new("test"){}).name).equals("test")
27
29
  end
28
30
 
29
31
  should "be a Proc" do
@@ -31,7 +33,7 @@ class Assert::Macro
31
33
  end
32
34
 
33
35
  should "complain if you create a macro without a block" do
34
- assert_that(-> { unit_class.new }).raises(ArgumentError)
36
+ assert_that{ unit_class.new }.raises(ArgumentError)
35
37
  end
36
38
  end
37
39
 
@@ -39,7 +41,7 @@ class Assert::Macro
39
41
  desc "have_instance_methods macro: this class"
40
42
  subject do
41
43
  class ::InstExample
42
- (1..6).each {|i| define_method("method_#{i}") {}}
44
+ (1..6).each{ |i| define_method("method_#{i}"){} }
43
45
  end
44
46
  ::InstExample.new
45
47
  end
@@ -60,7 +62,7 @@ class Assert::Macro
60
62
  subject do
61
63
  class ::ClassExample
62
64
  class << self
63
- (1..6).each {|i| define_method("method_#{i}") {}}
65
+ (1..6).each{ |i| define_method("method_#{i}"){} }
64
66
  end
65
67
  end
66
68
  ::ClassExample.new
@@ -81,7 +83,7 @@ class Assert::Macro
81
83
  desc "have_readers macro: this class"
82
84
  subject do
83
85
  class ::ReaderExample
84
- (1..6).each {|i| attr_reader "method_#{i}"}
86
+ (1..6).each{ |i| attr_reader "method_#{i}" }
85
87
  end
86
88
  ::ReaderExample.new
87
89
  end
@@ -101,7 +103,7 @@ class Assert::Macro
101
103
  desc "have_writers macro: this class"
102
104
  subject do
103
105
  class ::WriterExample
104
- (1..6).each {|i| attr_writer "method_#{i}"}
106
+ (1..6).each{ |i| attr_writer "method_#{i}" }
105
107
  end
106
108
  ::WriterExample.new
107
109
  end
@@ -121,7 +123,7 @@ class Assert::Macro
121
123
  desc "have_accessors macro: this class"
122
124
  subject do
123
125
  class ::AccessorExample
124
- (1..6).each {|i| attr_accessor "method_#{i}"}
126
+ (1..6).each{ |i| attr_accessor "method_#{i}" }
125
127
  end
126
128
  ::AccessorExample.new
127
129
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/result"
3
5
 
@@ -6,22 +8,23 @@ require "assert/file_line"
6
8
  module Assert::Result
7
9
  class UnitTests < Assert::Context
8
10
  desc "Assert::Result"
9
- subject { unit_class }
11
+ subject{ unit_class }
10
12
 
11
- let(:unit_class) { Assert::Result }
13
+ let(:unit_class){ Assert::Result }
12
14
 
13
- let(:test1) { Factory.test("a test name") }
15
+ let(:test1){ Factory.test("a test name") }
14
16
 
15
17
  should have_imeths :types, :new
16
18
 
17
19
  should "know its types" do
18
- exp = {
19
- :pass => Pass,
20
- :fail => Fail,
21
- :ignore => Ignore,
22
- :skip => Skip,
23
- :error => Error
24
- }
20
+ exp =
21
+ {
22
+ pass: Pass,
23
+ fail: Fail,
24
+ ignore: Ignore,
25
+ skip: Skip,
26
+ error: Error,
27
+ }
25
28
  assert_that(subject.types).equals(exp)
26
29
 
27
30
  assert_that(subject.types[Factory.string]).equals(Base)
@@ -29,26 +32,26 @@ module Assert::Result
29
32
 
30
33
  should "create results from data hashes" do
31
34
  type = Assert::Result.types.keys.sample
32
- exp = Assert::Result.types[type].new(:type => type)
33
- assert_that(Assert::Result.new(:type => type)).equals(exp)
35
+ exp = Assert::Result.types[type].new(type: type)
36
+ assert_that(Assert::Result.new(type: type)).equals(exp)
34
37
  end
35
38
  end
36
39
 
37
40
  class InitBaseTests < UnitTests
38
41
  desc "Base when init"
39
- subject { Base.new(given_data1) }
42
+ subject{ Base.new(given_data1) }
40
43
 
41
- let(:given_data1) {
44
+ let(:given_data1) do
42
45
  {
43
- :type => Factory.string,
44
- :name => Factory.string,
45
- :test_name => Factory.string,
46
- :test_file_line => Assert::FileLine.new(Factory.string, Factory.integer),
47
- :message => Factory.string,
48
- :output => Factory.text,
49
- :backtrace => Backtrace.new(Factory.backtrace)
46
+ type: Factory.string,
47
+ name: Factory.string,
48
+ test_name: Factory.string,
49
+ test_file_line: Assert::FileLine.new(Factory.string, Factory.integer),
50
+ message: Factory.string,
51
+ output: Factory.text,
52
+ backtrace: Backtrace.new(Factory.backtrace),
50
53
  }
51
- }
54
+ end
52
55
 
53
56
  should have_cmeths :type, :name, :for_test
54
57
  should have_imeths :type, :name, :test_name, :test_file_line
@@ -122,10 +125,11 @@ module Assert::Result
122
125
  assert_that(subject.trace).equals(exp_trace)
123
126
 
124
127
  # test that the first bt line is used if filtered is empty
125
- assert_lib_path = File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
126
- new_bt = (Factory.integer(3)+1).times.map{ assert_lib_path }
127
- exp_backtrace = Backtrace.new(new_bt)
128
- exp_trace = exp_backtrace.first.to_s
128
+ assert_lib_path =
129
+ File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
130
+ new_bt = (Factory.integer(3) + 1).times.map{ assert_lib_path }
131
+ exp_backtrace = Backtrace.new(new_bt)
132
+ exp_trace = exp_backtrace.first.to_s
129
133
  subject.set_backtrace(new_bt)
130
134
  assert_that(subject.backtrace).equals(exp_backtrace)
131
135
  assert_that(subject.trace).equals(exp_trace)
@@ -169,8 +173,9 @@ module Assert::Result
169
173
  assert_that(subject.line_num).equals(exp.line.to_i)
170
174
 
171
175
  # test that the first bt line is used if filtered is empty
172
- assert_lib_path = File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
173
- new_bt = (Factory.integer(3)+1).times.map{ assert_lib_path }
176
+ assert_lib_path =
177
+ File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
178
+ new_bt = (Factory.integer(3) + 1).times.map{ assert_lib_path }
174
179
  subject.set_backtrace(new_bt)
175
180
 
176
181
  exp = new_bt.first.to_s
@@ -229,7 +234,7 @@ module Assert::Result
229
234
 
230
235
  class InitPassTests < UnitTests
231
236
  desc "Pass when init"
232
- subject { Pass.new({}) }
237
+ subject{ Pass.new({}) }
233
238
 
234
239
  should "know its type/name" do
235
240
  assert_that(subject.type).equals(:pass)
@@ -240,7 +245,7 @@ module Assert::Result
240
245
 
241
246
  class InitIgnoreTests < UnitTests
242
247
  desc "Ignore when init"
243
- subject { Ignore.new({}) }
248
+ subject{ Ignore.new({}) }
244
249
 
245
250
  should "know its type/name" do
246
251
  assert_that(subject.type).equals(:ignore)
@@ -251,7 +256,7 @@ module Assert::Result
251
256
 
252
257
  class InitHaltingTestResultErrorTests < UnitTests
253
258
  desc "HaltingTestResultError when init"
254
- subject { HaltingTestResultError.new }
259
+ subject{ HaltingTestResultError.new }
255
260
 
256
261
  should have_accessors :assert_with_bt
257
262
 
@@ -262,7 +267,7 @@ module Assert::Result
262
267
 
263
268
  class InitTestFailureTests < UnitTests
264
269
  desc "TestFailure when init"
265
- subject { TestFailure.new }
270
+ subject{ TestFailure.new }
266
271
 
267
272
  should "be a halting test result error" do
268
273
  assert_that(subject).is_kind_of(HaltingTestResultError)
@@ -271,7 +276,7 @@ module Assert::Result
271
276
 
272
277
  class InitFailTests < UnitTests
273
278
  desc "Fail when init"
274
- subject { Fail.new({}) }
279
+ subject{ Fail.new({}) }
275
280
 
276
281
  should "know its type/name" do
277
282
  assert_that(subject.type).equals(:fail)
@@ -302,13 +307,14 @@ module Assert::Result
302
307
  end
303
308
 
304
309
  should "not allow creating for a test with non-TestFailure exceptions" do
305
- assert_that(-> { Fail.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
310
+ assert_that{ Fail.for_test(test1, RuntimeError.new) }
311
+ .raises(ArgumentError)
306
312
  end
307
313
  end
308
314
 
309
315
  class InitTestSkippedTests < UnitTests
310
316
  desc "TestSkipped when init"
311
- subject { TestSkipped.new }
317
+ subject{ TestSkipped.new }
312
318
 
313
319
  should "be a halting test result error" do
314
320
  assert_that(subject).is_kind_of(HaltingTestResultError)
@@ -317,7 +323,7 @@ module Assert::Result
317
323
 
318
324
  class InitSkipTests < UnitTests
319
325
  desc "Skip when init"
320
- subject { Skip.new({}) }
326
+ subject{ Skip.new({}) }
321
327
 
322
328
  should "know its type/name" do
323
329
  assert_that(subject.type).equals(:skip)
@@ -348,13 +354,14 @@ module Assert::Result
348
354
  end
349
355
 
350
356
  should "not allow creating for a test with non-TestSkipped exceptions" do
351
- assert_that(-> { Skip.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
357
+ assert_that{ Skip.for_test(test1, RuntimeError.new) }
358
+ .raises(ArgumentError)
352
359
  end
353
360
  end
354
361
 
355
362
  class InitErrorTests < UnitTests
356
363
  desc "Error when init"
357
- subject { Error.new({}) }
364
+ subject{ Error.new({}) }
358
365
 
359
366
  should "know its class-level type/name" do
360
367
  assert_that(subject.class.type).equals(:error)
@@ -375,13 +382,13 @@ module Assert::Result
375
382
  end
376
383
 
377
384
  should "not allow creating for a test without an exception" do
378
- assert_that(-> { Error.for_test(test1, Factory.string) }).raises(ArgumentError)
385
+ assert_that{ Error.for_test(test1, Factory.string) }.raises(ArgumentError)
379
386
  end
380
387
  end
381
388
 
382
389
  class InitBacktraceTests < UnitTests
383
390
  desc "Backtrace when init"
384
- subject { Backtrace.new(Factory.backtrace) }
391
+ subject{ Backtrace.new(Factory.backtrace) }
385
392
 
386
393
  should have_cmeths :parse, :to_s
387
394
  should have_imeths :filtered
@@ -391,7 +398,8 @@ module Assert::Result
391
398
  end
392
399
 
393
400
  should "render as a string by joining on the newline" do
394
- assert_that(Backtrace.to_s(subject)).equals(subject.join(Backtrace::DELIM))
401
+ assert_that(Backtrace.to_s(subject))
402
+ .equals(subject.join(Backtrace::DELIM))
395
403
  end
396
404
 
397
405
  should "be an Array" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/runner"
3
5
 
@@ -10,9 +12,9 @@ require "assert/view"
10
12
  class Assert::Runner
11
13
  class UnitTests < Assert::Context
12
14
  desc "Assert::Runner"
13
- subject { unit_class }
15
+ subject{ unit_class }
14
16
 
15
- let(:unit_class) { Assert::Runner }
17
+ let(:unit_class){ Assert::Runner }
16
18
 
17
19
  should "include the config helpers" do
18
20
  assert_that(subject).includes(Assert::ConfigHelpers)
@@ -21,14 +23,14 @@ class Assert::Runner
21
23
 
22
24
  class InitTests < UnitTests
23
25
  desc "when init"
24
- subject { unit_class.new(config1) }
26
+ subject{ unit_class.new(config1) }
25
27
 
26
28
  setup do
27
29
  config1.suite Assert::DefaultSuite.new(config1)
28
- config1.view Assert::View.new(config1, StringIO.new("", "w+"))
30
+ config1.view Assert::View.new(config1, StringIO.new(+"", "w+"))
29
31
  end
30
32
 
31
- let(:config1) { Factory.modes_off_config }
33
+ let(:config1){ Factory.modes_off_config }
32
34
 
33
35
  should have_readers :config
34
36
  should have_imeths :runner, :run
@@ -47,10 +49,10 @@ class Assert::Runner
47
49
 
48
50
  class RunTests < InitTests
49
51
  desc "and run"
50
- subject { runner_class1.new(config1) }
52
+ subject{ runner_class1.new(config1) }
51
53
 
52
54
  setup do
53
- @view_output = ""
55
+ @view_output = +""
54
56
 
55
57
  suite_class = Class.new(Assert::DefaultSuite){ include CallbackMixin }
56
58
  view_class = Class.new(Assert::View){ include CallbackMixin }
@@ -62,9 +64,13 @@ class Assert::Runner
62
64
  @result_count = subject.run
63
65
  end
64
66
 
65
- let(:runner_class1) { Class.new(unit_class) { include CallbackMixin } }
66
- let(:ci1) { Factory.context_info(Factory.modes_off_context_class) }
67
- let(:test1) { Factory.test("should pass", ci1){ assert(1==1) } }
67
+ let(:runner_class1) do
68
+ Class.new(unit_class){ include CallbackMixin }
69
+ end
70
+ let(:ci1){ Factory.context_info(Factory.modes_off_context_class) }
71
+ # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
72
+ let(:test1){ Factory.test("should pass", ci1){ assert(1 == 1) } }
73
+ # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
68
74
 
69
75
  should "return the fail+error result count as an integer exit code" do
70
76
  assert_that(@result_count).equals(0)
@@ -73,7 +79,7 @@ class Assert::Runner
73
79
  error_count = Factory.integer
74
80
  Assert.stub(subject, :fail_result_count){ fail_count }
75
81
  Assert.stub(subject, :error_result_count){ error_count }
76
- Assert.stub(test1, :run){ } # no-op
82
+ Assert.stub(test1, :run){} # no-op
77
83
  result_count = subject.run
78
84
 
79
85
  assert_that(result_count).equals(fail_count + error_count)
@@ -83,7 +89,8 @@ class Assert::Runner
83
89
  # itself
84
90
  assert_that(subject.on_start_called).is_true
85
91
  assert_that(subject.before_test_called).equals([test1])
86
- assert_that(subject.on_result_called.last).is_instance_of(Assert::Result::Pass)
92
+ assert_that(subject.on_result_called.last)
93
+ .is_instance_of(Assert::Result::Pass)
87
94
  assert_that(subject.after_test_called).equals([test1])
88
95
  assert_that(subject.on_finish_called).is_true
89
96
 
@@ -91,7 +98,8 @@ class Assert::Runner
91
98
  suite = config1.suite
92
99
  assert_that(suite.on_start_called).is_true
93
100
  assert_that(suite.before_test_called).equals([test1])
94
- assert_that(suite.on_result_called.last).is_instance_of(Assert::Result::Pass)
101
+ assert_that(suite.on_result_called.last)
102
+ .is_instance_of(Assert::Result::Pass)
95
103
  assert_that(suite.after_test_called).equals([test1])
96
104
  assert_that(suite.on_finish_called).is_true
97
105
 
@@ -99,7 +107,8 @@ class Assert::Runner
99
107
  view = config1.view
100
108
  assert_that(view.on_start_called).is_true
101
109
  assert_that(view.before_test_called).equals([test1])
102
- assert_that(view.on_result_called.last).is_instance_of(Assert::Result::Pass)
110
+ assert_that(view.on_result_called.last)
111
+ .is_instance_of(Assert::Result::Pass)
103
112
  assert_that(view.after_test_called).equals([test1])
104
113
  assert_that(view.on_finish_called).is_true
105
114
  end
@@ -116,7 +125,9 @@ class Assert::Runner
116
125
  end
117
126
 
118
127
  should "run only a single test if a single test is configured" do
119
- test = Factory.test("should pass", ci1){ assert(1==1) }
128
+ # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
129
+ test = Factory.test("should pass", ci1){ assert(1 == 1) }
130
+ # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
120
131
  config1.suite.clear_tests_to_run
121
132
  config1.suite.on_test(test)
122
133
  config1.single_test test.file_line.to_s
@@ -125,8 +136,11 @@ class Assert::Runner
125
136
  assert_that(runner.before_test_called).equals([test])
126
137
  end
127
138
 
128
- should "not run any tests if a single test is configured but can't be found" do
129
- test = Factory.test("should pass", ci1){ assert(1==1) }
139
+ should "not run any tests if a single test is configured but "\
140
+ "can't be found" do
141
+ # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
142
+ test = Factory.test("should pass", ci1){ assert(1 == 1) }
143
+ # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
130
144
  config1.suite.clear_tests_to_run
131
145
  config1.suite.on_test(test)
132
146
  config1.single_test Factory.string
@@ -135,7 +149,8 @@ class Assert::Runner
135
149
  assert_that(runner.before_test_called).is_nil
136
150
  end
137
151
 
138
- should "describe running only a single test if a single test is configured" do
152
+ should "describe running only a single test if a single test is "\
153
+ "configured" do
139
154
  config1.suite.clear_tests_to_run
140
155
  config1.suite.on_test(test1)
141
156
  config1.single_test test1.file_line.to_s
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/suite"
3
5
 
@@ -8,27 +10,22 @@ require "test/support/inherited_stuff"
8
10
  class Assert::Suite
9
11
  class UnitTests < Assert::Context
10
12
  desc "Assert::Suite"
11
- subject { unit_class }
13
+ subject{ unit_class }
12
14
 
13
- let(:unit_class) { Assert::Suite }
15
+ let(:unit_class){ Assert::Suite }
14
16
 
15
17
  should "include the config helpers" do
16
18
  assert_that(subject).includes(Assert::ConfigHelpers)
17
19
  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
20
  end
24
21
 
25
22
  class InitTests < UnitTests
26
23
  desc "when init"
27
- subject { unit_class.new(config1) }
24
+ subject{ unit_class.new(config1) }
28
25
 
29
- let(:config1) { Factory.modes_off_config }
26
+ let(:config1){ Factory.modes_off_config }
30
27
 
31
- should have_readers :config, :test_methods, :setups, :teardowns
28
+ should have_readers :config, :setups, :teardowns
32
29
  should have_accessors :start_time, :end_time
33
30
  should have_imeths :suite, :setup, :startup, :teardown, :shutdown
34
31
  should have_imeths :tests_to_run?, :tests_to_run_count, :clear_tests_to_run
@@ -46,7 +43,6 @@ class Assert::Suite
46
43
  end
47
44
 
48
45
  should "default its attrs" do
49
- assert_that(subject.test_methods).equals([])
50
46
  assert_that(subject.setups).equals([])
51
47
  assert_that(subject.teardowns).equals([])
52
48
 
@@ -78,8 +74,10 @@ class Assert::Suite
78
74
  Assert.stub(subject, :result_count){ count }
79
75
 
80
76
  assert_that(subject.run_time).equals(time)
81
- assert_that(subject.test_rate).equals((subject.test_count / subject.run_time))
82
- assert_that(subject.result_rate).equals((subject.result_count / subject.run_time))
77
+ assert_that(subject.test_rate)
78
+ .equals((subject.test_count / subject.run_time))
79
+ assert_that(subject.result_rate)
80
+ .equals((subject.result_count / subject.run_time))
83
81
  end
84
82
 
85
83
  should "add setup procs" do
@@ -110,17 +108,37 @@ class Assert::Suite
110
108
  tests1.each{ |test| subject.on_test(test) }
111
109
  end
112
110
 
113
- let(:ci1) { proc{ Factory.context_info(Factory.modes_off_context_class) } }
114
- let(:tests1) {
111
+ let(:ci1){ proc{ Factory.context_info(Factory.modes_off_context_class) } }
112
+ let(:tests1) do
113
+ # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
115
114
  [
116
- Factory.test("should nothing", ci1.call){ },
117
- Factory.test("should pass", ci1.call){ assert(1==1); refute(1==0) },
118
- Factory.test("should fail", ci1.call){ ignore; assert(1==0); refute(1==1) },
119
- Factory.test("should ignore", ci1.call){ ignore },
120
- Factory.test("should skip", ci1.call){ skip; ignore; assert(1==1) },
121
- Factory.test("should error", ci1.call){ raise Exception; ignore; assert(1==1) }
115
+ Factory.test("should nothing", ci1.call) do
116
+ end,
117
+ Factory.test("should pass", ci1.call) do
118
+ assert(1 == 1)
119
+ refute(1 == 0)
120
+ end,
121
+ Factory.test("should fail", ci1.call) do
122
+ ignore
123
+ assert(1 == 0)
124
+ refute(1 == 1)
125
+ end,
126
+ Factory.test("should ignore", ci1.call) do
127
+ ignore
128
+ end,
129
+ Factory.test("should skip", ci1.call) do
130
+ skip
131
+ ignore
132
+ assert(1 == 1)
133
+ end,
134
+ Factory.test("should error", ci1.call) do
135
+ raise Exception
136
+ ignore # rubocop:disable Lint/UnreachableCode
137
+ assert(1 == 1)
138
+ end,
122
139
  ]
123
- }
140
+ # rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
141
+ end
124
142
 
125
143
  should "know its tests-to-run attrs" do
126
144
  assert_that(subject.tests_to_run_count).equals(tests1.size)
@@ -134,14 +152,14 @@ class Assert::Suite
134
152
 
135
153
  should "find a test to run given a file line" do
136
154
  test = tests1.sample
137
- assert_that(subject.find_test_to_run(test.file_line)).is_the_same_as(test)
155
+ assert_that(subject.find_test_to_run(test.file_line)).is(test)
138
156
  end
139
157
 
140
158
  should "know its sorted tests to run" do
141
159
  sorted_tests = subject.sorted_tests_to_run{ 1 }
142
160
  assert_that(sorted_tests.size).equals(tests1.size)
143
161
  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)
162
+ assert_that(subject.sorted_tests_to_run{ 1 }.first).is(sorted_tests.first)
145
163
  end
146
164
  end
147
165
  end