super_diff 0.2.0 → 0.3.0

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.
@@ -142,7 +142,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
142
142
 
143
143
  it "produces the correct failure message when used in the negative" do
144
144
  as_both_colored_and_uncolored do |color_enabled|
145
- snippet = %|expect("Jennifer").to eq("Marty")|
145
+ snippet = %|expect("Jennifer").not_to eq("Jennifer")|
146
146
  program = make_plain_test_program(
147
147
  snippet,
148
148
  color_enabled: color_enabled,
@@ -150,16 +150,152 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
150
150
 
151
151
  expected_output = build_expected_output(
152
152
  color_enabled: color_enabled,
153
- snippet: %|expect("Jennifer").to eq("Marty")|,
153
+ snippet: %|expect("Jennifer").not_to eq("Jennifer")|,
154
154
  expectation: proc {
155
155
  line do
156
156
  plain "Expected "
157
157
  beta %|"Jennifer"|
158
+ plain " not to eq "
159
+ alpha %|"Jennifer"|
160
+ plain "."
161
+ end
162
+ },
163
+ )
164
+
165
+ expect(program).
166
+ to produce_output_when_run(expected_output).
167
+ in_color(color_enabled)
168
+ end
169
+ end
170
+ end
171
+
172
+ context "when comparing two different Time instances" do
173
+ it "produces the correct failure message when used in the positive" do
174
+ as_both_colored_and_uncolored do |color_enabled|
175
+ snippet = <<~RUBY
176
+ expected = Time.utc(2011, 12, 13, 14, 15, 16)
177
+ actual = Time.utc(2011, 12, 13, 14, 15, 16, 500_000)
178
+ expect(expected).to eq(actual)
179
+ RUBY
180
+ program = make_plain_test_program(
181
+ snippet,
182
+ color_enabled: color_enabled,
183
+ )
184
+
185
+ expected_output = build_expected_output(
186
+ color_enabled: color_enabled,
187
+ snippet: %|expect(expected).to eq(actual)|,
188
+ expectation: proc {
189
+ line do
190
+ plain "Expected "
191
+ beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
158
192
  plain " to eq "
159
- alpha %|"Marty"|
193
+ alpha %|2011-12-13 14:15:16.500 UTC +00:00 (Time)|
160
194
  plain "."
161
195
  end
162
196
  },
197
+ diff: proc {
198
+ plain_line " #<Time {"
199
+ plain_line " year: 2011,"
200
+ plain_line " month: 12,"
201
+ plain_line " day: 13,"
202
+ plain_line " hour: 14,"
203
+ plain_line " min: 15,"
204
+ plain_line " sec: 16,"
205
+ alpha_line "- nsec: 500000000,"
206
+ beta_line "+ nsec: 0,"
207
+ plain_line " zone: \"UTC\","
208
+ plain_line " gmt_offset: 0"
209
+ plain_line " }>"
210
+ },
211
+ )
212
+
213
+ expect(program).
214
+ to produce_output_when_run(expected_output).
215
+ in_color(color_enabled)
216
+ end
217
+ end
218
+
219
+ it "produces the correct failure message when used in the negative" do
220
+ as_both_colored_and_uncolored do |color_enabled|
221
+ snippet = <<~RUBY
222
+ time = Time.utc(2011, 12, 13, 14, 15, 16)
223
+ expect(time).not_to eq(time)
224
+ RUBY
225
+ program = make_plain_test_program(
226
+ snippet,
227
+ color_enabled: color_enabled,
228
+ )
229
+
230
+ expected_output = build_expected_output(
231
+ color_enabled: color_enabled,
232
+ snippet: %|expect(time).not_to eq(time)|,
233
+ newline_before_expectation: true,
234
+ expectation: proc {
235
+ line do
236
+ plain " Expected "
237
+ beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
238
+ end
239
+
240
+ line do
241
+ plain "not to eq "
242
+ alpha %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
243
+ end
244
+ },
245
+ )
246
+
247
+ expect(program).
248
+ to produce_output_when_run(expected_output).
249
+ in_color(color_enabled)
250
+ end
251
+ end
252
+ end
253
+
254
+ context "when comparing two different Time and ActiveSupport::TimeWithZone instances" do
255
+ it "produces the correct failure message when used in the positive" do
256
+ as_both_colored_and_uncolored do |color_enabled|
257
+ snippet = <<~RUBY
258
+ expected = Time.utc(2011, 12, 13, 14, 15, 16)
259
+ actual = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
260
+ expect(expected).to eq(actual)
261
+ RUBY
262
+ program = make_rspec_rails_test_program(
263
+ snippet,
264
+ color_enabled: color_enabled,
265
+ )
266
+
267
+ expected_output = build_expected_output(
268
+ color_enabled: color_enabled,
269
+ snippet: %|expect(expected).to eq(actual)|,
270
+ expectation: proc {
271
+ line do
272
+ plain "Expected "
273
+ beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
274
+ end
275
+
276
+ line do
277
+ plain " to eq "
278
+ alpha %|2011-12-13 16:15:16.000 CET +01:00 (ActiveSupport::TimeWithZone)|
279
+ end
280
+ },
281
+ diff: proc {
282
+ plain_line " #<ActiveSupport::TimeWithZone {"
283
+ plain_line " year: 2011,"
284
+ plain_line " month: 12,"
285
+ plain_line " day: 13,"
286
+ alpha_line "- hour: 16,"
287
+ beta_line "+ hour: 14,"
288
+ plain_line " min: 15,"
289
+ plain_line " sec: 16,"
290
+ plain_line " nsec: 0,"
291
+ alpha_line "- zone: \"CET\","
292
+ beta_line "+ zone: \"UTC\","
293
+ alpha_line "- gmt_offset: 3600,"
294
+ beta_line "+ gmt_offset: 0,"
295
+ alpha_line "- utc: 2011-12-13 15:15:16.000 UTC +00:00 (Time)"
296
+ beta_line "+ utc: 2011-12-13 14:15:16.000 UTC +00:00 (Time)"
297
+ plain_line " }>"
298
+ },
163
299
  )
164
300
 
165
301
  expect(program).
@@ -89,7 +89,7 @@ module SuperDiff
89
89
 
90
90
  def run_command
91
91
  CommandRunner.run(
92
- "rspec",
92
+ "rspec --options /tmp/dummy-rspec-config",
93
93
  tempfile.to_s,
94
94
  env: { "DISABLE_PRY" => "true" },
95
95
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Winkler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-05 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -142,6 +142,7 @@ files:
142
142
  - lib/super_diff/differs/empty.rb
143
143
  - lib/super_diff/differs/hash.rb
144
144
  - lib/super_diff/differs/multiline_string.rb
145
+ - lib/super_diff/differs/time.rb
145
146
  - lib/super_diff/equality_matcher.rb
146
147
  - lib/super_diff/equality_matchers.rb
147
148
  - lib/super_diff/equality_matchers/array.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/super_diff/object_inspection/inspectors/hash.rb
165
166
  - lib/super_diff/object_inspection/inspectors/primitive.rb
166
167
  - lib/super_diff/object_inspection/inspectors/string.rb
168
+ - lib/super_diff/object_inspection/inspectors/time.rb
167
169
  - lib/super_diff/object_inspection/map.rb
168
170
  - lib/super_diff/object_inspection/nodes.rb
169
171
  - lib/super_diff/object_inspection/nodes/base.rb
@@ -189,6 +191,7 @@ files:
189
191
  - lib/super_diff/operational_sequencers/default_object.rb
190
192
  - lib/super_diff/operational_sequencers/hash.rb
191
193
  - lib/super_diff/operational_sequencers/multiline_string.rb
194
+ - lib/super_diff/operational_sequencers/time_like.rb
192
195
  - lib/super_diff/operations.rb
193
196
  - lib/super_diff/operations/binary_operation.rb
194
197
  - lib/super_diff/operations/unary_operation.rb