snapshot_testing 0.3.2 → 0.3.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 +5 -5
- data/lib/snapshot_testing/recorder.rb +30 -12
- data/lib/snapshot_testing/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: abbd9e5dcb8e1bfc22a718387076ca8bc503da999d9d85ffb524a52b1ec9a01c
|
4
|
+
data.tar.gz: a6286990db3d03a19f8afc35f61c447b686f0cdfbc2f82f1513fa3881efbdd09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d91ce651122861a12589a3f6b70e5e9c7958fd972ad2ca8ea6d937474d3cafaf502afa3b24cb1503a5e95d20d73392a5a055b6d0fcb346f91b47e483391863
|
7
|
+
data.tar.gz: a9cae871013fadb45996d40822b0edae0fd0f6c9a6664b9cab38d9d0884f4e73cb2310ec613a4de3e04ed5390e07530cd73a1d48ef234501bae40492f7322528
|
@@ -9,6 +9,7 @@ module SnapshotTesting
|
|
9
9
|
@visited = []
|
10
10
|
@added = 0
|
11
11
|
@updated = 0
|
12
|
+
@removed = 0
|
12
13
|
end
|
13
14
|
|
14
15
|
def snapshot_path
|
@@ -60,15 +61,13 @@ module SnapshotTesting
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def commit
|
63
|
-
|
64
|
-
|
65
|
-
removed.each { |key| snapshots.delete(key) }
|
64
|
+
prune_snapshots if update?
|
65
|
+
write_snapshots if write?
|
66
66
|
|
67
|
-
write_snapshots(snapshots) if write?
|
68
67
|
log(added, :written) unless added.zero?
|
69
68
|
log(updated, :updated) unless updated.zero?
|
70
|
-
log(removed
|
71
|
-
log(
|
69
|
+
log(removed, :removed) unless removed.zero?
|
70
|
+
log(obsolete, :obsolete) unless obsolete.zero?
|
72
71
|
end
|
73
72
|
|
74
73
|
protected
|
@@ -79,6 +78,9 @@ module SnapshotTesting
|
|
79
78
|
# the number of updated snapshots
|
80
79
|
attr_accessor :updated
|
81
80
|
|
81
|
+
# the number of removed snapshots
|
82
|
+
attr_accessor :removed
|
83
|
+
|
82
84
|
# all snapshots that have been compared
|
83
85
|
attr_reader :visited
|
84
86
|
|
@@ -97,7 +99,28 @@ module SnapshotTesting
|
|
97
99
|
|
98
100
|
# should we write to the filesystem?
|
99
101
|
def write?
|
100
|
-
|
102
|
+
return true unless added.zero?
|
103
|
+
return false unless update?
|
104
|
+
!(updated + removed).zero?
|
105
|
+
end
|
106
|
+
|
107
|
+
# remove stale snapshots
|
108
|
+
def prune_snapshots
|
109
|
+
stale = snapshots.keys - visited
|
110
|
+
stale = stale.grep(/^#{name}\s\d+$/)
|
111
|
+
stale.each { |key| snapshots.delete(key) }
|
112
|
+
self.removed = stale.length
|
113
|
+
end
|
114
|
+
|
115
|
+
# the number of obsolete snapshots
|
116
|
+
def obsolete
|
117
|
+
(snapshots.keys - visited).grep(/^#{name}\s\d+$/).length
|
118
|
+
end
|
119
|
+
|
120
|
+
# write all snapshots to the filesystem
|
121
|
+
def write_snapshots
|
122
|
+
FileUtils.mkdir_p(snapshots_path)
|
123
|
+
File.write(snapshot_path, Snapshot.dump(snapshots))
|
101
124
|
end
|
102
125
|
|
103
126
|
def snapshots_path
|
@@ -117,10 +140,5 @@ module SnapshotTesting
|
|
117
140
|
FileUtils.mkdir_p(snapshots_path)
|
118
141
|
File.write(File.join(snapshots_path, name), data)
|
119
142
|
end
|
120
|
-
|
121
|
-
def write_snapshots(snapshots)
|
122
|
-
FileUtils.mkdir_p(snapshots_path)
|
123
|
-
File.write(snapshot_path, Snapshot.dump(snapshots))
|
124
|
-
end
|
125
143
|
end
|
126
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapshot_testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.6
|
150
|
+
rubygems_version: 2.7.6
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Proper snapshot support for RSpec.
|