snapshot_testing 0.3.3 → 0.3.4
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 +4 -4
- data/.gitignore +2 -0
- data/Rakefile +19 -9
- data/examples/minitest.rb +8 -0
- data/examples/rspec.rb +5 -0
- data/examples/test_unit.rb +4 -0
- data/lib/snapshot_testing/recorder.rb +7 -2
- data/lib/snapshot_testing/version.rb +1 -1
- metadata +3 -11
- data/examples/__snapshots__/minitest.rb.snap +0 -15
- data/examples/__snapshots__/named.minitest.spec.txt +0 -1
- data/examples/__snapshots__/named.minitest.test.txt +0 -1
- data/examples/__snapshots__/named.rspec.txt +0 -3
- data/examples/__snapshots__/named.unit.txt +0 -1
- data/examples/__snapshots__/rspec.rb.snap +0 -7
- data/examples/__snapshots__/test_unit.rb.snap +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24fffb537b059196e90489d136f7de672ee775dec6930f44c1906c21eac7d57d
|
4
|
+
data.tar.gz: 4708f457af4cf2bff18f17e3acb87631398d3dbb5ee04132283f3bf4a9f575fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbe9245acd2bb2726bb1b022de932723e0a2a0ec29a097f9f20e46afa19fea53ecd7c6baa4ed3b67a84e2ba00370d81d0695170012f046ca4b0ac18d1b85189d
|
7
|
+
data.tar.gz: 6a3e4e412bd2e5b0ccb7d498c11dd841a53c80cdd66a6f8cfded7d39497081a025770bb3c89a78c135acd4099b9324480e8a3d0913f5dfd735498d14833736dd
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -3,19 +3,29 @@ require "rspec/core/rake_task"
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module Color
|
7
|
+
def self.bold(msg); "\e[1m#{msg}\e[22m" end
|
8
|
+
def self.pink(msg); "\e[35m#{msg}\e[0m" end
|
9
|
+
def self.cyan(msg); "\e[36m#{msg}\e[0m" end
|
8
10
|
end
|
9
11
|
|
10
12
|
task :examples do
|
11
|
-
|
12
|
-
|
13
|
+
suites = [
|
14
|
+
["RSpec", "examples/rspec.rb -f progress --no-color"],
|
15
|
+
["Minitest", "examples/minitest.rb"],
|
16
|
+
["TestUnit", "examples/test_unit.rb --no-use-color"]
|
17
|
+
]
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
rm_rf "examples/__snapshots__/"
|
20
|
+
suites.each do |name, test_file|
|
21
|
+
puts Color.bold("==== #{name} ==============================")
|
22
|
+
puts Color.cyan("==>> Running #{name} for the first time...")
|
23
|
+
ruby test_file
|
24
|
+
puts "\n\n"
|
25
|
+
puts Color.pink("==>> Running #{name} against saved snapshots...")
|
26
|
+
ruby test_file
|
27
|
+
puts "\n\n"
|
28
|
+
end
|
19
29
|
end
|
20
30
|
|
21
31
|
task :default => :spec
|
data/examples/minitest.rb
CHANGED
@@ -13,6 +13,10 @@ class ExampleTest < Minitest::Test
|
|
13
13
|
def test_named_snapshot
|
14
14
|
assert_snapshot "named.minitest.test.txt", "named"
|
15
15
|
end
|
16
|
+
|
17
|
+
define_method "test_escapes_regex_[]" do
|
18
|
+
assert_snapshot "hello"
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
class ExampleSpec < Minitest::Spec
|
@@ -26,4 +30,8 @@ class ExampleSpec < Minitest::Spec
|
|
26
30
|
it "takes a named snapshot" do
|
27
31
|
_("named").must_match_snapshot "named.minitest.spec.txt"
|
28
32
|
end
|
33
|
+
|
34
|
+
it "escapes regex []" do
|
35
|
+
_("hello").must_match_snapshot
|
36
|
+
end
|
29
37
|
end
|
data/examples/rspec.rb
CHANGED
@@ -4,6 +4,7 @@ require "snapshot_testing/rspec"
|
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.include SnapshotTesting::RSpec
|
7
|
+
config.color = false
|
7
8
|
end
|
8
9
|
|
9
10
|
RSpec.describe "Example" do
|
@@ -21,4 +22,8 @@ RSpec.describe "Example" do
|
|
21
22
|
|
22
23
|
expect(message).to match_snapshot("named.rspec.txt")
|
23
24
|
end
|
25
|
+
|
26
|
+
it "escapes regex []" do
|
27
|
+
expect("hello").to match_snapshot
|
28
|
+
end
|
24
29
|
end
|
data/examples/test_unit.rb
CHANGED
@@ -92,6 +92,11 @@ module SnapshotTesting
|
|
92
92
|
# the file location of the current test
|
93
93
|
attr_reader :path
|
94
94
|
|
95
|
+
# a Regexp that will match a snapshot name
|
96
|
+
def name_pattern
|
97
|
+
/^#{Regexp.escape(name)}\s\d+$/
|
98
|
+
end
|
99
|
+
|
95
100
|
# should we update failing snapshots?
|
96
101
|
def update?
|
97
102
|
@update
|
@@ -107,14 +112,14 @@ module SnapshotTesting
|
|
107
112
|
# remove stale snapshots
|
108
113
|
def prune_snapshots
|
109
114
|
stale = snapshots.keys - visited
|
110
|
-
stale = stale.grep(
|
115
|
+
stale = stale.grep(name_pattern)
|
111
116
|
stale.each { |key| snapshots.delete(key) }
|
112
117
|
self.removed = stale.length
|
113
118
|
end
|
114
119
|
|
115
120
|
# the number of obsolete snapshots
|
116
121
|
def obsolete
|
117
|
-
(snapshots.keys - visited).grep(
|
122
|
+
(snapshots.keys - visited).grep(name_pattern).length
|
118
123
|
end
|
119
124
|
|
120
125
|
# write all snapshots to the filesystem
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,13 +109,6 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- bin/console
|
111
111
|
- bin/setup
|
112
|
-
- examples/__snapshots__/minitest.rb.snap
|
113
|
-
- examples/__snapshots__/named.minitest.spec.txt
|
114
|
-
- examples/__snapshots__/named.minitest.test.txt
|
115
|
-
- examples/__snapshots__/named.rspec.txt
|
116
|
-
- examples/__snapshots__/named.unit.txt
|
117
|
-
- examples/__snapshots__/rspec.rb.snap
|
118
|
-
- examples/__snapshots__/test_unit.rb.snap
|
119
112
|
- examples/minitest.rb
|
120
113
|
- examples/rspec.rb
|
121
114
|
- examples/test_unit.rb
|
@@ -146,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
139
|
- !ruby/object:Gem::Version
|
147
140
|
version: '0'
|
148
141
|
requirements: []
|
149
|
-
|
150
|
-
rubygems_version: 2.7.6
|
142
|
+
rubygems_version: 3.0.3
|
151
143
|
signing_key:
|
152
144
|
specification_version: 4
|
153
145
|
summary: Proper snapshot support for RSpec.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
snapshots["test_0001_takes a snapshot 1"] = <<-SNAP
|
2
|
-
hello
|
3
|
-
SNAP
|
4
|
-
|
5
|
-
snapshots["test_0001_takes a snapshot 2"] = <<-SNAP
|
6
|
-
goodbye
|
7
|
-
SNAP
|
8
|
-
|
9
|
-
snapshots["test_snapshot 1"] = <<-SNAP
|
10
|
-
hello
|
11
|
-
SNAP
|
12
|
-
|
13
|
-
snapshots["test_snapshot 2"] = <<-SNAP
|
14
|
-
goodbye
|
15
|
-
SNAP
|
@@ -1 +0,0 @@
|
|
1
|
-
named
|
@@ -1 +0,0 @@
|
|
1
|
-
named
|
@@ -1 +0,0 @@
|
|
1
|
-
named
|