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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1165c4cf04b324c16e1e189f35e278a6b5e0576
4
- data.tar.gz: d3855143a9680fcc6fa1fde7a5319bf0b5eb57b0
3
+ metadata.gz: 07c63dd63678069e3f072b0efa3502ed7b733aac
4
+ data.tar.gz: 369ed422cd2ebd54739d1244ec6a27dd9067ed59
5
5
  SHA512:
6
- metadata.gz: 148b5ff9dc1a44be11e22a7daeab47a3d74cad14ef6a859c04e6f71fefc0f5f8322c3d576cb8393ce45f47d224ee61020fc5ec5af30988bf1cdd7ef8be6ea540
7
- data.tar.gz: 3cdb26755cab8aaac328079a60ab8474d91405c1ccce123964a82eacfa7941880036feb6d072569d453d0dedf24fc58c19e652442c48aa379b33b69989aac7fb
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
@@ -1,3 +1,3 @@
1
1
  module AssertMatchesSnapshot
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_matches_snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Broadley