minitag 0.4.1 → 0.5.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 +4 -4
- data/.github/workflows/ci.yml +5 -1
- data/.rubocop.yml +2 -7
- data/Gemfile.lock +1 -1
- data/lib/minitag/context.rb +16 -3
- data/lib/minitag/minitest_tag.rb +20 -0
- data/lib/minitag/tag_extension.rb +3 -3
- data/lib/minitag/tag_registry.rb +21 -6
- data/lib/minitag/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d440fb67a5cd62d5c4b65d12abd2168a7962171348ecdf55b401bc87815d407b
|
|
4
|
+
data.tar.gz: 0e0aa4b1f27d85fff9fd79242d28a8e48b23f0e5c76cb982b41aae570fa17b79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffc87f80426c64eacc5a9171f5bec559c04fc2e6ebb9c0530fd22b9d84cca03f4d27a6fc637c0ce030b6256793180d6c2276e4cb566a85ecad895078a119d99f
|
|
7
|
+
data.tar.gz: b636027dfe4dbb4bfcff9d9d5ae6c3614fc1fcf1635779e9911a485ceed81211bc21d5175bde1a8e2cdd2bf037f74e961ba630e9effb42b10cc083d1f6f44eaa
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/minitag/context.rb
CHANGED
|
@@ -18,12 +18,25 @@ module Minitag
|
|
|
18
18
|
# @param [Array] tags the collection of tags.
|
|
19
19
|
#
|
|
20
20
|
# @return [void]
|
|
21
|
-
def
|
|
21
|
+
def add_test_tags(namespace:, name:, tags:)
|
|
22
22
|
@tag_registry.add(namespace: namespace, name: name, tags: tags)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# Add tags to an entire namespace. Every test within the namespace will
|
|
26
|
+
# share these tags.
|
|
27
|
+
#
|
|
28
|
+
# @param [String] namespace the namespace that contain tests.
|
|
29
|
+
# @param [Array] tags the collection of tags.
|
|
30
|
+
#
|
|
31
|
+
# @return [void]
|
|
32
|
+
def add_namespace_tags(namespace:, tags:)
|
|
33
|
+
@tag_registry.add_for_namespace(namespace: namespace, tags: tags)
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
# Adds a filter tag.
|
|
26
|
-
#
|
|
37
|
+
#
|
|
38
|
+
# Tags with a ~ prefix are treated as exclusive filters or inclusive filters
|
|
39
|
+
# otherwise.
|
|
27
40
|
#
|
|
28
41
|
# param [String] name the name of the filter tag.
|
|
29
42
|
#
|
|
@@ -61,7 +74,7 @@ module Minitag
|
|
|
61
74
|
def match?(namespace:, name:)
|
|
62
75
|
return true if no_filters?
|
|
63
76
|
|
|
64
|
-
tags = @tag_registry.
|
|
77
|
+
tags = @tag_registry.get(namespace: namespace, name: name)
|
|
65
78
|
match_inclusive_filters?(tags) && match_exclusive_filters?(tags)
|
|
66
79
|
end
|
|
67
80
|
|
data/lib/minitag/minitest_tag.rb
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
module Minitag
|
|
4
4
|
# Module used to extend Minitest::Test with the tag method.
|
|
5
5
|
module MinitestTag
|
|
6
|
+
# Add tags to be associated with an entire class that inherits from
|
|
7
|
+
# Minitest::Test. Every test that belongs to this class will also inherit
|
|
8
|
+
# these tags.
|
|
9
|
+
#
|
|
10
|
+
# It is important to notice that tags associated with a class have no
|
|
11
|
+
# concept of being inclusive or exclusive. This distinction is only
|
|
12
|
+
# valid for tag filters.
|
|
13
|
+
#
|
|
14
|
+
# @param [Array] tags the list of tags to be associated with a test class.
|
|
15
|
+
#
|
|
16
|
+
# @return [void]
|
|
17
|
+
def tag_namespace(*tags)
|
|
18
|
+
Minitag.context.add_namespace_tags(
|
|
19
|
+
namespace: to_s,
|
|
20
|
+
tags: tags.map { |tag| tag.to_s.strip.downcase }
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
Minitag.register_for_extension(self)
|
|
24
|
+
end
|
|
25
|
+
|
|
6
26
|
# Add tags to be associated with the next test definition and extends the
|
|
7
27
|
# class from which the tag method is being used with Minitag::TagExtension.
|
|
8
28
|
#
|
|
@@ -8,8 +8,8 @@ module Minitag
|
|
|
8
8
|
module TagExtension
|
|
9
9
|
define_method(:method_added) do |name|
|
|
10
10
|
if name[/\Atest_/]
|
|
11
|
-
Minitag.context.
|
|
12
|
-
namespace:
|
|
11
|
+
Minitag.context.add_test_tags(
|
|
12
|
+
namespace: to_s, name: name, tags: Minitag.pending_tags
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
Minitag.pending_tags = []
|
|
@@ -21,7 +21,7 @@ module Minitag
|
|
|
21
21
|
return methods if Minitag.context.no_filters?
|
|
22
22
|
|
|
23
23
|
methods.select do |runnable_method|
|
|
24
|
-
Minitag.context.match?(namespace:
|
|
24
|
+
Minitag.context.match?(namespace: to_s, name: runnable_method)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
data/lib/minitag/tag_registry.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Minitag
|
|
4
|
-
# Stores tags associated with a
|
|
5
|
-
#
|
|
4
|
+
# Stores tags associated with a namespace or a single test case.
|
|
5
|
+
#
|
|
6
|
+
# A namespace is usually the class which tests belongs to.
|
|
6
7
|
class TagRegistry
|
|
7
8
|
def initialize
|
|
8
|
-
@
|
|
9
|
+
@registry = {}
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
# Associates tags with a name taking into account its namespace.
|
|
@@ -18,7 +19,19 @@ module Minitag
|
|
|
18
19
|
#
|
|
19
20
|
# @return [void]
|
|
20
21
|
def add(namespace:, name:, tags:)
|
|
21
|
-
@
|
|
22
|
+
@registry[key(namespace, name)] = Set.new(tags)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Associates tags with a namespace.
|
|
26
|
+
#
|
|
27
|
+
# Duplicated tags will be removed during this operation.
|
|
28
|
+
#
|
|
29
|
+
# @param [String] namespace the context which a test name belongs.
|
|
30
|
+
# @param [Array] tags the collection of tags associated with a test.
|
|
31
|
+
#
|
|
32
|
+
# @return [void]
|
|
33
|
+
def add_for_namespace(namespace:, tags:)
|
|
34
|
+
@registry[namespace] = Set.new(tags)
|
|
22
35
|
end
|
|
23
36
|
|
|
24
37
|
# Fetches tags associated with a test name and namespace.
|
|
@@ -27,8 +40,10 @@ module Minitag
|
|
|
27
40
|
# @param [String] name the test name.
|
|
28
41
|
#
|
|
29
42
|
# @return [Set] the tags associated with the specified namespace and test name.
|
|
30
|
-
def
|
|
31
|
-
@
|
|
43
|
+
def get(namespace:, name:)
|
|
44
|
+
@registry.fetch(namespace, Set.new).union(
|
|
45
|
+
@registry.fetch(key(namespace, name), Set.new)
|
|
46
|
+
)
|
|
32
47
|
end
|
|
33
48
|
|
|
34
49
|
private
|
data/lib/minitag/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minitag
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bernardo de Araujo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-07-
|
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|