snapshot_testing 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/__snapshots__/named.rspec.txt +3 -1
- data/examples/rspec.rb +7 -1
- data/lib/snapshot_testing/rspec.rb +8 -12
- data/lib/snapshot_testing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34fda2f98525f2de25ae45b78c943965afae17b2
|
4
|
+
data.tar.gz: 488bab370972b35f7b891b11012abdcd1b68bb23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1927abd0956bb9a001c690e2ab53789e443003a3eded4ead50f13281b7378a92bc837f5477c996c0f019e5232262dda2714c57e23d93a262faf436b09e389b
|
7
|
+
data.tar.gz: 4a46591f6322bed4702efea3531795b183514a467d8204f2abf6f0c82ee8ffc7b65cad608752fa38fa78aea1de4556d284c883ecbfeb5813bfc9fc065901cc18
|
data/examples/rspec.rb
CHANGED
@@ -13,6 +13,12 @@ RSpec.describe "Example" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "takes a named snapshot" do
|
16
|
-
|
16
|
+
message = <<~EOS
|
17
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam diam
|
18
|
+
urna, dignissim a faucibus eu, malesuada vitae tellus. Aliquam dignissim
|
19
|
+
volutpat fermentum. Nam ultricies risus ac ornare venenatis.
|
20
|
+
EOS
|
21
|
+
|
22
|
+
expect(message).to match_snapshot("named.rspec.txt")
|
17
23
|
end
|
18
24
|
end
|
@@ -19,28 +19,24 @@ module SnapshotTesting
|
|
19
19
|
|
20
20
|
matcher :match_snapshot do |name|
|
21
21
|
match do |actual|
|
22
|
+
@actual = actual
|
22
23
|
@expected = if name.nil?
|
23
24
|
__snapshot_recorder__.record(actual)
|
24
25
|
else
|
25
26
|
__snapshot_recorder__.record_file(name, actual)
|
26
27
|
end
|
27
28
|
|
28
|
-
@expected == actual
|
29
|
+
@expected == @actual
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
description { "match snapshot #{expected_formatted}"}
|
32
|
+
description { "match snapshot #{@expected.inspect}"}
|
33
33
|
|
34
|
-
failure_message do
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def expected_formatted
|
39
|
-
::RSpec::Support::ObjectFormatter.format(@expected)
|
40
|
-
end
|
34
|
+
failure_message do
|
35
|
+
diff = ::RSpec::Expectations.differ.diff(@actual, @expected)
|
41
36
|
|
42
|
-
|
43
|
-
|
37
|
+
message = "\nexpected: #{@expected.inspect}\n got: #{@actual.inspect}\n"
|
38
|
+
message = "#{message}\nDiff: #{diff}" unless diff.strip.empty?
|
39
|
+
message
|
44
40
|
end
|
45
41
|
end
|
46
42
|
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.1
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|