rematch 0.0.1 → 1.3.1
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 +4 -4
- data/lib/minitest/rematch_plugin.rb +18 -4
- data/lib/rematch.rb +19 -3
- metadata +8 -8
- data/lib/rematch/tasks.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3271af42b8c0ebd9bd6c291e07fe71c1a90da689c211d170169b4ad25f6333
|
4
|
+
data.tar.gz: 3a27075b4698939aa160c670e27a937bc7f958d4918257e5264057caf17dbf2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ce7f05a928e044bca8d416df72a316a9d6f280d8fb05570e5b8f6a380568c378d8aedba8374f5a31e02069c262a1e92cf152f819702d5e8eebdb3f7445067e
|
7
|
+
data.tar.gz: b12f5b0f28535c42457d6a4da0266472ef4968691a4d6969c919090849d9d14394f5ef117955b52b684b0292e08263812220b340acb0071781960536da8c7aca
|
@@ -4,18 +4,32 @@ require 'rematch'
|
|
4
4
|
|
5
5
|
# Implement the minitest plugin
|
6
6
|
module Minitest
|
7
|
+
def self.plugin_rematch_options(opts, _options)
|
8
|
+
opts.on '--rematch-rebuild', 'Rebuild the stores with the current entries/values' do
|
9
|
+
Rematch.rebuild = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# reopen the minitest class
|
7
14
|
class Test
|
8
15
|
def before_setup
|
9
|
-
@rematch = Rematch.new(path: method(name).source_location.first, id: location)
|
10
16
|
super
|
17
|
+
@rematch = Rematch.new(path: method(name).source_location.first, id: location)
|
11
18
|
end
|
12
19
|
end
|
20
|
+
|
21
|
+
# reopen the minitest module
|
13
22
|
module Assertions
|
14
|
-
def assert_rematch(
|
15
|
-
assert_equal
|
23
|
+
def assert_rematch(actual, *args)
|
24
|
+
assertion = :assert_equal
|
25
|
+
message = nil
|
26
|
+
args.each { |arg| arg.is_a?(Symbol) ? assertion = arg : message = arg }
|
27
|
+
send assertion, @rematch.rematch(actual), actual, message
|
16
28
|
end
|
17
29
|
end
|
30
|
+
|
31
|
+
# reopen the minitest module
|
18
32
|
module Expectations
|
19
|
-
infect_an_assertion :assert_rematch, :must_rematch
|
33
|
+
infect_an_assertion :assert_rematch, :must_rematch, true # dont_flip
|
20
34
|
end
|
21
35
|
end
|
data/lib/rematch.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml/store'
|
4
|
-
require '
|
4
|
+
require 'fileutils'
|
5
5
|
|
6
6
|
# Implement the key/value store
|
7
7
|
class Rematch
|
8
|
-
VERSION = '
|
8
|
+
VERSION = '1.3.1'
|
9
9
|
EXT = '.rematch'
|
10
10
|
|
11
|
+
@rebuild = false
|
12
|
+
@rebuilt = []
|
13
|
+
class << self
|
14
|
+
attr_accessor :rebuild
|
15
|
+
|
16
|
+
def check_rebuild(path)
|
17
|
+
return unless @rebuild && !@rebuilt.include?(path)
|
18
|
+
|
19
|
+
FileUtils.rm_f(path)
|
20
|
+
@rebuilt << path
|
21
|
+
puts "Rebuilt #{path}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
11
25
|
# path and unique id of the test being run
|
12
26
|
def initialize(path:, id:)
|
13
|
-
|
27
|
+
path = "#{path}#{EXT}"
|
28
|
+
self.class.check_rebuild(path)
|
29
|
+
@store = YAML::Store.new(path, true)
|
14
30
|
@id = id
|
15
31
|
@count = 0
|
16
32
|
end
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rematch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
13
|
+
description: Instead of copying and pasting large outputs or big ruby structures into
|
14
|
+
all the affected test files every time your code change, you can do it the easy
|
15
|
+
way, possibly saving many hours of boring maintenance work!
|
16
16
|
email:
|
17
17
|
- dd.nexus@gmail.com
|
18
18
|
executables: []
|
@@ -22,7 +22,6 @@ files:
|
|
22
22
|
- LICENSE.txt
|
23
23
|
- lib/minitest/rematch_plugin.rb
|
24
24
|
- lib/rematch.rb
|
25
|
-
- lib/rematch/tasks.rb
|
26
25
|
homepage: https://github.com/ddnexus/rematch
|
27
26
|
licenses:
|
28
27
|
- MIT
|
@@ -35,7 +34,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
34
|
requirements:
|
36
35
|
- - ">"
|
37
36
|
- !ruby/object:Gem::Version
|
38
|
-
version: '2.
|
37
|
+
version: '2.1'
|
39
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
39
|
requirements:
|
41
40
|
- - ">="
|
@@ -45,5 +44,6 @@ requirements: []
|
|
45
44
|
rubygems_version: 3.2.15
|
46
45
|
signing_key:
|
47
46
|
specification_version: 4
|
48
|
-
summary:
|
47
|
+
summary: Declutter your test files from large hardcoded data and update them automatically
|
48
|
+
when your code changes
|
49
49
|
test_files: []
|
data/lib/rematch/tasks.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
|
5
|
-
class Rematch
|
6
|
-
module Tasks
|
7
|
-
extend Rake::DSL
|
8
|
-
namespace :rematch do
|
9
|
-
desc 'Delete all the rematch stores below the tree=/path/to/test/dir (or current tree if omitted)'
|
10
|
-
task :reset do
|
11
|
-
pattern = Pathname.new(ENV['tree'] || '').join('**','*.rematch')
|
12
|
-
Dir.glob(pattern).each { |f| File.delete(f) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|