minitest-snapshots 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 411f63a5cccd1e1db3268528b288bf135842b81a00545445d56aceb0e8bafe23
4
- data.tar.gz: 4b12cb599785b458f68f545bd3cc4725f2870d0d35ae4397a921a436a7b16c6f
3
+ metadata.gz: ada852a8846eb38fdbb54bba6137d8e98526400a6aeb7c4f69c2738063f84ab3
4
+ data.tar.gz: e6460d1edd5797c28d3f5646aeeaae97990224882fe8d66570be434bbc220766
5
5
  SHA512:
6
- metadata.gz: 1080bbc13fb55cbe405def0c01f6a8236fef0f4b73dba4d29615df7a7f11a1bdd7eee212a3b05efa9c5a08b8df36e564e8acb48395893d1a7d232724124b3611
7
- data.tar.gz: 3fff24593022ebe0d75419c4ba03dbb760b4a221852bde666c4d6cb982373bc1e18d48c503766c0b68c8e027cb4a33b7b0342d5306e3e66084771ff555c8a353
6
+ metadata.gz: 7be94c6b6a1aafccd033504c727dc7bd3ccc693e09f923f28dcf6604d3ef3e60aeb0e338567f34934bfb305ff1fd3602bf85768207c0c3cfa63a9d6367faaf05
7
+ data.tar.gz: 42388f113aa86b0e8525a09fc25322a0e632003f1ee00d37a4bb9d4f00f9a57f5d94c183a799f52650f2b2e0d2fabecf568be0ac24a828a1770711505441262d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-snapshots (0.2.0)
4
+ minitest-snapshots (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,9 @@
1
+ require "fileutils"
2
+
1
3
  module Minitest
2
4
  module Assertions
3
5
  def assert_matches_snapshot(string, snapshot_name = nil)
4
- snapshot_file = snapshot_path(snapshot_name || (@snapshot_assertion_counter += 1))
6
+ snapshot_file = snapshot_path(self.class.name.underscore, snapshot_name || (@snapshot_assertion_counter += 1))
5
7
 
6
8
  if !Minitest::Snapshots.force_updates && File.exist?(snapshot_file)
7
9
  assert_equal File.read(snapshot_file), string, "The string does not match the snapshot (located at #{snapshot_file})"
@@ -9,6 +11,9 @@ module Minitest
9
11
  if Minitest::Snapshots.lock_snapshots
10
12
  assert false, "New snapshot tried to be created when snapshot writing is prevented with the --lock-snapshots option."
11
13
  end
14
+
15
+ FileUtils.mkdir_p(File.dirname(snapshot_file))
16
+
12
17
  File.open(snapshot_file, "w") do |file|
13
18
  file.write(string)
14
19
  end
@@ -1,16 +1,22 @@
1
+ require "fileutils"
2
+
1
3
  module Minitest
2
4
  module Snapshots
3
5
  module TestExtensions
4
6
  def before_setup
5
7
  super
6
8
  @snapshot_assertion_counter = 0
7
- @snapshot_dir ||= Rails.root.join("test", "snapshots").to_s
9
+ @snapshot_dir ||= if defined?(Rails)
10
+ Rails.root.join("test", "snapshots").to_s
11
+ else
12
+ FileUtils.pwd
13
+ end
8
14
  end
9
15
 
10
16
  private
11
17
 
12
- def snapshot_path(snapshot_name)
13
- File.join(@snapshot_dir, "#{name}__#{snapshot_name}.snap.txt")
18
+ def snapshot_path(suite_name, snapshot_name)
19
+ File.join(@snapshot_dir, suite_name, "#{name}__#{snapshot_name}.snap.txt")
14
20
  end
15
21
  end
16
22
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Snapshots
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-snapshots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Brundage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2019-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler