easytest 0.9.0 → 0.10.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: 9a953eabbcc6eb08f30507561d26309fd305983f9f6be7f0c2e2e1a1ce3410b5
4
- data.tar.gz: 86ae0173c242a2069944836dcf48795960f29af50f3bb62c41aae2f079cc86df
3
+ metadata.gz: 8b46bba7f2013706b78807e3ccda09b44711259717bda01d99d3610ee63436cb
4
+ data.tar.gz: 3231effd59cc137da79ce59eeb1db2acb5bccf58d951f69f4f6ab7ee38f58859
5
5
  SHA512:
6
- metadata.gz: aeabfbd63843ff8edb06d2929f65c20c6a748da8f85f2d60b67dc87b7e446776cb76f524ae6ca48aae0601846a9f4da48b1d961f71f32b502697cff9a98e09e5
7
- data.tar.gz: 87f634738fa05e63a1ac0e544965b15b72b6e66b44eccf806102894318f042eb286890cf1c559815c6681f958ec499e06fcbddae2fdee989c76430a7ff6460c2
6
+ metadata.gz: eabd062a3db5062f77ea92a9316d148709af73e3f49d1ed8100eec9229273cc92a37a95fc6ebe671d487e0ecec4f7c38dc34347deb9a0d14c83a263488886115
7
+ data.tar.gz: 285b5df16fdd009212d0890fb3df87c9a8aba76f1019713060aca6e349beacb91591a6ddacafcf4b5d72bf120348c0017537e140938dcc6e6313d9e883db77f3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.10.0
6
+
7
+ - **Breaking:** Change refinement to `extend` in an anonymous module. The usage should change as follows:
8
+ ```diff
9
+ -using Easytest::DSL
10
+ +extend Easytest::DSL
11
+ ```
12
+ - **Breaking:** Drop support for Ruby 2.7 (End-of-Life on March 31, 2023)
13
+ - Remove extra whitespaces from console output.
14
+
5
15
  ## 0.9.0
6
16
 
7
17
  - 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
- using Easytest::DSL
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
- Tests: 1 failed, 0 passed, 1 total (1 files)
58
- Time: 0.00087 seconds
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
- Tests: 1 passed, 1 total (1 files)
75
- Time: 0.00077 seconds
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
- ```console
135
- $ easytest --watch
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 { |test_file| load test_file }
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 do |file|
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
- refine Kernel do
4
- def test(name, &block)
5
- Utils.raise_if_no_test_name(name, method: "test")
6
- Easytest.add_case Case.new(name: name, block: block)
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
- def before(&block)
10
- Easytest.add_hook Hook.new(type: :before, block: block)
11
- end
8
+ def before(&block)
9
+ Easytest.add_hook Hook.new(type: :before, block: block)
10
+ end
12
11
 
13
- def after(&block)
14
- Easytest.add_hook Hook.new(type: :after, block: block)
15
- end
12
+ def after(&block)
13
+ Easytest.add_hook Hook.new(type: :after, block: block)
14
+ end
16
15
 
17
- def skip(name, &block)
18
- Utils.raise_if_no_test_name(name, method: "skip")
19
- Easytest.add_case Case.new(name: name, skipped: true, block: block)
20
- end
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
- def only(name, &block)
23
- Utils.raise_if_no_test_name(name, method: "only")
24
- Easytest.add_case Case.new(name: name, only: true, block: block)
25
- end
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
- def expect(actual = nil, &block)
28
- Expectation.new(actual, &block)
29
- end
26
+ def expect(actual = nil, &block)
27
+ Expectation.new(actual, &block)
30
28
  end
31
29
  end
32
30
  end
@@ -59,8 +59,8 @@ module Easytest
59
59
  false
60
60
  else
61
61
  puts ""
62
- puts " #{Rainbow('Tests:').bright} #{summary}"
63
- puts " #{Rainbow('Time:').bright} #{elapsed_time.round(5)} seconds"
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
@@ -1,3 +1,3 @@
1
1
  module Easytest
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
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.9.0
4
+ version: 0.10.0
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: 2022-10-23 00:00:00.000000000 Z
11
+ date: 2023-09-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: '2.7'
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.3.7
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: []