|
25 | 25 | end
|
26 | 26 | end
|
27 | 27 |
|
| 28 | + context "given the same symbol" do |
| 29 | + it "returns an empty string" do |
| 30 | + output = described_class.call(expected: :foo, actual: :foo) |
| 31 | + |
| 32 | + expect(output).to eq("") |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + context "given differing symbols" do |
| 37 | + it "returns a message along with a comparison" do |
| 38 | + actual_output = described_class.call(expected: :foo, actual: :bar) |
| 39 | + |
| 40 | + expected_output = <<~STR |
| 41 | + Differing symbols. |
| 42 | +
|
| 43 | + Expected: :foo |
| 44 | + Actual: :bar |
| 45 | + STR |
| 46 | + |
| 47 | + expect(actual_output).to eq(expected_output) |
| 48 | + end |
| 49 | + end |
| 50 | + |
28 | 51 | context "given the same string" do
|
29 | 52 | it "returns an empty string" do
|
30 | 53 | output = described_class.call(expected: "", actual: "")
|
|
131 | 154 | end
|
132 | 155 | end
|
133 | 156 |
|
134 |
| - context "given two equal-length, one-dimensional arrays with differing strings" do |
| 157 | + context "given two equal-length, one-dimensional arrays with differing numbers" do |
135 | 158 | it "returns a message along with the diff" do
|
136 | 159 | actual_output = described_class.call(
|
137 |
| - expected: ["foo", "bar", "qux"], |
138 |
| - actual: ["foo", "baz", "qux"] |
| 160 | + expected: [1, 2, 3, 4], |
| 161 | + actual: [1, 2, 99, 4] |
139 | 162 | )
|
140 | 163 |
|
141 | 164 | expected_output = <<~STR
|
142 | 165 | Differing arrays.
|
143 | 166 |
|
144 |
| - Expected: ["foo", "bar", "qux"] |
145 |
| - Actual: ["foo", "baz", "qux"] |
| 167 | + Expected: [1, 2, 3, 4] |
| 168 | + Actual: [1, 2, 99, 4] |
146 | 169 |
|
147 | 170 | Details:
|
148 | 171 |
|
149 |
| - - *[1]: Differing strings. |
150 |
| - Expected: "bar" |
151 |
| - Actual: "baz" |
| 172 | + - *[2]: Differing numbers. |
| 173 | + Expected: 3 |
| 174 | + Actual: 99 |
152 | 175 | STR
|
153 | 176 |
|
154 | 177 | expect(actual_output).to eq(expected_output)
|
155 | 178 | end
|
156 | 179 | end
|
157 | 180 |
|
158 |
| - context "given two equal-length, one-dimensional arrays with differing numbers" do |
| 181 | + context "given two equal-length, one-dimensional arrays with differing symbols" do |
159 | 182 | it "returns a message along with the diff" do
|
160 | 183 | actual_output = described_class.call(
|
161 |
| - expected: [1, 2, 3, 4], |
162 |
| - actual: [1, 2, 99, 4] |
| 184 | + expected: [:one, :fish, :two, :fish], |
| 185 | + actual: [:one, :FISH, :two, :fish] |
163 | 186 | )
|
164 | 187 |
|
165 | 188 | expected_output = <<~STR
|
166 | 189 | Differing arrays.
|
167 | 190 |
|
168 |
| - Expected: [1, 2, 3, 4] |
169 |
| - Actual: [1, 2, 99, 4] |
| 191 | + Expected: [:one, :fish, :two, :fish] |
| 192 | + Actual: [:one, :FISH, :two, :fish] |
170 | 193 |
|
171 | 194 | Details:
|
172 | 195 |
|
173 |
| - - *[2]: Differing numbers. |
174 |
| - Expected: 3 |
175 |
| - Actual: 99 |
| 196 | + - *[1]: Differing symbols. |
| 197 | + Expected: :fish |
| 198 | + Actual: :FISH |
| 199 | + STR |
| 200 | + |
| 201 | + expect(actual_output).to eq(expected_output) |
| 202 | + end |
| 203 | + end |
| 204 | + |
| 205 | + context "given two equal-length, one-dimensional arrays with differing strings" do |
| 206 | + it "returns a message along with the diff" do |
| 207 | + actual_output = described_class.call( |
| 208 | + expected: ["foo", "bar", "qux"], |
| 209 | + actual: ["foo", "baz", "qux"] |
| 210 | + ) |
| 211 | + |
| 212 | + expected_output = <<~STR |
| 213 | + Differing arrays. |
| 214 | +
|
| 215 | + Expected: ["foo", "bar", "qux"] |
| 216 | + Actual: ["foo", "baz", "qux"] |
| 217 | +
|
| 218 | + Details: |
| 219 | +
|
| 220 | + - *[1]: Differing strings. |
| 221 | + Expected: "bar" |
| 222 | + Actual: "baz" |
176 | 223 | STR
|
177 | 224 |
|
178 | 225 | expect(actual_output).to eq(expected_output)
|
|
0 commit comments