assert_matches_snapshot 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/assert_matches_snapshot/assertion.rb +7 -1
- data/lib/assert_matches_snapshot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c63dd63678069e3f072b0efa3502ed7b733aac
|
4
|
+
data.tar.gz: 369ed422cd2ebd54739d1244ec6a27dd9067ed59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716848dc0e655ca0b92806d109e45cd9e17f8b42fcc7eab6ba02beb1068a0f38d9c33a503338d9621b9baf4f7422e1762f570a4f11725947d9c4964692813bbe
|
7
|
+
data.tar.gz: c0e53183b7afd0d54fdb940faf06574581a43c995aa25a29c8877320d3e81db5d82f2b6f38826523d60d5b69292ac33235a5d810fa2244c95a6efe9523523b75
|
data/README.md
CHANGED
@@ -28,6 +28,8 @@ assert_matches_snapshot 'after page is loaded'
|
|
28
28
|
|
29
29
|
`assert_matches_snapshot` takes one argument: a string that is used to distinguish snapshots from each other. This string should be unique across all tests for a controller-action combination.
|
30
30
|
|
31
|
+
To overwrite the snapshots, pass the argument `--overwrite-snapshots` to your test command.
|
32
|
+
|
31
33
|
## Development
|
32
34
|
|
33
35
|
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests, or `bundle exec guard` to run the tests every time a file is changed.
|
@@ -6,7 +6,7 @@ module AssertMatchesSnapshot
|
|
6
6
|
FileUtils.mkpath(snapshot_file_path)
|
7
7
|
|
8
8
|
full_path = snapshot_file_full_path(key)
|
9
|
-
if File.exists?(full_path)
|
9
|
+
if File.exists?(full_path) && !OverwriteSnapshots.active?
|
10
10
|
assert_equal response.body, IO.read(full_path)
|
11
11
|
else
|
12
12
|
File.open(full_path, 'w') do |snapshot_file|
|
@@ -29,5 +29,11 @@ module AssertMatchesSnapshot
|
|
29
29
|
def snapshot_file_name(key)
|
30
30
|
"#{@controller.controller_name}_#{@controller.action_name}_#{key}".downcase.gsub(/\W/, '_') + ".snapshot.html"
|
31
31
|
end
|
32
|
+
|
33
|
+
class OverwriteSnapshots
|
34
|
+
def self.active?
|
35
|
+
ARGV.include?('--overwrite-snapshots')
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|