minitest-difftastic 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +17 -1
- data/lib/minitest/difftastic/version.rb +1 -1
- data/lib/minitest/difftastic_plugin.rb +37 -3
- data/screenshots/integers.png +0 -0
- data/screenshots/nested_objects.png +0 -0
- data/screenshots/objects.png +0 -0
- data/screenshots/strings.png +0 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 692dd87d40229d2fea8ac5e00900e45ae33ec436b33f22d98027037f5448ef22
|
4
|
+
data.tar.gz: d1f4de4c6be40d5bdcd5efed3907ecfc52725d15f8d7606083c0d34b4904e142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c1ffb8e443e9423074ec083cc94f7c90121c44590ca7559ae6e0ed6ba75e4d7bec2b293f576e22a7dd4d48487a20c63ca6e0c28a94355d1f6972e3917f0afb
|
7
|
+
data.tar.gz: fb8c0fa64bed4a4d163a295343083b37418cd27ade769f2b8cb71d1dd6f2f8fbd116d0838b5fdd5e19de0411638c8a503ebf9177a25af55ae493c4865914d0f3
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
# Minitest::Difftastic
|
2
2
|
|
3
|
-
A Minitest Plugin which uses [`difftastic`](https://github.com/Wilfred/difftastic) (via [`difftastic-ruby`](https://github.com/joeldrapper/difftastic-ruby)) to show the diffs for failing assertions.
|
3
|
+
A Minitest Plugin which uses [`difftastic`](https://github.com/Wilfred/difftastic) (via [`difftastic-ruby`](https://github.com/joeldrapper/difftastic-ruby)) to show the diffs for failing assertions.
|
4
4
|
|
5
5
|
Also works for Rails tests using `ActiveSupport::TestCase`.
|
6
6
|
|
7
|
+
### Integers
|
8
|
+
|
9
|
+
![Integers Comparison](./screenshots/integers.png)
|
10
|
+
|
11
|
+
### Strings
|
12
|
+
|
13
|
+
![Strings Comparison](./screenshots/strings.png)
|
14
|
+
|
15
|
+
### Objects
|
16
|
+
|
17
|
+
![Objects Comparison](./screenshots/objects.png)
|
18
|
+
|
19
|
+
### Nested Objects
|
20
|
+
|
21
|
+
![Nested Objects Comparison](./screenshots/nested_objects.png)
|
22
|
+
|
7
23
|
## Installation
|
8
24
|
|
9
25
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -5,10 +5,44 @@ require "difftastic"
|
|
5
5
|
# TODO: use refinements
|
6
6
|
module Minitest
|
7
7
|
module Assertions
|
8
|
+
MINIMUM_OFFSET = 29
|
9
|
+
TAB_WIDTH = 2
|
10
|
+
|
11
|
+
RED = "\e[91;1m"
|
12
|
+
GREEN = "\e[92;1m"
|
13
|
+
RESET = "\e[0m"
|
14
|
+
|
15
|
+
DIFFER = ::Difftastic::Differ.new(
|
16
|
+
color: :always,
|
17
|
+
tab_width: TAB_WIDTH,
|
18
|
+
syntax_highlight: :off
|
19
|
+
)
|
20
|
+
|
21
|
+
alias diff_original diff
|
22
|
+
|
8
23
|
def diff(exp, act)
|
9
|
-
|
10
|
-
|
11
|
-
|
24
|
+
diff = DIFFER.diff_objects(exp, act)
|
25
|
+
offset = actual_text_offset(diff.split("\n").first)
|
26
|
+
|
27
|
+
"\n#{RED}#{"Expected".ljust(offset)} #{GREEN}Actual#{RESET}\n#{diff}"
|
28
|
+
rescue StandardError => e
|
29
|
+
puts "Minitest::DiffTastic error: #{e.inspect} (#{e.backtrace[0]})"
|
30
|
+
diff_original(exp, act)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def strip_ansi_formatting(string)
|
36
|
+
string.to_s.gsub(/\e\[[0-9;]*m/, "")
|
37
|
+
end
|
38
|
+
|
39
|
+
def actual_text_offset(line)
|
40
|
+
stripped_line = strip_ansi_formatting(line)
|
41
|
+
_lhs, rhs = stripped_line.split(/\s{#{TAB_WIDTH},}/, 2)
|
42
|
+
|
43
|
+
offset = stripped_line.index("#{" " * TAB_WIDTH}#{rhs}") + TAB_WIDTH - 1
|
44
|
+
|
45
|
+
[MINIMUM_OFFSET, offset].max
|
12
46
|
end
|
13
47
|
end
|
14
48
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-difftastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Roth
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: difftastic
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.1
|
27
|
-
description: Minitest Plugin to use difftastic for
|
27
|
+
description: Minitest Plugin to use difftastic for failed assertions
|
28
28
|
email:
|
29
29
|
- marco.roth@intergga.ch
|
30
30
|
executables: []
|
@@ -41,6 +41,10 @@ files:
|
|
41
41
|
- lib/minitest/difftastic.rb
|
42
42
|
- lib/minitest/difftastic/version.rb
|
43
43
|
- lib/minitest/difftastic_plugin.rb
|
44
|
+
- screenshots/integers.png
|
45
|
+
- screenshots/nested_objects.png
|
46
|
+
- screenshots/objects.png
|
47
|
+
- screenshots/strings.png
|
44
48
|
- sig/minitest/difftastic.rbs
|
45
49
|
homepage: https://github.com/marcoroth/minitest-difftastic
|
46
50
|
licenses: []
|
@@ -57,15 +61,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
61
|
requirements:
|
58
62
|
- - ">="
|
59
63
|
- !ruby/object:Gem::Version
|
60
|
-
version: 3.
|
64
|
+
version: 3.1.0
|
61
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
66
|
requirements:
|
63
67
|
- - ">="
|
64
68
|
- !ruby/object:Gem::Version
|
65
69
|
version: '0'
|
66
70
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.5.11
|
68
72
|
signing_key:
|
69
73
|
specification_version: 4
|
70
|
-
summary: Minitest Plugin to use difftastic for
|
74
|
+
summary: Minitest Plugin to use difftastic for failed assertions
|
71
75
|
test_files: []
|