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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/base.rb +17 -4
- data/lib/sus/context.rb +9 -10
- data/lib/sus/include_context.rb +1 -1
- data/lib/sus/it_behaves_like.rb +1 -1
- data/lib/sus/mock.rb +1 -1
- data/lib/sus/shared.rb +1 -1
- data/lib/sus/version.rb +1 -1
- data/readme.md +20 -27
- data.tar.gz.sig +0 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ef71ae68fa2f1c55825c77c389370bd8903b6888bc1a4034126d945c0d0e0c
|
4
|
+
data.tar.gz: 4abbb662af110be31822445fbb76049a26df539630d68466231dd117bb4ef50b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
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-
|
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
|
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(:
|
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
|
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(:
|
104
|
-
error
|
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
|
-
|
109
|
+
super(error)
|
111
110
|
end
|
112
111
|
|
113
112
|
self.include(wrapper)
|
data/lib/sus/include_context.rb
CHANGED
data/lib/sus/it_behaves_like.rb
CHANGED
data/lib/sus/mock.rb
CHANGED
data/lib/sus/shared.rb
CHANGED
data/lib/sus/version.rb
CHANGED
data/readme.md
CHANGED
@@ -1,40 +1,33 @@
|
|
1
|
-
# Sus
|
1
|
+
# Sus
|
2
2
|
|
3
|
-
|
3
|
+
Sus is a testing framework for Ruby.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
+
[![Development Status](https://github.com/socketry/sus/workflows/Test/badge.svg)](https://github.com/socketry/sus/actions?workflow=Test)
|
11
13
|
|
12
|
-
|
13
|
-
- Backwards compatibility.
|
14
|
+
## Lightning Talk: Testing with Sus (2023)
|
14
15
|
|
15
|
-
|
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
|
-
##
|
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
|
-
|
24
|
+
Please see the [project documentation](https://socketry.github.io/sus/) for more details.
|
30
25
|
|
31
|
-
|
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
|
-
##
|
28
|
+
## See Also
|
36
29
|
|
37
|
-
|
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.
|
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-
|
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/
|
104
|
+
homepage: https://github.com/socketry/sus
|
105
105
|
licenses:
|
106
106
|
- MIT
|
107
107
|
metadata:
|
108
|
-
documentation_uri: https://
|
108
|
+
documentation_uri: https://socketry.github.io/sus/
|
109
109
|
funding_uri: https://github.com/sponsors/ioquatix/
|
110
|
-
source_code_uri: https://github.com/
|
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
|