minitag 0.5.0 → 0.6.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/Gemfile.lock +1 -1
- data/README.md +19 -5
- data/lib/minitag/minitest_tag.rb +17 -2
- data/lib/minitag/tag_extension.rb +2 -13
- data/lib/minitag/version.rb +1 -1
- data/lib/minitest/minitag_plugin.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3149cc0ce5b301309d45193c6e997b300adb38c6944b2e0c22a0e2634d5e576b
|
|
4
|
+
data.tar.gz: a15958d81aaa6f99f2d2656cb4ee3840e877bd2c0bf8f4ff877ad6514bb1bfca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4ee8c9f7de0386c4275b997c426bb12be7eff7fbd76b7966fde47e8452e35d529e496e6cfb3ccd02e0ab50a622c60ca3d8d2204ae8de940c26e4e9f57124603
|
|
7
|
+
data.tar.gz: 726bb9c4307f77aba61d23966b339d8a26f20e4b9238dba73546466e942abead18c8e7c7842eb37ab02fb3b9e85c7a2ff6203f830b623c4267790963f65f3a63
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
# Minitag
|
|
4
4
|
|
|
5
|
-
A simple gem that allow developers to
|
|
6
|
-
|
|
5
|
+
A simple gem that allow developers using minitest to specify tags for their classes and tests, and run their test suite based on these tags.
|
|
6
|
+
|
|
7
|
+
This gem should be framework agnostic, let me know if you encounter any problems
|
|
8
|
+
running this within the framework of your choice.
|
|
9
|
+
|
|
10
|
+
## When should I use this?
|
|
11
|
+
|
|
12
|
+
- When there's a need to split a test suite into different CI steps.
|
|
13
|
+
- During development, it's helpful to have extra flexibility when running a big
|
|
14
|
+
test suite.
|
|
15
|
+
- When there are tests that you want to run only occasionality. For example,
|
|
16
|
+
tests that perform network calls or have expensive side effects.
|
|
7
17
|
|
|
8
18
|
## Installation
|
|
9
19
|
|
|
@@ -23,18 +33,22 @@ $ gem install minitag
|
|
|
23
33
|
|
|
24
34
|
### Setup
|
|
25
35
|
|
|
26
|
-
Require `minitag`
|
|
36
|
+
Require `minitag` within `test_helper.rb`:
|
|
27
37
|
|
|
28
38
|
`require 'minitag'`
|
|
29
39
|
|
|
30
40
|
### Adding tags
|
|
31
41
|
|
|
32
|
-
We can tag specific tests with one or more tags.
|
|
42
|
+
We can tag specific classes or tests with one or more tags.
|
|
33
43
|
|
|
34
|
-
It is important to point out that tags associated with a test have no concept of being inclusive or exclusive. This distinction is only valid for [tag filters](#running-tests-with-tag-filters).
|
|
44
|
+
It is important to point out that tags associated with a class or test have no concept of being inclusive or exclusive. This distinction is only valid for [tag filters](#running-tests-with-tag-filters).
|
|
35
45
|
|
|
36
46
|
```rb
|
|
37
47
|
class MyTest < Minitest::Test
|
|
48
|
+
# Every test within this class will inherit this tag
|
|
49
|
+
tag_namespace 'my_namespace_tag'
|
|
50
|
+
|
|
51
|
+
# Only the test below will have this tag
|
|
38
52
|
tag 'my_tag', 'another_tag'
|
|
39
53
|
def test_hello_minitest
|
|
40
54
|
# ...
|
data/lib/minitag/minitest_tag.rb
CHANGED
|
@@ -19,8 +19,6 @@ module Minitag
|
|
|
19
19
|
namespace: to_s,
|
|
20
20
|
tags: tags.map { |tag| tag.to_s.strip.downcase }
|
|
21
21
|
)
|
|
22
|
-
|
|
23
|
-
Minitag.register_for_extension(self)
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
# Add tags to be associated with the next test definition and extends the
|
|
@@ -37,6 +35,23 @@ module Minitag
|
|
|
37
35
|
Minitag.pending_tags = tags.map { |tag| tag.to_s.strip.downcase }
|
|
38
36
|
Minitag.register_for_extension(self)
|
|
39
37
|
end
|
|
38
|
+
|
|
39
|
+
# Decides which methods to run based on an Array of test names provided by
|
|
40
|
+
# the superclass and the tags defined within test classes.
|
|
41
|
+
#
|
|
42
|
+
# Invariants:
|
|
43
|
+
# - Returns the full list of test names when the test suite runs without
|
|
44
|
+
# any tag filtering.
|
|
45
|
+
#
|
|
46
|
+
# @return [Array] the list of test names that should run.
|
|
47
|
+
def runnable_methods
|
|
48
|
+
methods = super.dup
|
|
49
|
+
return methods if Minitag.context.no_filters?
|
|
50
|
+
|
|
51
|
+
methods.select do |runnable_method|
|
|
52
|
+
Minitag.context.match?(namespace: to_s, name: runnable_method)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
40
55
|
end
|
|
41
56
|
end
|
|
42
57
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Minitag
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# - Associate tags with tests
|
|
7
|
-
# - Filter tests based on the specified tags
|
|
4
|
+
# Responsible for listening to added methods and associating tags
|
|
5
|
+
# with those.
|
|
8
6
|
module TagExtension
|
|
9
7
|
define_method(:method_added) do |name|
|
|
10
8
|
if name[/\Atest_/]
|
|
@@ -15,14 +13,5 @@ module Minitag
|
|
|
15
13
|
Minitag.pending_tags = []
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
|
-
|
|
19
|
-
def runnable_methods
|
|
20
|
-
methods = super.dup
|
|
21
|
-
return methods if Minitag.context.no_filters?
|
|
22
|
-
|
|
23
|
-
methods.select do |runnable_method|
|
|
24
|
-
Minitag.context.match?(namespace: to_s, name: runnable_method)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
16
|
end
|
|
28
17
|
end
|
data/lib/minitag/version.rb
CHANGED