assert 2.18.3 → 2.19.3
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 +4 -4
- data/Gemfile +4 -2
- data/assert.gemspec +11 -5
- data/bin/assert +1 -0
- data/lib/assert.rb +20 -6
- data/lib/assert/actual_value.rb +26 -8
- data/lib/assert/assert_runner.rb +38 -17
- data/lib/assert/assertions.rb +145 -41
- data/lib/assert/cli.rb +19 -66
- data/lib/assert/clirb.rb +55 -0
- data/lib/assert/config.rb +9 -7
- data/lib/assert/config_helpers.rb +57 -22
- data/lib/assert/context.rb +33 -49
- data/lib/assert/context/let_dsl.rb +10 -4
- data/lib/assert/context/method_missing.rb +3 -0
- data/lib/assert/context/setup_dsl.rb +24 -16
- data/lib/assert/context/subject_dsl.rb +26 -25
- data/lib/assert/context/suite_dsl.rb +5 -1
- data/lib/assert/context/test_dsl.rb +58 -19
- data/lib/assert/context_info.rb +2 -0
- data/lib/assert/default_runner.rb +2 -0
- data/lib/assert/default_suite.rb +27 -15
- data/lib/assert/default_view.rb +49 -30
- data/lib/assert/factory.rb +2 -0
- data/lib/assert/file_line.rb +8 -6
- data/lib/assert/macro.rb +3 -1
- data/lib/assert/macros/methods.rb +73 -45
- data/lib/assert/result.rb +117 -61
- data/lib/assert/runner.rb +70 -51
- data/lib/assert/stub.rb +44 -3
- data/lib/assert/suite.rb +76 -38
- data/lib/assert/test.rb +43 -44
- data/lib/assert/utils.rb +22 -11
- data/lib/assert/version.rb +3 -1
- data/lib/assert/view.rb +46 -18
- data/lib/assert/view_helpers.rb +102 -92
- data/test/helper.rb +8 -4
- data/test/support/factory.rb +40 -21
- data/test/support/inherited_stuff.rb +2 -0
- data/test/system/stub_tests.rb +272 -250
- data/test/system/test_tests.rb +89 -73
- data/test/unit/actual_value_tests.rb +103 -46
- data/test/unit/assert_tests.rb +49 -39
- data/test/unit/assertions/assert_block_tests.rb +14 -14
- data/test/unit/assertions/assert_changes_tests.rb +103 -0
- data/test/unit/assertions/assert_empty_tests.rb +18 -16
- data/test/unit/assertions/assert_equal_tests.rb +48 -32
- data/test/unit/assertions/assert_file_exists_tests.rb +19 -17
- data/test/unit/assertions/assert_includes_tests.rb +14 -14
- data/test/unit/assertions/assert_instance_of_tests.rb +18 -18
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +14 -14
- data/test/unit/assertions/assert_nil_tests.rb +20 -16
- data/test/unit/assertions/assert_raises_tests.rb +36 -27
- data/test/unit/assertions/assert_respond_to_tests.rb +14 -14
- data/test/unit/assertions/assert_same_tests.rb +28 -32
- data/test/unit/assertions/assert_true_false_tests.rb +38 -32
- data/test/unit/assertions_tests.rb +25 -18
- data/test/unit/config_helpers_tests.rb +20 -9
- data/test/unit/config_tests.rb +16 -8
- data/test/unit/context/let_dsl_tests.rb +2 -0
- data/test/unit/context/setup_dsl_tests.rb +27 -15
- data/test/unit/context/subject_dsl_tests.rb +5 -4
- data/test/unit/context/suite_dsl_tests.rb +6 -5
- data/test/unit/context/test_dsl_tests.rb +43 -19
- data/test/unit/context_info_tests.rb +12 -3
- data/test/unit/context_tests.rb +166 -116
- data/test/unit/default_runner_tests.rb +2 -0
- data/test/unit/default_suite_tests.rb +17 -5
- data/test/unit/factory_tests.rb +5 -1
- data/test/unit/file_line_tests.rb +14 -12
- data/test/unit/macro_tests.rb +17 -10
- data/test/unit/result_tests.rb +72 -75
- data/test/unit/runner_tests.rb +38 -23
- data/test/unit/suite_tests.rb +48 -30
- data/test/unit/test_tests.rb +88 -102
- data/test/unit/utils_tests.rb +53 -36
- data/test/unit/view_helpers_tests.rb +25 -17
- data/test/unit/view_tests.rb +8 -5
- metadata +40 -9
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
data/test/unit/assert_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
|
3
5
|
require "assert/config"
|
@@ -7,7 +9,9 @@ require "much-stub"
|
|
7
9
|
module Assert
|
8
10
|
class UnitTests < Assert::Context
|
9
11
|
desc "Assert"
|
10
|
-
subject
|
12
|
+
subject{ unit_class }
|
13
|
+
|
14
|
+
let(:unit_class){ Assert }
|
11
15
|
|
12
16
|
should have_imeths :config, :configure, :view, :suite, :runner
|
13
17
|
should have_imeths :stubs, :stub, :unstub, :unstub!, :stub_send
|
@@ -17,9 +21,9 @@ module Assert
|
|
17
21
|
end
|
18
22
|
|
19
23
|
should "map its view, suite and runner to its config" do
|
20
|
-
assert_that(subject.view).
|
21
|
-
assert_that(subject.suite).
|
22
|
-
assert_that(subject.runner).
|
24
|
+
assert_that(subject.view).is(subject.config.view)
|
25
|
+
assert_that(subject.suite).is(subject.config.suite)
|
26
|
+
assert_that(subject.runner).is(subject.config.runner)
|
23
27
|
end
|
24
28
|
|
25
29
|
# Note: don't really need to explicitly test the configure method as
|
@@ -27,27 +31,20 @@ module Assert
|
|
27
31
|
end
|
28
32
|
|
29
33
|
class StubTests < UnitTests
|
30
|
-
|
31
|
-
# orig_value1 = Factory.string
|
32
|
-
# stub_value1 = Factory.string
|
33
|
-
|
34
|
-
# @myclass =
|
35
|
-
# Class.new do
|
36
|
-
# def initialize(value); @value = value; end
|
37
|
-
# def mymeth; @value; end
|
38
|
-
# end
|
39
|
-
# object1 = @myclass.new(orig_value1)
|
40
|
-
# end
|
41
|
-
|
42
|
-
let(:class1) {
|
34
|
+
let(:class1) do
|
43
35
|
Class.new do
|
44
|
-
def initialize(value)
|
45
|
-
|
36
|
+
def initialize(value)
|
37
|
+
@value = value
|
38
|
+
end
|
39
|
+
|
40
|
+
def mymeth
|
41
|
+
@value
|
42
|
+
end
|
46
43
|
end
|
47
|
-
|
48
|
-
let(:object1)
|
49
|
-
let(:orig_value1)
|
50
|
-
let(:stub_value1)
|
44
|
+
end
|
45
|
+
let(:object1){ class1.new(orig_value1) }
|
46
|
+
let(:orig_value1){ Factory.string }
|
47
|
+
let(:stub_value1){ Factory.string }
|
51
48
|
|
52
49
|
should "build a stub" do
|
53
50
|
stub1 = Assert.stub(object1, :mymeth)
|
@@ -57,9 +54,9 @@ module Assert
|
|
57
54
|
should "build a stub with an on_call block" do
|
58
55
|
my_meth_called_with = nil
|
59
56
|
stub1 =
|
60
|
-
Assert.stub_on_call(object1, :mymeth)
|
57
|
+
Assert.stub_on_call(object1, :mymeth) do |call|
|
61
58
|
my_meth_called_with = call
|
62
|
-
|
59
|
+
end
|
63
60
|
|
64
61
|
object1.mymeth
|
65
62
|
assert_kind_of MuchStub::Stub, stub1
|
@@ -69,12 +66,12 @@ module Assert
|
|
69
66
|
should "lookup stubs that have been called before" do
|
70
67
|
stub1 = Assert.stub(object1, :mymeth)
|
71
68
|
stub2 = Assert.stub(object1, :mymeth)
|
72
|
-
assert_that(stub2).
|
69
|
+
assert_that(stub2).is(stub1)
|
73
70
|
end
|
74
71
|
|
75
72
|
should "set the stub's do block if given a block" do
|
76
73
|
Assert.stub(object1, :mymeth)
|
77
|
-
assert_that
|
74
|
+
assert_that{ object1.mymeth }.raises(MuchStub::NotStubbedError)
|
78
75
|
Assert.stub(object1, :mymeth){ stub_value1 }
|
79
76
|
assert_that(object1.mymeth).equals(stub_value1)
|
80
77
|
end
|
@@ -106,7 +103,7 @@ module Assert
|
|
106
103
|
should "auto-unstub any stubs on teardown" do
|
107
104
|
context_class = ::Factory.modes_off_context_class do
|
108
105
|
setup do
|
109
|
-
Assert.stub("1", :to_s){ "one" }
|
106
|
+
Assert.stub(+"1", :to_s){ "one" }
|
110
107
|
end
|
111
108
|
end
|
112
109
|
|
@@ -119,8 +116,9 @@ module Assert
|
|
119
116
|
|
120
117
|
should "be able to call a stub's original method" do
|
121
118
|
err =
|
122
|
-
assert_that
|
123
|
-
|
119
|
+
assert_that{
|
120
|
+
Assert.stub_send(object1, :mymeth)
|
121
|
+
}.raises(MuchStub::NotStubbedError)
|
124
122
|
assert_that(err.message).includes("not stubbed.")
|
125
123
|
assert_that(err.backtrace.first).includes("test/unit/assert_tests.rb")
|
126
124
|
|
@@ -132,9 +130,9 @@ module Assert
|
|
132
130
|
|
133
131
|
should "be able to add a stub tap" do
|
134
132
|
my_meth_called_with = nil
|
135
|
-
Assert.stub_tap(object1, :mymeth)
|
133
|
+
Assert.stub_tap(object1, :mymeth) do |_value, *args|
|
136
134
|
my_meth_called_with = args
|
137
|
-
|
135
|
+
end
|
138
136
|
|
139
137
|
assert_that(object1.mymeth).equals(orig_value1)
|
140
138
|
assert_that(my_meth_called_with).equals([])
|
@@ -142,9 +140,9 @@ module Assert
|
|
142
140
|
|
143
141
|
should "be able to add a stub tap with an on_call block" do
|
144
142
|
my_meth_called_with = nil
|
145
|
-
Assert.stub_tap_on_call(object1, :mymeth)
|
143
|
+
Assert.stub_tap_on_call(object1, :mymeth) do |_value, call|
|
146
144
|
my_meth_called_with = call
|
147
|
-
|
145
|
+
end
|
148
146
|
|
149
147
|
assert_that(object1.mymeth).equals(orig_value1)
|
150
148
|
assert_that(my_meth_called_with.args).equals([])
|
@@ -152,10 +150,21 @@ module Assert
|
|
152
150
|
|
153
151
|
should "be able to add a stubbed spy" do
|
154
152
|
myclass = Class.new do
|
155
|
-
def one
|
156
|
-
|
157
|
-
|
158
|
-
|
153
|
+
def one
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
def two(_val)
|
158
|
+
self
|
159
|
+
end
|
160
|
+
|
161
|
+
def three
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
def ready?
|
166
|
+
false
|
167
|
+
end
|
159
168
|
end
|
160
169
|
myobj = myclass.new
|
161
170
|
|
@@ -165,7 +174,8 @@ module Assert
|
|
165
174
|
:one,
|
166
175
|
:two,
|
167
176
|
:three,
|
168
|
-
ready?: true
|
177
|
+
ready?: true,
|
178
|
+
)
|
169
179
|
|
170
180
|
assert_that(myobj.one).equals(spy)
|
171
181
|
assert_that(myobj.two("a")).equals(spy)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/assertions"
|
3
5
|
|
@@ -6,16 +8,15 @@ module Assert::Assertions
|
|
6
8
|
include Assert::Test::TestHelpers
|
7
9
|
|
8
10
|
desc "`assert_block`"
|
9
|
-
subject
|
10
|
-
|
11
|
-
let(:desc1) { "assert block fail desc" }
|
12
|
-
let(:test1) {
|
11
|
+
subject do
|
13
12
|
desc = desc1
|
14
13
|
Factory.test do
|
15
|
-
assert_block
|
16
|
-
assert_block(desc)
|
14
|
+
assert_block{ true } # pass
|
15
|
+
assert_block(desc){ false } # fail
|
17
16
|
end
|
18
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:desc1){ "assert block fail desc" }
|
19
20
|
|
20
21
|
should "produce results as expected" do
|
21
22
|
subject.run(&test_run_callback)
|
@@ -33,16 +34,15 @@ module Assert::Assertions
|
|
33
34
|
include Assert::Test::TestHelpers
|
34
35
|
|
35
36
|
desc "`assert_not_block`"
|
36
|
-
subject
|
37
|
-
|
38
|
-
let(:desc1) { "assert not block fail desc" }
|
39
|
-
let(:test1) {
|
37
|
+
subject do
|
40
38
|
desc = desc1
|
41
39
|
Factory.test do
|
42
|
-
assert_not_block(desc)
|
43
|
-
assert_not_block
|
40
|
+
assert_not_block(desc){ true } # fail
|
41
|
+
assert_not_block{ false } # pass
|
44
42
|
end
|
45
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:desc1){ "assert not block fail desc" }
|
46
46
|
|
47
47
|
should "produce results as expected" do
|
48
48
|
subject.run(&test_run_callback)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "assert"
|
4
|
+
require "assert/assertions"
|
5
|
+
|
6
|
+
module Assert::Assertions
|
7
|
+
class AssertChangesTests < Assert::Context
|
8
|
+
include Assert::Test::TestHelpers
|
9
|
+
|
10
|
+
desc "`assert_changes`"
|
11
|
+
subject do
|
12
|
+
desc = desc1
|
13
|
+
Factory.test do
|
14
|
+
@my_var = 1
|
15
|
+
assert_changes("@my_var", from: 1, to: 2){ @my_var = 2 } # pass
|
16
|
+
@my_var = 1
|
17
|
+
assert_changes("@my_var", from: 1){ @my_var = 2 } # pass
|
18
|
+
@my_var = 1
|
19
|
+
assert_changes("@my_var", to: 2){ @my_var = 2 } # pass
|
20
|
+
@my_var = 1
|
21
|
+
assert_changes("@my_var", desc: desc){ @my_var = 2 } # pass
|
22
|
+
|
23
|
+
@my_var = 1
|
24
|
+
assert_changes("@my_var", from: 2, to: 1){ @my_var = 2 } # fail
|
25
|
+
@my_var = 1
|
26
|
+
assert_changes("@my_var", from: 2){ @my_var = 2 } # fail
|
27
|
+
@my_var = 1
|
28
|
+
assert_changes("@my_var", to: 1){ @my_var = 2 } # fail
|
29
|
+
@my_var = 1
|
30
|
+
assert_changes("@my_var", desc: desc){ @my_var = 1 } # fail
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:desc1){ "assert changes fail desc" }
|
35
|
+
|
36
|
+
should "produce results as expected" do
|
37
|
+
subject.run(&test_run_callback)
|
38
|
+
|
39
|
+
assert_that(test_run_result_count).equals(10)
|
40
|
+
assert_that(test_run_result_count(:pass)).equals(5)
|
41
|
+
assert_that(test_run_result_count(:fail)).equals(5)
|
42
|
+
|
43
|
+
exp =
|
44
|
+
[
|
45
|
+
"Expected `@my_var` to change from `2`",
|
46
|
+
"Expected `@my_var` to change to `1`",
|
47
|
+
"Expected `@my_var` to change from `2`",
|
48
|
+
"Expected `@my_var` to change to `1`",
|
49
|
+
"#{desc1}\nExpected `@my_var` to change; "\
|
50
|
+
"it was `1` and didn't change",
|
51
|
+
]
|
52
|
+
messages = test_run_results(:fail).map(&:message)
|
53
|
+
messages.each_with_index do |msg, n|
|
54
|
+
assert_that(msg).matches(/^#{exp[n]}/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class AssertNotChangesTests < Assert::Context
|
60
|
+
include Assert::Test::TestHelpers
|
61
|
+
|
62
|
+
desc "`assert_changes`"
|
63
|
+
subject do
|
64
|
+
desc = desc1
|
65
|
+
Factory.test do
|
66
|
+
@my_var = 1
|
67
|
+
assert_not_changes("@my_var", from: 1){ @my_var = 1 } # pass
|
68
|
+
@my_var = 1
|
69
|
+
assert_not_changes("@my_var", desc: desc){ @my_var = 1 } # pass
|
70
|
+
|
71
|
+
@my_var = 1
|
72
|
+
assert_not_changes("@my_var", from: 2){ @my_var = 1 } # fail
|
73
|
+
@my_var = 1
|
74
|
+
assert_not_changes("@my_var", from: 1){ @my_var = 2 } # fail
|
75
|
+
@my_var = 1
|
76
|
+
assert_not_changes("@my_var", desc: desc){ @my_var = 2 } # fail
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
let(:desc1){ "assert not changes fail desc" }
|
81
|
+
|
82
|
+
should "produce results as expected" do
|
83
|
+
subject.run(&test_run_callback)
|
84
|
+
|
85
|
+
assert_that(test_run_result_count).equals(8)
|
86
|
+
assert_that(test_run_result_count(:pass)).equals(5)
|
87
|
+
assert_that(test_run_result_count(:fail)).equals(3)
|
88
|
+
|
89
|
+
exp =
|
90
|
+
[
|
91
|
+
"Expected `@my_var` to not change from `2`",
|
92
|
+
"Expected `@my_var` to not change; "\
|
93
|
+
"it was `1` and changed to `2`",
|
94
|
+
"#{desc1}\nExpected `@my_var` to not change; "\
|
95
|
+
"it was `1` and changed to `2`",
|
96
|
+
]
|
97
|
+
messages = test_run_results(:fail).map(&:message)
|
98
|
+
messages.each_with_index do |msg, n|
|
99
|
+
assert_that(msg).matches(/^#{exp[n]}/)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/assertions"
|
3
5
|
|
@@ -8,18 +10,17 @@ module Assert::Assertions
|
|
8
10
|
include Assert::Test::TestHelpers
|
9
11
|
|
10
12
|
desc "`assert_empty`"
|
11
|
-
subject
|
12
|
-
|
13
|
-
let(:desc1) { "assert empty fail desc" }
|
14
|
-
let(:args1) { [[1], desc1] }
|
15
|
-
let(:test1) {
|
13
|
+
subject do
|
16
14
|
args = args1
|
17
15
|
Factory.test do
|
18
16
|
assert_empty([]) # pass
|
19
17
|
assert_empty(*args) # fail
|
20
18
|
end
|
21
|
-
|
22
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:desc1){ "assert empty fail desc" }
|
22
|
+
let(:args1){ [[1], desc1] }
|
23
|
+
let(:config1){ subject.config }
|
23
24
|
|
24
25
|
should "produce results as expected" do
|
25
26
|
subject.run(&test_run_callback)
|
@@ -29,7 +30,8 @@ module Assert::Assertions
|
|
29
30
|
assert_that(test_run_result_count(:fail)).equals(1)
|
30
31
|
|
31
32
|
exp =
|
32
|
-
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be
|
33
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be "\
|
34
|
+
"empty."
|
33
35
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
34
36
|
end
|
35
37
|
end
|
@@ -38,18 +40,17 @@ module Assert::Assertions
|
|
38
40
|
include Assert::Test::TestHelpers
|
39
41
|
|
40
42
|
desc "`assert_not_empty`"
|
41
|
-
subject
|
42
|
-
|
43
|
-
let(:desc1) { "assert not empty fail desc" }
|
44
|
-
let(:args1) { [[], desc1] }
|
45
|
-
let(:test1) {
|
43
|
+
subject do
|
46
44
|
args = args1
|
47
45
|
Factory.test do
|
48
46
|
assert_not_empty([1]) # pass
|
49
47
|
assert_not_empty(*args) # fail
|
50
48
|
end
|
51
|
-
|
52
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:desc1){ "assert not empty fail desc" }
|
52
|
+
let(:args1){ [[], desc1] }
|
53
|
+
let(:config1){ subject.config }
|
53
54
|
|
54
55
|
should "produce results as expected" do
|
55
56
|
subject.run(&test_run_callback)
|
@@ -59,7 +60,8 @@ module Assert::Assertions
|
|
59
60
|
assert_that(test_run_result_count(:fail)).equals(1)
|
60
61
|
|
61
62
|
exp =
|
62
|
-
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not
|
63
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not "\
|
64
|
+
"be empty."
|
63
65
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
64
66
|
end
|
65
67
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "assert/assertions"
|
3
5
|
|
@@ -8,18 +10,17 @@ module Assert::Assertions
|
|
8
10
|
include Assert::Test::TestHelpers
|
9
11
|
|
10
12
|
desc "`assert_equal`"
|
11
|
-
subject
|
12
|
-
|
13
|
-
let(:desc1) { "assert equal fail desc" }
|
14
|
-
let(:args1) { ["1", "2", desc1] }
|
15
|
-
let(:test1) {
|
13
|
+
subject do
|
16
14
|
args = args1
|
17
15
|
Factory.test do
|
18
16
|
assert_equal(1, 1) # pass
|
19
17
|
assert_equal(*args) # fail
|
20
18
|
end
|
21
|
-
|
22
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:desc1){ "assert equal fail desc" }
|
22
|
+
let(:args1){ ["1", "2", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
23
24
|
|
24
25
|
should "produce results as expected" do
|
25
26
|
subject.run(&test_run_callback)
|
@@ -39,18 +40,17 @@ module Assert::Assertions
|
|
39
40
|
include Assert::Test::TestHelpers
|
40
41
|
|
41
42
|
desc "`assert_not_equal`"
|
42
|
-
subject
|
43
|
-
|
44
|
-
let(:desc1) { "assert not equal fail desc" }
|
45
|
-
let(:args1) { ["1", "1", desc1] }
|
46
|
-
let(:test1) {
|
43
|
+
subject do
|
47
44
|
args = args1
|
48
45
|
Factory.test do
|
49
46
|
assert_not_equal(*args) # fail
|
50
47
|
assert_not_equal(1, 2) # pass
|
51
48
|
end
|
52
|
-
|
53
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:desc1){ "assert not equal fail desc" }
|
52
|
+
let(:args1){ ["1", "1", desc1] }
|
53
|
+
let(:config1){ subject.config }
|
54
54
|
|
55
55
|
should "produce results as expected" do
|
56
56
|
subject.run(&test_run_callback)
|
@@ -71,11 +71,31 @@ module Assert::Assertions
|
|
71
71
|
|
72
72
|
desc "with objects that define custom equality operators"
|
73
73
|
|
74
|
-
let(:is_class)
|
75
|
-
|
74
|
+
let(:is_class) do
|
75
|
+
Class.new do
|
76
|
+
def ==(other)
|
77
|
+
if other.is_a?(Assert::ActualValue.not_given.class)
|
78
|
+
super
|
79
|
+
else
|
80
|
+
true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
let(:is_not_class) do
|
86
|
+
Class.new do
|
87
|
+
def ==(other)
|
88
|
+
if other.is_a?(Assert::ActualValue.not_given.class)
|
89
|
+
super
|
90
|
+
else
|
91
|
+
false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
76
96
|
|
77
|
-
let(:is1)
|
78
|
-
let(:is_not1)
|
97
|
+
let(:is1){ is_class.new }
|
98
|
+
let(:is_not1){ is_not_class.new }
|
79
99
|
|
80
100
|
should "use the equality operator of the exp value" do
|
81
101
|
assert_that(is1).equals(is_not1)
|
@@ -88,29 +108,27 @@ module Assert::Assertions
|
|
88
108
|
|
89
109
|
desc "with objects that should use diff when showing"
|
90
110
|
|
91
|
-
let(:config1)
|
111
|
+
let(:config1) do
|
92
112
|
Factory.modes_off_config.tap do |config|
|
93
113
|
config.use_diff_proc(Assert::U.default_use_diff_proc)
|
94
114
|
config.run_diff_proc(Assert::U.syscmd_diff_proc)
|
95
115
|
end
|
96
|
-
|
116
|
+
end
|
97
117
|
|
98
|
-
let(:exp_obj1)
|
99
|
-
let(:act_obj1)
|
100
|
-
let(:exp_obj_show1)
|
101
|
-
let(:act_obj_show1)
|
118
|
+
let(:exp_obj1){ "I'm a\nstring" }
|
119
|
+
let(:act_obj1){ "I am a \nstring" }
|
120
|
+
let(:exp_obj_show1){ Assert::U.show_for_diff(exp_obj1, config1) }
|
121
|
+
let(:act_obj_show1){ Assert::U.show_for_diff(act_obj1, config1) }
|
102
122
|
end
|
103
123
|
|
104
124
|
class AssertEqualDiffTests < DiffTests
|
105
125
|
desc "`assert_equal`"
|
106
|
-
subject
|
107
|
-
|
108
|
-
let(:test1) {
|
126
|
+
subject do
|
109
127
|
exp_obj, act_obj = exp_obj1, act_obj1
|
110
128
|
Factory.test(config1) do
|
111
129
|
assert_equal(exp_obj, act_obj)
|
112
130
|
end
|
113
|
-
|
131
|
+
end
|
114
132
|
|
115
133
|
should "include diff output in the fail messages" do
|
116
134
|
subject.run(&test_run_callback)
|
@@ -124,14 +142,12 @@ module Assert::Assertions
|
|
124
142
|
|
125
143
|
class AssertNotEqualDiffTests < DiffTests
|
126
144
|
desc "`assert_not_equal`"
|
127
|
-
subject
|
128
|
-
|
129
|
-
let(:test1) {
|
145
|
+
subject do
|
130
146
|
exp_obj = exp_obj1
|
131
147
|
Factory.test(config1) do
|
132
148
|
assert_not_equal(exp_obj, exp_obj)
|
133
149
|
end
|
134
|
-
|
150
|
+
end
|
135
151
|
|
136
152
|
should "include diff output in the fail messages" do
|
137
153
|
subject.run(&test_run_callback)
|