smartest 0.6.2.alpha1 → 0.6.2.alpha2
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/README.md +4 -1
- data/lib/smartest/dsl.rb +71 -0
- data/lib/smartest/version.rb +1 -1
- data/sig/smartest.rbs +1 -13
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0718af27aa3da16e50c8172fab0145ec41de84435c1f662af9f404ad81d2ed1
|
|
4
|
+
data.tar.gz: 861107ab2de4d07fa3b47c5a09ab39648b253567f17557ddb036c1bca1df7fc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b8e1a64faff9721e48a787841bff898c3b2a52fccc70808b4f298b22ecfe2473ae0d43a066c19267cecd8e640e8266ae81aa79a1097e72f070ab0aec2b0bde3
|
|
7
|
+
data.tar.gz: 3d3330b9b3087ae3c8d32775a4bfd0b082f1f0f42954bac03a00ab44b54930d999a4b787fcd768ce507dcea708d6f42878cee805165bb7026f28b19ed18dcba6
|
data/README.md
CHANGED
|
@@ -333,7 +333,10 @@ This makes fixture usage explicit and avoids relying on positional argument orde
|
|
|
333
333
|
|
|
334
334
|
Smartest also ships RBS signatures for the public DSL, including `test`,
|
|
335
335
|
`around_suite`, `around_test`, `fixture`, `suite_fixture`, `on_teardown`,
|
|
336
|
-
`expect`, and hook registration methods such as `use_fixture`.
|
|
336
|
+
`expect`, and hook registration methods such as `use_fixture`. The signatures
|
|
337
|
+
model `Smartest::DSL` as prepended into `Kernel`, matching how
|
|
338
|
+
`smartest/autorun` installs the top-level DSL over Ruby's built-in
|
|
339
|
+
`Kernel#test` file-test helper.
|
|
337
340
|
|
|
338
341
|
## Skipping and pending tests
|
|
339
342
|
|
data/lib/smartest/dsl.rb
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Smartest
|
|
4
|
+
# Top-level Smartest test definition DSL.
|
|
5
|
+
#
|
|
6
|
+
# Smartest installs this module into Kernel when `smartest/autorun` is
|
|
7
|
+
# required. The module intentionally overrides Ruby's built-in `Kernel#test`
|
|
8
|
+
# file-test helper while Smartest tests are being loaded.
|
|
4
9
|
module DSL
|
|
10
|
+
# Define a named Smartest test.
|
|
11
|
+
#
|
|
12
|
+
# Test fixtures are requested with required keyword block parameters:
|
|
13
|
+
#
|
|
14
|
+
# test("opens the home page") do |page:|
|
|
15
|
+
# page.goto("/")
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# @param name [String, Symbol] human-readable test name
|
|
19
|
+
# @param metadata [Hash] optional metadata kept with the test case
|
|
20
|
+
# @yield test body; required keyword parameters request fixtures
|
|
21
|
+
# @return [void]
|
|
5
22
|
def test(name, **metadata, &block)
|
|
6
23
|
location = caller_locations(1, 1).first
|
|
7
24
|
|
|
@@ -16,12 +33,27 @@ module Smartest
|
|
|
16
33
|
)
|
|
17
34
|
end
|
|
18
35
|
|
|
36
|
+
# Register a hook that wraps the whole suite.
|
|
37
|
+
#
|
|
38
|
+
# The block receives a `Smartest::SuiteRun` object and must call
|
|
39
|
+
# `suite.run` exactly once.
|
|
40
|
+
#
|
|
41
|
+
# @yieldparam suite [Smartest::SuiteRun] suite run target
|
|
42
|
+
# @return [void]
|
|
19
43
|
def around_suite(&block)
|
|
20
44
|
raise ArgumentError, "around_suite block is required" unless block
|
|
21
45
|
|
|
22
46
|
Smartest.suite.around_suite_hooks << block
|
|
23
47
|
end
|
|
24
48
|
|
|
49
|
+
# Register a hook that wraps tests declared after this hook in the same file.
|
|
50
|
+
#
|
|
51
|
+
# The block receives a `Smartest::TestRun` object and must call `test.run`
|
|
52
|
+
# exactly once. The hook wraps fixture setup, the test body, and fixture
|
|
53
|
+
# teardown.
|
|
54
|
+
#
|
|
55
|
+
# @yieldparam test [Smartest::TestRun] test run target
|
|
56
|
+
# @return [void]
|
|
25
57
|
def around_test(&block)
|
|
26
58
|
raise ArgumentError, "around_test block is required" unless block
|
|
27
59
|
|
|
@@ -31,3 +63,42 @@ module Smartest
|
|
|
31
63
|
private :test, :around_suite, :around_test
|
|
32
64
|
end
|
|
33
65
|
end
|
|
66
|
+
|
|
67
|
+
module Kernel
|
|
68
|
+
# @!method test(name, **metadata, &block)
|
|
69
|
+
# Define a named Smartest test.
|
|
70
|
+
#
|
|
71
|
+
# Fixture values are requested with required keyword block parameters:
|
|
72
|
+
#
|
|
73
|
+
# test("opens the home page") do |page:|
|
|
74
|
+
# page.goto("/")
|
|
75
|
+
# end
|
|
76
|
+
#
|
|
77
|
+
# Smartest installs this method by prepending `Smartest::DSL` into Kernel,
|
|
78
|
+
# so it overrides Ruby's built-in `Kernel#test` file-test helper while
|
|
79
|
+
# Smartest tests are being loaded.
|
|
80
|
+
#
|
|
81
|
+
# @param name [String, Symbol] human-readable test name
|
|
82
|
+
# @param metadata [Hash] optional metadata kept with the test case
|
|
83
|
+
# @yield test body; required keyword parameters request fixtures
|
|
84
|
+
# @return [void]
|
|
85
|
+
#
|
|
86
|
+
# @!method around_suite(&block)
|
|
87
|
+
# Register a hook that wraps the whole suite.
|
|
88
|
+
#
|
|
89
|
+
# The block receives a `Smartest::SuiteRun` object and must call
|
|
90
|
+
# `suite.run` exactly once.
|
|
91
|
+
#
|
|
92
|
+
# @yieldparam suite [Smartest::SuiteRun] suite run target
|
|
93
|
+
# @return [void]
|
|
94
|
+
#
|
|
95
|
+
# @!method around_test(&block)
|
|
96
|
+
# Register a hook that wraps tests declared after this hook in the same file.
|
|
97
|
+
#
|
|
98
|
+
# The block receives a `Smartest::TestRun` object and must call `test.run`
|
|
99
|
+
# exactly once. The hook wraps fixture setup, the test body, and fixture
|
|
100
|
+
# teardown.
|
|
101
|
+
#
|
|
102
|
+
# @yieldparam test [Smartest::TestRun] test run target
|
|
103
|
+
# @return [void]
|
|
104
|
+
end
|
data/lib/smartest/version.rb
CHANGED
data/sig/smartest.rbs
CHANGED
|
@@ -147,17 +147,5 @@ module Smartest
|
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
module Kernel
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# Define a named Smartest test. Fixture values are requested with keyword
|
|
153
|
-
# block parameters, for example `test("opens page") do |page:|`.
|
|
154
|
-
def test: (String | Symbol, **untyped) { (*untyped, **untyped) -> untyped } -> void
|
|
155
|
-
|
|
156
|
-
# Register a suite hook. The block receives a run target and must call
|
|
157
|
-
# `suite.run` exactly once.
|
|
158
|
-
def around_suite: () { (Smartest::SuiteRun) -> untyped } -> void
|
|
159
|
-
|
|
160
|
-
# Register a test hook for tests declared after this hook in the same file.
|
|
161
|
-
# The block receives a run target and must call `test.run` exactly once.
|
|
162
|
-
def around_test: () { (Smartest::TestRun) -> untyped } -> void
|
|
150
|
+
prepend Smartest::DSL
|
|
163
151
|
end
|