easytest 0.9.0 → 0.10.1
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/CHANGELOG.md +14 -0
- data/README.md +7 -7
- data/lib/easytest/cli.rb +6 -4
- data/lib/easytest/dsl.rb +20 -22
- data/lib/easytest/runner.rb +2 -2
- data/lib/easytest/version.rb +1 -1
- data/sig/easytest.rbs +18 -21
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e036b68f05b438dfcb392f448b5aab8b0a9ac37ac2b8790d92efff25fa9b7c2
|
4
|
+
data.tar.gz: eb28cb3da178c9391231f19303f075c1d6bd3e30922f5324b44603abf715e1e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8777f94dd6f3133c041e54c12fe716e06f039584b5ab8f12f050e02b3241598e610ec0106cf793875e2cefa9f0e2e8020dc34929fef000099e50b3da7dfe6fb8
|
7
|
+
data.tar.gz: b192eb934a13acd0aa6302bd115582a7126e8b386927aaac501eb65c448cd1e2eed4451b536b0822f7334f57a4cf5e142b3e0ffcbc05165335ba4311d23e7a1c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 0.10.1
|
6
|
+
|
7
|
+
- No actual changes. Just switch to a new simplified release workflow.
|
8
|
+
|
9
|
+
## 0.10.0
|
10
|
+
|
11
|
+
- **Breaking:** Change refinement to `extend` in an anonymous module. The usage should change as follows:
|
12
|
+
```diff
|
13
|
+
-using Easytest::DSL
|
14
|
+
+extend Easytest::DSL
|
15
|
+
```
|
16
|
+
- **Breaking:** Drop support for Ruby 2.7 (End-of-Life on March 31, 2023)
|
17
|
+
- Remove extra whitespaces from console output.
|
18
|
+
|
5
19
|
## 0.9.0
|
6
20
|
|
7
21
|
- Add watch mode (`--watch`).
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ First, put `test/addition_test.rb` as below:
|
|
34
34
|
```ruby
|
35
35
|
require "easytest"
|
36
36
|
|
37
|
-
|
37
|
+
extend Easytest::DSL
|
38
38
|
|
39
39
|
test "addition" do
|
40
40
|
expect(1 + 2).to_eq 2
|
@@ -54,8 +54,8 @@ $ easytest
|
|
54
54
|
# test/addition_test.rb:6:in `block in <top (required)>'
|
55
55
|
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
Tests: 1 failed, 0 passed, 1 total (1 files)
|
58
|
+
Time: 0.00087 seconds
|
59
59
|
```
|
60
60
|
|
61
61
|
Oops. Let's fix the failure:
|
@@ -71,8 +71,8 @@ Then, run it again:
|
|
71
71
|
$ easytest
|
72
72
|
PASS test/addition_test.rb
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
Tests: 1 passed, 1 total (1 files)
|
75
|
+
Time: 0.00077 seconds
|
76
76
|
```
|
77
77
|
|
78
78
|
The test now passes! 🎉
|
@@ -131,8 +131,8 @@ To-do cases will be reported as "todo".
|
|
131
131
|
|
132
132
|
If you want to run tests immediately when changing code, specify the `--watch` option:
|
133
133
|
|
134
|
-
```
|
135
|
-
|
134
|
+
```shell
|
135
|
+
easytest --watch
|
136
136
|
```
|
137
137
|
|
138
138
|
This *watch* mode is useful during development.
|
data/lib/easytest/cli.rb
CHANGED
@@ -112,7 +112,11 @@ module Easytest
|
|
112
112
|
.filter do |file|
|
113
113
|
argv.empty? || argv.any? { |pattern| file.include?(pattern) }
|
114
114
|
end
|
115
|
-
.each {
|
115
|
+
.each { load_test_file(_1) }
|
116
|
+
end
|
117
|
+
|
118
|
+
def load_test_file(file)
|
119
|
+
load(file, true)
|
116
120
|
end
|
117
121
|
|
118
122
|
def test_files
|
@@ -129,9 +133,7 @@ module Easytest
|
|
129
133
|
require "listen"
|
130
134
|
listener = Listen.to(Easytest.test_dir, only: /_test\.rb$/) do |modified, added|
|
131
135
|
Easytest.start(no_tests_forbidden: false)
|
132
|
-
test_files.intersection(modified + added).each
|
133
|
-
load(file)
|
134
|
-
end
|
136
|
+
test_files.intersection(modified + added).each { load_test_file(_1) }
|
135
137
|
Easytest.run
|
136
138
|
end
|
137
139
|
listener.start
|
data/lib/easytest/dsl.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
1
|
module Easytest
|
2
2
|
module DSL
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
def test(name, &block)
|
4
|
+
Utils.raise_if_no_test_name(name, method: "test")
|
5
|
+
Easytest.add_case Case.new(name: name, block: block)
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def before(&block)
|
9
|
+
Easytest.add_hook Hook.new(type: :before, block: block)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def after(&block)
|
13
|
+
Easytest.add_hook Hook.new(type: :after, block: block)
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def skip(name, &block)
|
17
|
+
Utils.raise_if_no_test_name(name, method: "skip")
|
18
|
+
Easytest.add_case Case.new(name: name, skipped: true, block: block)
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def only(name, &block)
|
22
|
+
Utils.raise_if_no_test_name(name, method: "only")
|
23
|
+
Easytest.add_case Case.new(name: name, only: true, block: block)
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
def expect(actual = nil, &block)
|
27
|
+
Expectation.new(actual, &block)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
data/lib/easytest/runner.rb
CHANGED
@@ -59,8 +59,8 @@ module Easytest
|
|
59
59
|
false
|
60
60
|
else
|
61
61
|
puts ""
|
62
|
-
puts "
|
63
|
-
puts "
|
62
|
+
puts "#{Rainbow('Tests:').bright} #{summary}"
|
63
|
+
puts "#{Rainbow('Time:').bright} #{elapsed_time.round(5)} seconds"
|
64
64
|
all_passed?
|
65
65
|
end
|
66
66
|
end
|
data/lib/easytest/version.rb
CHANGED
data/sig/easytest.rbs
CHANGED
@@ -5,6 +5,24 @@ module Easytest
|
|
5
5
|
|
6
6
|
# Define methods for the Easytest DSL.
|
7
7
|
module DSL
|
8
|
+
# Define a test case. If omitting a block, the case is considered a to-do.
|
9
|
+
def test: (String name) ?{ () -> void } -> void
|
10
|
+
|
11
|
+
# Run the given block before each test case.
|
12
|
+
def before: () { (Easytest::Case case) -> void } -> void
|
13
|
+
|
14
|
+
# Run the given block after each test case.
|
15
|
+
def after: () { (Easytest::Case case) -> void } -> void
|
16
|
+
|
17
|
+
# Skip the given test case.
|
18
|
+
def skip: (String name) { () -> void } -> void
|
19
|
+
|
20
|
+
# Run only the given test case.
|
21
|
+
def only: (String name) { () -> void } -> void
|
22
|
+
|
23
|
+
# Expect the given object or block to satisfy some criterion.
|
24
|
+
def expect: (untyped actual) -> Easytest::Expectation
|
25
|
+
| { () -> void } -> Easytest::Expectation
|
8
26
|
end
|
9
27
|
|
10
28
|
# An expectation in test cases.
|
@@ -69,24 +87,3 @@ module Easytest
|
|
69
87
|
attr_reader name: String
|
70
88
|
end
|
71
89
|
end
|
72
|
-
|
73
|
-
module Kernel
|
74
|
-
# TODO: Can we avoid `RBS::DuplicatedMethodDefinitionError` "::Kernel#test has duplicated definitions"?
|
75
|
-
# def test: (String name) ?{ () -> void } -> void
|
76
|
-
|
77
|
-
# Run the given block before each test case.
|
78
|
-
def before: () { (Easytest::Case case) -> void } -> void
|
79
|
-
|
80
|
-
# Run the given block after each test case.
|
81
|
-
def after: () { (Easytest::Case case) -> void } -> void
|
82
|
-
|
83
|
-
# Skip the given test case.
|
84
|
-
def skip: (String name) { () -> void } -> void
|
85
|
-
|
86
|
-
# Run only the given test case.
|
87
|
-
def only: (String name) { () -> void } -> void
|
88
|
-
|
89
|
-
# Expect the given object or block to satisfy some criterion.
|
90
|
-
def expect: (untyped actual) -> Easytest::Expectation
|
91
|
-
| { () -> void } -> Easytest::Expectation
|
92
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easytest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Koba
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -87,7 +87,7 @@ metadata:
|
|
87
87
|
source_code_uri: https://github.com/ybiquitous/easytest
|
88
88
|
changelog_uri: https://github.com/ybiquitous/easytest/blob/main/CHANGELOG.md
|
89
89
|
rubygems_mfa_required: 'true'
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -95,15 +95,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
98
|
+
version: '3.0'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
105
|
+
rubygems_version: 3.4.10
|
106
|
+
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Easy testing for Ruby.
|
109
109
|
test_files: []
|