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