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