assert 2.19.0 → 2.19.5

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/assert.gemspec +11 -6
  4. data/bin/assert +1 -0
  5. data/lib/assert.rb +20 -6
  6. data/lib/assert/actual_value.rb +11 -6
  7. data/lib/assert/assert_runner.rb +38 -17
  8. data/lib/assert/assertions.rb +85 -50
  9. data/lib/assert/cli.rb +32 -70
  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 +16 -18
  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 +114 -62
  29. data/lib/assert/runner.rb +70 -51
  30. data/lib/assert/stub.rb +44 -3
  31. data/lib/assert/suite.rb +69 -28
  32. data/lib/assert/test.rb +43 -36
  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 +71 -50
  43. data/test/unit/assert_tests.rb +42 -23
  44. data/test/unit/assertions/assert_block_tests.rb +12 -10
  45. data/test/unit/assertions/assert_changes_tests.rb +27 -21
  46. data/test/unit/assertions/assert_empty_tests.rb +16 -12
  47. data/test/unit/assertions/assert_equal_tests.rb +28 -26
  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 +29 -20
  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 +16 -9
  59. data/test/unit/config_helpers_tests.rb +17 -10
  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 +39 -17
  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 +39 -15
  76. data/test/unit/test_tests.rb +65 -50
  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 +26 -11
  81. data/test/unit/assertions/assert_kind_of_tests.rb +0 -66
@@ -1,25 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
4
6
  require "assert/utils"
5
7
 
6
8
  module Assert::Assertions
7
-
8
9
  class AssertFileExistsTests < Assert::Context
9
10
  include Assert::Test::TestHelpers
10
11
 
11
12
  desc "`assert_file_exists`"
12
- subject {
13
+ subject do
13
14
  args = args1
14
15
  Factory.test do
15
16
  assert_file_exists(__FILE__) # pass
16
17
  assert_file_exists(*args) # fail
17
18
  end
18
- }
19
+ end
19
20
 
20
- let(:desc1) { "assert file exists fail desc" }
21
- let(:args1) { ["/a/path/to/some/file/that/no/exists", desc1] }
22
- let(:config1) { subject.config }
21
+ let(:desc1){ "assert file exists fail desc" }
22
+ let(:args1){ ["/a/path/to/some/file/that/no/exists", desc1] }
23
+ let(:config1){ subject.config }
23
24
 
24
25
  should "produce results as expected" do
25
26
  subject.run(&test_run_callback)
@@ -28,7 +29,8 @@ module Assert::Assertions
28
29
  assert_that(test_run_result_count(:pass)).equals(1)
29
30
  assert_that(test_run_result_count(:fail)).equals(1)
30
31
 
31
- exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to exist."
32
+ exp =
33
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to exist."
32
34
  assert_that(test_run_results(:fail).first.message).equals(exp)
33
35
  end
34
36
  end
@@ -37,17 +39,17 @@ module Assert::Assertions
37
39
  include Assert::Test::TestHelpers
38
40
 
39
41
  desc "`assert_not_file_exists`"
40
- subject {
42
+ subject do
41
43
  args = args1
42
44
  Factory.test do
43
45
  assert_not_file_exists("/file/path") # pass
44
46
  assert_not_file_exists(*args) # fail
45
47
  end
46
- }
48
+ end
47
49
 
48
- let(:desc1) { "assert not file exists fail desc" }
49
- let(:args1) { [__FILE__, desc1] }
50
- let(:config1) { subject.config }
50
+ let(:desc1){ "assert not file exists fail desc" }
51
+ let(:args1){ [__FILE__, desc1] }
52
+ let(:config1){ subject.config }
51
53
 
52
54
  should "produce results as expected" do
53
55
  subject.run(&test_run_callback)
@@ -56,7 +58,9 @@ module Assert::Assertions
56
58
  assert_that(test_run_result_count(:pass)).equals(1)
57
59
  assert_that(test_run_result_count(:fail)).equals(1)
58
60
 
59
- exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not exist."
61
+ exp =
62
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
63
+ "not exist."
60
64
  assert_that(test_run_results(:fail).first.message).equals(exp)
61
65
  end
62
66
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,17 +10,17 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_includes`"
11
- subject {
13
+ subject do
12
14
  args = args1
13
15
  Factory.test do
14
16
  assert_includes(1, [1]) # pass
15
17
  assert_includes(*args) # fail
16
18
  end
17
- }
19
+ end
18
20
 
19
- let(:desc1) { "assert includes fail desc" }
20
- let(:args1) { [2, [1], desc1] }
21
- let(:config1) { subject.config }
21
+ let(:desc1){ "assert includes fail desc" }
22
+ let(:args1){ [2, [1], desc1] }
23
+ let(:config1){ subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
26
  subject.run(&test_run_callback)
@@ -39,17 +41,17 @@ module Assert::Assertions
39
41
  include Assert::Test::TestHelpers
40
42
 
41
43
  desc "`assert_not_included`"
42
- subject {
44
+ subject do
43
45
  args = args1
44
46
  Factory.test do
45
47
  assert_not_included(2, [1]) # pass
46
48
  assert_not_included(*args) # fail
47
49
  end
48
- }
50
+ end
49
51
 
50
- let(:desc1) { "assert not included fail desc" }
51
- let(:args1) { [1, [1], desc1] }
52
- let(:config1) { subject.config }
52
+ let(:desc1){ "assert not included fail desc" }
53
+ let(:args1){ [1, [1], desc1] }
54
+ let(:config1){ subject.config }
53
55
 
54
56
  should "produce results as expected" do
55
57
  subject.run(&test_run_callback)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,17 +10,17 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_instance_of`"
11
- subject {
13
+ subject do
12
14
  args = args1
13
15
  Factory.test do
14
16
  assert_instance_of(String, "object") # pass
15
17
  assert_instance_of(*args) # fail
16
18
  end
17
- }
19
+ end
18
20
 
19
- let(:desc1) { "assert instance of fail desc" }
20
- let(:args1) { [Array, "object", desc1] }
21
- let(:config1) { subject.config }
21
+ let(:desc1){ "assert instance of fail desc" }
22
+ let(:args1){ [Array, "object", desc1] }
23
+ let(:config1){ subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
26
  subject.run(&test_run_callback)
@@ -28,8 +30,8 @@ module Assert::Assertions
28
30
  assert_that(test_run_result_count(:fail)).equals(1)
29
31
 
30
32
  exp =
31
- "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
32
- " to be an instance of #{args1[0]}."
33
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
34
+ "(#{args1[1].class}) to be an instance of #{args1[0]}."
33
35
  assert_that(test_run_results(:fail).first.message).equals(exp)
34
36
  end
35
37
  end
@@ -38,17 +40,17 @@ module Assert::Assertions
38
40
  include Assert::Test::TestHelpers
39
41
 
40
42
  desc "`assert_not_instance_of`"
41
- subject {
43
+ subject do
42
44
  args = args1
43
45
  Factory.test do
44
46
  assert_not_instance_of(*args) # fail
45
47
  assert_not_instance_of(Array, "object") # pass
46
48
  end
47
- }
49
+ end
48
50
 
49
- let(:desc1) { "assert not instance of fail desc" }
50
- let(:args1) { [String, "object", desc1] }
51
- let(:config1) { subject.config }
51
+ let(:desc1){ "assert not instance of fail desc" }
52
+ let(:args1){ [String, "object", desc1] }
53
+ let(:config1){ subject.config }
52
54
 
53
55
  should "produce results as expected" do
54
56
  subject.run(&test_run_callback)
@@ -58,8 +60,8 @@ module Assert::Assertions
58
60
  assert_that(test_run_result_count(:fail)).equals(1)
59
61
 
60
62
  exp =
61
- "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
62
- " to not be an instance of #{args1[0]}."
63
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
64
+ "(#{args1[1].class}) to not be an instance of #{args1[0]}."
63
65
  assert_that(test_run_results(:fail).first.message).equals(exp)
64
66
  end
65
67
  end
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "assert"
4
+ require "assert/assertions"
5
+
6
+ require "assert/utils"
7
+
8
+ module Assert::Assertions
9
+ class AssertIsATests < Assert::Context
10
+ include Assert::Test::TestHelpers
11
+
12
+ desc "`assert_is_a`"
13
+ subject do
14
+ args = args1
15
+ Factory.test do
16
+ assert_is_a(String, "object") # pass
17
+ assert_is_a(*args) # fail
18
+ end
19
+ end
20
+
21
+ let(:desc1){ "assert kind of fail desc" }
22
+ let(:args1){ [Array, "object", desc1] }
23
+ let(:config1){ subject.config }
24
+
25
+ should "produce results as expected" do
26
+ subject.run(&test_run_callback)
27
+
28
+ assert_that(test_run_result_count).equals(2)
29
+ assert_that(test_run_result_count(:pass)).equals(1)
30
+ assert_that(test_run_result_count(:fail)).equals(1)
31
+
32
+ exp =
33
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
34
+ "(#{args1[1].class}) to be a `#{args1[0]}`."
35
+ assert_that(test_run_results(:fail).first.message).equals(exp)
36
+ end
37
+ end
38
+
39
+ class AssertIsNotATests < Assert::Context
40
+ include Assert::Test::TestHelpers
41
+
42
+ desc "`assert_not_kind_of`"
43
+ subject do
44
+ args = args1
45
+ Factory.test do
46
+ assert_is_not_a(*args) # fail
47
+ assert_is_not_a(Array, "object") # pass
48
+ end
49
+ end
50
+
51
+ let(:desc1){ "assert not kind of fail desc" }
52
+ let(:args1){ [String, "object", desc1] }
53
+ let(:config1){ subject.config }
54
+
55
+ should "produce results as expected" do
56
+ subject.run(&test_run_callback)
57
+
58
+ assert_that(test_run_result_count).equals(2)
59
+ assert_that(test_run_result_count(:pass)).equals(1)
60
+ assert_that(test_run_result_count(:fail)).equals(1)
61
+
62
+ exp =
63
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
64
+ "(#{args1[1].class}) to not be a `#{args1[0]}`."
65
+ assert_that(test_run_results(:fail).first.message).equals(exp)
66
+ end
67
+ end
68
+
69
+ class AssertKindOfTests < Assert::Context
70
+ include Assert::Test::TestHelpers
71
+
72
+ desc "`assert_kind_of`"
73
+ subject do
74
+ args = args1
75
+ Factory.test do
76
+ assert_kind_of(String, "object") # pass
77
+ assert_kind_of(*args) # fail
78
+ end
79
+ end
80
+
81
+ let(:desc1){ "assert kind of fail desc" }
82
+ let(:args1){ [Array, "object", desc1] }
83
+ let(:config1){ subject.config }
84
+
85
+ should "produce results as expected" do
86
+ subject.run(&test_run_callback)
87
+
88
+ assert_that(test_run_result_count).equals(2)
89
+ assert_that(test_run_result_count(:pass)).equals(1)
90
+ assert_that(test_run_result_count(:fail)).equals(1)
91
+
92
+ exp =
93
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
94
+ "(#{args1[1].class}) to be a `#{args1[0]}`."
95
+ assert_that(test_run_results(:fail).first.message).equals(exp)
96
+ end
97
+ end
98
+
99
+ class AssertNotKindOfTests < Assert::Context
100
+ include Assert::Test::TestHelpers
101
+
102
+ desc "`assert_not_kind_of`"
103
+ subject do
104
+ args = args1
105
+ Factory.test do
106
+ assert_not_kind_of(*args) # fail
107
+ assert_not_kind_of(Array, "object") # pass
108
+ end
109
+ end
110
+
111
+ let(:desc1){ "assert not kind of fail desc" }
112
+ let(:args1){ [String, "object", desc1] }
113
+ let(:config1){ subject.config }
114
+
115
+ should "produce results as expected" do
116
+ subject.run(&test_run_callback)
117
+
118
+ assert_that(test_run_result_count).equals(2)
119
+ assert_that(test_run_result_count(:pass)).equals(1)
120
+ assert_that(test_run_result_count(:fail)).equals(1)
121
+
122
+ exp =
123
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
124
+ "(#{args1[1].class}) to not be a `#{args1[0]}`."
125
+ assert_that(test_run_results(:fail).first.message).equals(exp)
126
+ end
127
+ end
128
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,17 +10,17 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_match`"
11
- subject {
13
+ subject do
12
14
  args = args1
13
15
  Factory.test do
14
16
  assert_match(/a/, "a string") # pass
15
17
  assert_match(*args) # fail
16
18
  end
17
- }
19
+ end
18
20
 
19
- let(:desc1) { "assert match fail desc" }
20
- let(:args1) { ["not", "a string", desc1] }
21
- let(:config1) { subject.config }
21
+ let(:desc1){ "assert match fail desc" }
22
+ let(:args1){ ["not", "a string", desc1] }
23
+ let(:config1){ subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
26
  subject.run(&test_run_callback)
@@ -38,17 +40,17 @@ module Assert::Assertions
38
40
  include Assert::Test::TestHelpers
39
41
 
40
42
  desc "`assert_not_match`"
41
- subject {
43
+ subject do
42
44
  args = args1
43
45
  Factory.test do
44
46
  assert_not_match(*args) # fail
45
47
  assert_not_match("not", "a string") # pass
46
48
  end
47
- }
49
+ end
48
50
 
49
- let(:desc1) { "assert not match fail desc" }
50
- let(:args1) { [/a/, "a string", desc1] }
51
- let(:config1) { subject.config }
51
+ let(:desc1){ "assert not match fail desc" }
52
+ let(:args1){ [/a/, "a string", desc1] }
53
+ let(:config1){ subject.config }
52
54
 
53
55
  should "produce results as expected" do
54
56
  subject.run(&test_run_callback)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,17 +10,17 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_nil`"
11
- subject {
13
+ subject do
12
14
  args = args1
13
15
  Factory.test do
14
16
  assert_nil(nil) # pass
15
17
  assert_nil(*args) # fail
16
18
  end
17
- }
19
+ end
18
20
 
19
- let(:desc1) { "assert nil empty fail desc" }
20
- let(:args1) { [1, desc1] }
21
- let(:config1) { subject.config }
21
+ let(:desc1){ "assert nil empty fail desc" }
22
+ let(:args1){ [1, desc1] }
23
+ let(:config1){ subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
26
  subject.run(&test_run_callback)
@@ -27,7 +29,9 @@ module Assert::Assertions
27
29
  assert_that(test_run_result_count(:pass)).equals(1)
28
30
  assert_that(test_run_result_count(:fail)).equals(1)
29
31
 
30
- exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be nil."
32
+ exp =
33
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
34
+ "be nil."
31
35
  assert_that(test_run_results(:fail).first.message).equals(exp)
32
36
  end
33
37
  end
@@ -36,17 +40,17 @@ module Assert::Assertions
36
40
  include Assert::Test::TestHelpers
37
41
 
38
42
  desc "`assert_not_nil`"
39
- subject {
43
+ subject do
40
44
  args = args1
41
45
  Factory.test do
42
46
  assert_not_nil(1) # pass
43
47
  assert_not_nil(*args) # fail
44
48
  end
45
- }
49
+ end
46
50
 
47
- let(:desc1) { "assert not nil empty fail desc" }
48
- let(:args1) { [nil, desc1] }
49
- let(:config1) { subject.config }
51
+ let(:desc1){ "assert not nil empty fail desc" }
52
+ let(:args1){ [nil, desc1] }
53
+ let(:config1){ subject.config }
50
54
 
51
55
  should "produce results as expected" do
52
56
  subject.run(&test_run_callback)
@@ -55,7 +59,9 @@ module Assert::Assertions
55
59
  assert_that(test_run_result_count(:pass)).equals(1)
56
60
  assert_that(test_run_result_count(:fail)).equals(1)
57
61
 
58
- exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not be nil."
62
+ exp =
63
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
64
+ "not be nil."
59
65
  assert_that(test_run_results(:fail).first.message).equals(exp)
60
66
  end
61
67
  end