rematch 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/minitest/rematch_plugin.rb +6 -6
- data/lib/rematch.rb +24 -14
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785b035990ab3f3b2615c20211f0714b475adc30c2b10340b22fc2c3aedb3ab4
|
4
|
+
data.tar.gz: 1b1cdcc8e0a17a2564aff63e89ff41d652320259d4be90d315704f7fe2a1843b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ea2ec684a238530b4050d89a63cf4d8454264e5df821122d4857f5ece42cf0f29c63b26bc4cfe8675b60599a85c8f0987d0c9783bf437f62d5ecfcc11c6e9f
|
7
|
+
data.tar.gz: 981c98f90eb585f57bb0bd8808c43b146b8ab7d8503ef9646620ed1003375a29e29d02bb057b4eb4eecc2a30ba61c1233692d1cd84cf57c372648915824a4b76
|
@@ -23,16 +23,16 @@ module Minitest
|
|
23
23
|
# Reopen the minitest module
|
24
24
|
module Assertions
|
25
25
|
# Main assertion
|
26
|
-
def assert_rematch(actual, *args)
|
26
|
+
def assert_rematch(key, actual, *args)
|
27
27
|
assertion = :assert_equal
|
28
28
|
message = nil
|
29
29
|
args.each { |arg| arg.is_a?(Symbol) ? assertion = arg : message = arg }
|
30
|
-
send assertion, @rematch.rematch(actual), actual, message # assert that the stored value is the same actual value
|
30
|
+
send assertion, @rematch.rematch(key, actual), actual, message # assert that the stored value is the same actual value
|
31
31
|
end
|
32
32
|
|
33
33
|
# Temporarily used to store the actual value, useful for reconciliation of expected changed values
|
34
|
-
def store_assert_rematch(actual, *_args)
|
35
|
-
@rematch.store(actual)
|
34
|
+
def store_assert_rematch(key, actual, *_args)
|
35
|
+
@rematch.store(key, actual)
|
36
36
|
# Always fail after storing, forcing the restore of the original assertion/expectation
|
37
37
|
raise Minitest::Assertion, '[rematch] the value has been stored: remove the "store_" prefix to pass the test'
|
38
38
|
end
|
@@ -41,7 +41,7 @@ module Minitest
|
|
41
41
|
# Reopen the minitest module
|
42
42
|
module Expectations
|
43
43
|
# Add the expectations pointing to the assertions
|
44
|
-
infect_an_assertion :assert_rematch, :must_rematch
|
45
|
-
infect_an_assertion :store_assert_rematch, :store_must_rematch
|
44
|
+
infect_an_assertion :assert_rematch, :must_rematch
|
45
|
+
infect_an_assertion :store_assert_rematch, :store_must_rematch
|
46
46
|
end
|
47
47
|
end
|
data/lib/rematch.rb
CHANGED
@@ -5,7 +5,7 @@ require 'fileutils'
|
|
5
5
|
|
6
6
|
# Handles the key/value store for each test
|
7
7
|
class Rematch
|
8
|
-
VERSION = '
|
8
|
+
VERSION = '2.0.0'
|
9
9
|
EXT = '.rematch'
|
10
10
|
|
11
11
|
@rebuild = false # rebuild the store?
|
@@ -29,24 +29,34 @@ class Rematch
|
|
29
29
|
self.class.check_rebuild(path)
|
30
30
|
@store = YAML::Store.new(path, true)
|
31
31
|
@id = id
|
32
|
-
@count = 0
|
33
32
|
end
|
34
33
|
|
35
34
|
# Retrieve the stored value for the current assertion if its key is known; store the value otherwise
|
36
|
-
def rematch(value)
|
37
|
-
key = assertion_key
|
38
|
-
@store.transaction
|
35
|
+
def rematch(key, value)
|
36
|
+
# key = assertion_key(key)
|
37
|
+
@store.transaction do |s|
|
38
|
+
if s.root?(@id) # there is the root id
|
39
|
+
if s[@id].key?(key) # there is the key
|
40
|
+
s[@id][key] # return it
|
41
|
+
else # not such a key
|
42
|
+
s[@id][key] = value # set
|
43
|
+
end
|
44
|
+
else # there is no root yet
|
45
|
+
s[@id] = { key => value } # the key is the first one
|
46
|
+
value # always return the value
|
47
|
+
end
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
# Store the value
|
42
|
-
def store(value)
|
43
|
-
@store.transaction
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
def store(key, value)
|
53
|
+
@store.transaction do |s|
|
54
|
+
if s.root?(@id) # there is the root id
|
55
|
+
s[@id][key] = value # set
|
56
|
+
else # there is no root yet
|
57
|
+
s[@id] = { key => value } # the key is the first one
|
58
|
+
value # always return the value
|
59
|
+
end
|
60
|
+
end
|
51
61
|
end
|
52
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rematch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Instead of copying and pasting large outputs or big ruby structures into
|
14
14
|
all the affected test files every time your code change, you can do it the easy
|
@@ -38,14 +38,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
39
39
|
- - ">"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '3.1'
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
48
|
+
rubygems_version: 3.5.3
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Declutter your test files from large hardcoded data and update them automatically
|