sus 0.30.0 → 0.31.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: c1b91ed35726c8afcbc97fd2c73ea28d433874f7976958b26beebd9f4ed1dfe4
4
- data.tar.gz: 2295e4817295a52265e94c4eadf708f15b4502ecd40e42b76a44570c3f7c5f2b
3
+ metadata.gz: c3ef71ae68fa2f1c55825c77c389370bd8903b6888bc1a4034126d945c0d0e0c
4
+ data.tar.gz: 4abbb662af110be31822445fbb76049a26df539630d68466231dd117bb4ef50b
5
5
  SHA512:
6
- metadata.gz: 821e42e75cb7628974b6e10b036eb222aa35adfbafb25dc7b773b7b2ba8714c1a292c9ab539763567e1a1010f814aeada965b406eb77969a2f78c6dbf59c82e1
7
- data.tar.gz: 44a648f339a1a947037bdfde3a5e84f875dc9fb5b018133b8e269c572f33ff90dd05c9bfe86f233df60b6ae7357b08ec62523841dddc1cd137327c445d13258e
6
+ metadata.gz: c7ccf1055d49fdb0dcb45b4c3cad14c91f325bc0e897018680354cc1a6ae83c5476f7a240370a98569eabb523603d7b2006e3bd028571e82ef8e0138c337cd13
7
+ data.tar.gz: 49c602c11a456c8eaefcf105e4c135efd18c8c62a3106fc475de03245ce99ace9281d2a246528b0bff96ff153983430748967e4ee7b530e6a91008bbf9044394
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sus/base.rb CHANGED
@@ -16,18 +16,31 @@ module Sus
16
16
  "\#<Sus::Base for #{self.class.description.inspect}>"
17
17
  end
18
18
 
19
+ # A hook which is called before the test is executed.
20
+ #
21
+ # If you override this method, you must call super.
19
22
  def before
20
23
  end
21
24
 
22
- def after
25
+ # A hook which is called after the test is executed.
26
+ #
27
+ # If you override this method, you must call super.
28
+ def after(error = nil)
23
29
  end
24
30
 
25
- def around
31
+ # Wrap logic around the test being executed.
32
+ #
33
+ # Invokes the before hook, then the block, then the after hook.
34
+ #
35
+ # @yields {...} the block which should execute a test.
36
+ def around(&block)
26
37
  self.before
27
38
 
28
- return yield
39
+ return block.call
40
+ rescue => error
41
+ raise
29
42
  ensure
30
- self.after
43
+ self.after(error)
31
44
  end
32
45
 
33
46
  def assert(...)
data/lib/sus/context.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2023, by Samuel Williams.
4
+ # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'assertions'
7
7
  require_relative 'identity'
@@ -78,15 +78,16 @@ module Sus
78
78
 
79
79
  # Include an around method to the context class, that invokes the given block before running the test.
80
80
  #
81
- # Before hooks are called in the reverse order they are defined, in other words the last defined before hook is called first.
81
+ # Before hooks are usually invoked in the order they are defined, i.e. the first defined hook is invoked first.
82
82
  #
83
83
  # @parameter hook [Proc] The block to execute before each test.
84
84
  def before(&hook)
85
85
  wrapper = Module.new
86
86
 
87
- wrapper.define_method(:around) do |&block|
87
+ wrapper.define_method(:before) do
88
+ super()
89
+
88
90
  instance_exec(&hook)
89
- super(&block)
90
91
  end
91
92
 
92
93
  self.include(wrapper)
@@ -94,20 +95,18 @@ module Sus
94
95
 
95
96
  # Include an around method to the context class, that invokes the given block after running the test.
96
97
  #
97
- # After hooks are called in the order they are defined, in other words the last defined after hook is called last.
98
+ # After hooks are usually invoked in the reverse order they are defined, i.e. the last defined hook is invoked first.
98
99
  #
99
100
  # @parameter hook [Proc] The block to execute after each test. An `error` argument is passed if the test failed with an exception.
100
101
  def after(&hook)
101
102
  wrapper = Module.new
102
103
 
103
- wrapper.define_method(:around) do |&block|
104
- error = nil
105
-
106
- super(&block)
104
+ wrapper.define_method(:after) do |error|
105
+ instance_exec(error, &hook)
107
106
  rescue => error
108
107
  raise
109
108
  ensure
110
- instance_exec(error, &hook)
109
+ super(error)
111
110
  end
112
111
 
113
112
  self.include(wrapper)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2023, by Samuel Williams.
4
+ # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2023, by Samuel Williams.
4
+ # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
data/lib/sus/mock.rb CHANGED
@@ -82,7 +82,7 @@ module Sus
82
82
  end
83
83
 
84
84
  module Mocks
85
- def after
85
+ def after(error = nil)
86
86
  super
87
87
 
88
88
  @mocks&.each_value(&:clear)
data/lib/sus/shared.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'context'
7
7
 
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.30.0"
7
+ VERSION = "0.31.0"
8
8
  end
data/readme.md CHANGED
@@ -1,40 +1,33 @@
1
- # Sus(picious)
1
+ # Sus
2
2
 
3
- An opinionated test framework designed with several goals:
3
+ Sus is a testing framework for Ruby.
4
4
 
5
- - As fast as possible, aiming for \~10,000 assertions per second per core.
6
- - Isolated tests which parallelise easily (including `class` definitions).
7
- - Native support for balanced (work-stealing) multi-core execution.
8
- - Incredible test output with detailed failure logging (including nested assertions and predicates).
5
+ - It's similar to RSpec but with less baggage and more parallelism.
6
+ - It uses `expect` style syntax with first-class predicates.
7
+ - It has direct [support for code coverage](https://github.com/socketry/covered).
8
+ - It supports the [VSCode Test Runner interface](https://github.com/socketry/sus-vscode).
9
+ - It's based on my experience writing thousands of tests.
10
+ - It's easy to extend (see the `sus-fixtures-` gems for examples).
9
11
 
10
- Non-features:
12
+ [![Development Status](https://github.com/socketry/sus/workflows/Test/badge.svg)](https://github.com/socketry/sus/actions?workflow=Test)
11
13
 
12
- - Flexibility at the expense of performance.
13
- - Backwards compatibility.
14
+ ## Lightning Talk: Testing with Sus (2023)
14
15
 
15
- [![Development Status](https://github.com/sus-rb/sus/workflows/Test/badge.svg)](https://github.com/sus-rb/sus/actions?workflow=Test)
16
+ <div align="center">
17
+ <a href="https://www.youtube.com/watch?v=BDQHgb2rrwU">
18
+ <img src="https://img.youtube.com/vi/BDQHgb2rrwU/0.jpg" alt="Testing with Sus">
19
+ </a>
20
+ </div>
16
21
 
17
- ## Ideas
18
-
19
- I've been thinking about how this should grow long term. I see a separation between "defining tests" and "running tests". I think this gem should be split across those responsibilities. By doing so, defining tests remains relatively static, but can be extended independently of execution model. And execution models which include parallelism, code coverage, multi-server, etc can be implemented effectively.
20
-
21
- The key point is that we need a well defined interface between defining tests and running tests. This interface is provided by the test registry, which can load test files. The test registry provides a way to enumerate all tests where each test has an identity that uniquely identifies it.
22
-
23
- ### Sequential vs Parallel
24
-
25
- `sus` has both sequential and multi-threaded (`sus-parallel`) execution models for tests. Parallel execution is potentially much faster. This is an experimental feature.
26
-
27
- ![Sequential vs Parallel](https://user-images.githubusercontent.com/30030/144770080-092cf07b-b121-4754-96e0-8ff1d8ea0695.mov)
22
+ ## Usage
28
23
 
29
- ## Installation
24
+ Please see the [project documentation](https://socketry.github.io/sus/) for more details.
30
25
 
31
- ``` shell
32
- bundle add sus
33
- ```
26
+ - [Getting Started](https://socketry.github.io/sus/guides/getting-started/index) - This guide explains how to use the `sus` gem to write tests for your Ruby projects.
34
27
 
35
- ## Usage
28
+ ## See Also
36
29
 
37
- Check `test` directory for examples.
30
+ - [sus-vscode](https://github.com/socketry/sus-vscode) - Visual Studio Code extension for Sus.
38
31
 
39
32
  ## Contributing
40
33
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2024-07-22 00:00:00.000000000 Z
41
+ date: 2024-07-28 00:00:00.000000000 Z
42
42
  dependencies: []
43
43
  description:
44
44
  email:
@@ -101,13 +101,13 @@ files:
101
101
  - lib/sus/with.rb
102
102
  - license.md
103
103
  - readme.md
104
- homepage: https://github.com/sus-rb/sus
104
+ homepage: https://github.com/socketry/sus
105
105
  licenses:
106
106
  - MIT
107
107
  metadata:
108
- documentation_uri: https://sus-rb.github.io/sus/
108
+ documentation_uri: https://socketry.github.io/sus/
109
109
  funding_uri: https://github.com/sponsors/ioquatix/
110
- source_code_uri: https://github.com/sus-rb/sus.git
110
+ source_code_uri: https://github.com/socketry/sus.git
111
111
  post_install_message:
112
112
  rdoc_options: []
113
113
  require_paths:
metadata.gz.sig CHANGED
Binary file