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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d440fb67a5cd62d5c4b65d12abd2168a7962171348ecdf55b401bc87815d407b
4
- data.tar.gz: 0e0aa4b1f27d85fff9fd79242d28a8e48b23f0e5c76cb982b41aae570fa17b79
3
+ metadata.gz: 3149cc0ce5b301309d45193c6e997b300adb38c6944b2e0c22a0e2634d5e576b
4
+ data.tar.gz: a15958d81aaa6f99f2d2656cb4ee3840e877bd2c0bf8f4ff877ad6514bb1bfca
5
5
  SHA512:
6
- metadata.gz: ffc87f80426c64eacc5a9171f5bec559c04fc2e6ebb9c0530fd22b9d84cca03f4d27a6fc637c0ce030b6256793180d6c2276e4cb566a85ecad895078a119d99f
7
- data.tar.gz: b636027dfe4dbb4bfcff9d9d5ae6c3614fc1fcf1635779e9911a485ceed81211bc21d5175bde1a8e2cdd2bf037f74e961ba630e9effb42b10cc083d1f6f44eaa
6
+ metadata.gz: a4ee8c9f7de0386c4275b997c426bb12be7eff7fbd76b7966fde47e8452e35d529e496e6cfb3ccd02e0ab50a622c60ca3d8d2204ae8de940c26e4e9f57124603
7
+ data.tar.gz: 726bb9c4307f77aba61d23966b339d8a26f20e4b9238dba73546466e942abead18c8e7c7842eb37ab02fb3b9e85c7a2ff6203f830b623c4267790963f65f3a63
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitag (0.5.0)
4
+ minitag (0.6.0)
5
5
  minitest (~> 5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,8 +2,18 @@
2
2
 
3
3
  # Minitag
4
4
 
5
- A simple gem that allow developers to tag their minitest tests and run tests
6
- based on these tags.
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` in our `test_helper.rb`:
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
  # ...
@@ -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
- # Module used to extend classes that rely on tags.
5
- # It has the following responsibilities:
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Minitag
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -14,7 +14,7 @@ module Minitest
14
14
 
15
15
  def self.plugin_minitag_init(options)
16
16
  Array(options[:tags]).each do |tag|
17
- Minitag.context.add_filter(tag)
17
+ Minitag.add_filter(tag)
18
18
  end
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo de Araujo