aggregate_assertions 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b46b11cc7ee1614fc3575d4a4950b21b9c0cee9f08581fe08d61565ff7d4907f
4
- data.tar.gz: 64a0b013a23ef08da64e7260f4314ef22a96541dc681b46667f23ea45c216461
3
+ metadata.gz: 77b0cce26f3703f2174328d00eabd81792c97871c6d81fb137932ef73d297754
4
+ data.tar.gz: 63f5abd248efdac2067557ab4389abcd2614f7d1cf2e81ccb65dc3afe4e044d9
5
5
  SHA512:
6
- metadata.gz: 9e866e4d3de4b9d26e9d9a46e479a339eee5f837fbd54998805edf3b3395d795874350f6c316e9bf51102d109bc8f05a1a45b666392a3b41f108403e72637bbb
7
- data.tar.gz: f3afd90ca09b7ff2848f4d81be5493bc1ee367ae0406283646baa0da49aa939746aa4837852a312625cd57339e152412356486dab985ffa516624dd4a4e0f7b6
6
+ metadata.gz: b29c664ed761747edd3e2e8358db4fb4e19955a7f3c4e9c6cf5267b949c349420bd715573bf0e008a118b1ed7420df302558833ff315a1c89f3bccac678d8c62
7
+ data.tar.gz: e463dee9e7da960bc3ca0774be6c030652d9281e3fcf4ece57786d101050fb10f5a1cc7b7157e89ff6c55b5fd07918525c848e750af1946ee7879b7a461ebf4c
@@ -10,7 +10,7 @@ jobs:
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 2.6.8
13
+ ruby-version: 2.7.6
14
14
  bundler-cache: true
15
15
  - name: Tests
16
16
  run: bundle exec rake test
data/.rubocop.yml CHANGED
@@ -1,11 +1,14 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
  SuggestExtensions: false
4
- TargetRubyVersion: 2.6
4
+ TargetRubyVersion: 2.7
5
5
 
6
6
  Metrics/AbcSize:
7
7
  Enabled: false
8
8
 
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+
9
12
  Metrics/MethodLength:
10
13
  Enabled: false
11
14
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2022-10-19
4
+ - Add `AggregateAssertions::EachTest` module to wrap each test with an implicit `aggregate_assertions`.
5
+ - Add `aggregate_assertions/everywhere` require to wrap all tests with an implicit `aggregate_assertions`.
6
+ - Require Ruby 2.7 or later.
7
+
3
8
  ## [0.1.1] - 2021-11-15
4
9
  - Specify `rubygems_mfa_required` in gemspec metadata.
5
10
 
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aggregate_assertions (0.1.1)
4
+ aggregate_assertions (0.2.0)
5
5
  minitest (~> 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- minitest (5.14.4)
11
+ minitest (5.16.3)
12
12
  parallel (1.21.0)
13
13
  parser (3.0.2.0)
14
14
  ast (~> 2.4.1)
@@ -45,4 +45,4 @@ DEPENDENCIES
45
45
  rubocop-minitest
46
46
 
47
47
  BUNDLED WITH
48
- 2.2.31
48
+ 2.3.4
data/README.md CHANGED
@@ -69,6 +69,27 @@ There were 3 errors in group "testing response":
69
69
  Actual: "Not Found"
70
70
  ```
71
71
 
72
+ ### Experimental: Enable for all tests
73
+
74
+ All tests in a class or an entire test suite can be implicitly wrapped
75
+ with `aggregate_assertions`.
76
+
77
+ To enable for all tests in a class include the module `AggregateAssertions::EachTest`:
78
+
79
+ ```ruby
80
+ class MyTest < Minitest::Test
81
+ include AggregateAssertions::EachTest
82
+
83
+ def test_both_errors_reported
84
+ # both assertions are reported without needing an explicit aggregate_assertions block
85
+ assert false, "first error"
86
+ assert false, "second error"
87
+ end
88
+ end
89
+ ```
90
+
91
+ To enable for all tests in a test suite require `aggregate_assertions/everywhere` from your `test_helper.rb` file.
92
+
72
93
  ## Development
73
94
 
74
95
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/tjwp/aggregate_assertions"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
18
  spec.metadata["rubygems_mfa_required"] = "true"
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative("error")
4
- require_relative("failure_group")
3
+ require "minitest"
4
+ require_relative "error"
5
+ require_relative "failure_group"
5
6
 
6
7
  module AggregateAssertions
7
8
  # Main entry-point for the interacting with the state of aggregation.
@@ -23,6 +24,24 @@ module AggregateAssertions
23
24
  store.pop
24
25
  end
25
26
 
27
+ def wrap(label = nil)
28
+ AssertionAggregator.open_failure_group(label)
29
+
30
+ begin
31
+ yield
32
+ rescue Minitest::Assertion, StandardError => e
33
+ AssertionAggregator.add_error(e)
34
+ ensure
35
+ failure_group = AssertionAggregator.close_failure_group
36
+ end
37
+
38
+ return if failure_group.success?
39
+
40
+ raise failure_group.error unless AssertionAggregator.active?
41
+
42
+ AssertionAggregator.add_error(failure_group.error)
43
+ end
44
+
26
45
  private
27
46
 
28
47
  def store
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "aggregate_assertions/assertion_aggregator"
4
+
5
+ module AggregateAssertions
6
+ # Aggregate assertions for all test cases in a Minitest::Test class.
7
+ module EachTest
8
+ def capture_exceptions(&block)
9
+ super do
10
+ AssertionAggregator.wrap(&block)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "aggregate_assertions/each_test"
4
+
5
+ Minitest::Test.prepend(AggregateAssertions::EachTest)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AggregateAssertions
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "minitest"
4
4
  require_relative "aggregate_assertions/version"
5
+ require_relative "aggregate_assertions/each_test"
5
6
  require_relative "aggregate_assertions/assertion_aggregator"
6
7
 
7
8
  module AggregateAssertions
@@ -15,24 +16,10 @@ module AggregateAssertions
15
16
  AssertionAggregator.add_error(e)
16
17
  end
17
18
 
18
- def aggregate_assertions(label = nil)
19
+ def aggregate_assertions(label = nil, &block)
19
20
  flunk "aggregate_assertions requires a block" unless block_given?
20
21
 
21
- AssertionAggregator.open_failure_group(label)
22
-
23
- begin
24
- yield
25
- rescue Minitest::Assertion, StandardError => e
26
- AssertionAggregator.add_error(e)
27
- ensure
28
- failure_group = AssertionAggregator.close_failure_group
29
- end
30
-
31
- return if failure_group.success?
32
-
33
- raise failure_group.error unless AssertionAggregator.active?
34
-
35
- AssertionAggregator.add_error(failure_group.error)
22
+ AssertionAggregator.wrap(label, &block)
36
23
  end
37
24
  end
38
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggregate_assertions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Perkins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -45,7 +45,9 @@ files:
45
45
  - bin/setup
46
46
  - lib/aggregate_assertions.rb
47
47
  - lib/aggregate_assertions/assertion_aggregator.rb
48
+ - lib/aggregate_assertions/each_test.rb
48
49
  - lib/aggregate_assertions/error.rb
50
+ - lib/aggregate_assertions/everywhere.rb
49
51
  - lib/aggregate_assertions/failure_group.rb
50
52
  - lib/aggregate_assertions/version.rb
51
53
  homepage: https://github.com/tjwp/aggregate_assertions
@@ -65,14 +67,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
67
  requirements:
66
68
  - - ">="
67
69
  - !ruby/object:Gem::Version
68
- version: 2.6.0
70
+ version: 2.7.0
69
71
  required_rubygems_version: !ruby/object:Gem::Requirement
70
72
  requirements:
71
73
  - - ">="
72
74
  - !ruby/object:Gem::Version
73
75
  version: '0'
74
76
  requirements: []
75
- rubygems_version: 3.0.3
77
+ rubygems_version: 3.2.20
76
78
  signing_key:
77
79
  specification_version: 4
78
80
  summary: Aggregate Minitest assertions