nukadoko 0.4.0 → 0.6.0
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 +78 -0
- data/README.ja.md +12 -2
- data/README.md +10 -3
- data/lib/nukadoko/check.rb +15 -4
- data/lib/nukadoko/cli.rb +10 -4
- data/lib/nukadoko/command.rb +22 -4
- data/lib/nukadoko/error_frames.rb +44 -0
- data/lib/nukadoko/features.rb +3 -1
- data/lib/nukadoko/fixtures.rb +108 -7
- data/lib/nukadoko/judgment_file.rb +21 -0
- data/lib/nukadoko/judgments.rb +30 -0
- data/lib/nukadoko/run.rb +126 -27
- data/lib/nukadoko/run_record.rb +9 -5
- data/lib/nukadoko/schema.rb +165 -37
- data/lib/nukadoko/step_fixtures.rb +225 -0
- data/lib/nukadoko/summary.rb +4 -1
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +1 -1
- data/lib/nukadoko.rb +2 -0
- data/llms.txt +3 -2
- data/sig/generated/nukadoko/command.rbs +13 -4
- data/sig/generated/nukadoko/error_frames.rbs +24 -0
- data/sig/generated/nukadoko/fixtures.rbs +38 -2
- data/sig/generated/nukadoko/judgment_file.rbs +6 -0
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/run.rbs +25 -4
- data/sig/generated/nukadoko/schema.rbs +91 -27
- data/sig/generated/nukadoko/step_fixtures.rbs +129 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/skills/nukadoko/SKILL.md +1 -1
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/judgments.md +6 -0
- data/skills/nukadoko/references/ruby.md +80 -0
- metadata +6 -1
|
@@ -4,8 +4,19 @@
|
|
|
4
4
|
# a value must pass at run time, the RBS a Steep user checks the step body
|
|
5
5
|
# against, and the Data class the body receives. A type is a symbol for a
|
|
6
6
|
# scalar, `[:array, type]` for a list, or a nested Schema for an object.
|
|
7
|
+
# `[:checked, type, checks]` is an array item with bounds of its own.
|
|
8
|
+
#
|
|
9
|
+
# Each field method takes the options zod spells as methods: `null: true`
|
|
10
|
+
# (`.nullable()`), `optional: true` (`.optional()`: the key may be absent,
|
|
11
|
+
# and the body reads nil), `default:` (`.default(x)`: an absent key reads
|
|
12
|
+
# as the value), and bounds: `min:` and `max:` (a number's value, a
|
|
13
|
+
# string's length, an array's item count), `positive: true` (> 0) and
|
|
14
|
+
# `negative: true` (< 0).
|
|
7
15
|
module Nukadoko
|
|
8
16
|
class Schema
|
|
17
|
+
# The value of `default` when the field declares none.
|
|
18
|
+
NONE: untyped
|
|
19
|
+
|
|
9
20
|
class Field < Data
|
|
10
21
|
attr_reader name(): Symbol
|
|
11
22
|
|
|
@@ -13,14 +24,31 @@ module Nukadoko
|
|
|
13
24
|
|
|
14
25
|
attr_reader description(): String?
|
|
15
26
|
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
attr_reader optional(): bool
|
|
28
|
+
|
|
29
|
+
attr_reader default(): untyped
|
|
30
|
+
|
|
31
|
+
attr_reader checks(): Hash[Symbol, untyped]
|
|
18
32
|
|
|
19
|
-
def self.
|
|
33
|
+
def self.new: (Symbol name, untyped type, String? description, bool optional, untyped default, Hash[Symbol, untyped] checks) -> instance
|
|
34
|
+
| (name: Symbol, type: untyped, description: String?, optional: bool, default: untyped, checks: Hash[Symbol, untyped]) -> instance
|
|
20
35
|
|
|
21
|
-
def members: () -> [ :name, :type, :description ]
|
|
36
|
+
def self.members: () -> [ :name, :type, :description, :optional, :default, :checks ]
|
|
37
|
+
|
|
38
|
+
def members: () -> [ :name, :type, :description, :optional, :default, :checks ]
|
|
22
39
|
end
|
|
23
40
|
|
|
41
|
+
class Field
|
|
42
|
+
# An absent key passes: the field is optional or has a default.
|
|
43
|
+
# : () -> bool
|
|
44
|
+
def absent_ok?: () -> bool
|
|
45
|
+
|
|
46
|
+
# : () -> bool
|
|
47
|
+
def default?: () -> bool
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
CHECKS: untyped
|
|
51
|
+
|
|
24
52
|
# : () ?{ () [self: Schema] -> void } -> Schema
|
|
25
53
|
def self.build: () ?{ () [self: Schema] -> void } -> Schema
|
|
26
54
|
|
|
@@ -29,33 +57,45 @@ module Nukadoko
|
|
|
29
57
|
# : (?Array[Field]) -> void
|
|
30
58
|
def initialize: (?Array[Field]) -> void
|
|
31
59
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
60
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
61
|
+
def string: (Symbol, ?String?, **untyped) -> void
|
|
62
|
+
|
|
63
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
64
|
+
def boolean: (Symbol, ?String?, **untyped) -> void
|
|
35
65
|
|
|
36
|
-
# : (Symbol, ?String?,
|
|
37
|
-
def
|
|
66
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
67
|
+
def integer: (Symbol, ?String?, **untyped) -> void
|
|
38
68
|
|
|
39
|
-
# : (Symbol, ?String?,
|
|
40
|
-
def
|
|
69
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
70
|
+
def number: (Symbol, ?String?, **untyped) -> void
|
|
41
71
|
|
|
42
|
-
# : (Symbol, ?String?,
|
|
43
|
-
def
|
|
72
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
73
|
+
def unknown: (Symbol, ?String?, **untyped) -> void
|
|
44
74
|
|
|
45
|
-
# : (Symbol, ?String
|
|
46
|
-
def
|
|
75
|
+
# : (Symbol, Array[String | Symbol], ?String?, **untyped) -> void
|
|
76
|
+
def enum: (Symbol, Array[String | Symbol], ?String?, **untyped) -> void
|
|
47
77
|
|
|
48
|
-
# : (Symbol,
|
|
49
|
-
def
|
|
78
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
79
|
+
def strings: (Symbol, ?String?, **untyped) -> void
|
|
50
80
|
|
|
51
|
-
# : (Symbol, ?String?,
|
|
52
|
-
def
|
|
81
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
82
|
+
def numbers: (Symbol, ?String?, **untyped) -> void
|
|
53
83
|
|
|
54
|
-
# : (Symbol, ?String?,
|
|
55
|
-
def
|
|
84
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
85
|
+
def integers: (Symbol, ?String?, **untyped) -> void
|
|
56
86
|
|
|
57
|
-
# : (Symbol, ?String?,
|
|
58
|
-
def
|
|
87
|
+
# : (Symbol, ?String?, **untyped) -> void
|
|
88
|
+
def table: (Symbol, ?String?, **untyped) -> void
|
|
89
|
+
|
|
90
|
+
# : (Symbol, ?String?, **untyped) { () [self: Schema] -> void } -> void
|
|
91
|
+
def object: (Symbol, ?String?, **untyped) { () [self: Schema] -> void } -> void
|
|
92
|
+
|
|
93
|
+
# A list: of objects the block declares (`array :todos do string :id end`),
|
|
94
|
+
# or of `of:` (:string, :number, :integer, :boolean, or a Schema).
|
|
95
|
+
# `each:` holds bounds every item meets (`each: { positive: true }`);
|
|
96
|
+
# `min:` and `max:` bound the item count.
|
|
97
|
+
# : (Symbol, ?String?, ?of: untyped, ?each: Hash[Symbol, untyped], **untyped) ?{ () [self: Schema] -> void } -> void
|
|
98
|
+
def array: (Symbol, ?String?, ?of: untyped, ?each: Hash[Symbol, untyped], **untyped) ?{ () [self: Schema] -> void } -> void
|
|
59
99
|
|
|
60
100
|
# Reuses a field another step declared, so two contracts that must agree
|
|
61
101
|
# on one shape are written once: `field :created, AnItemExists.returns[:body]`.
|
|
@@ -65,6 +105,10 @@ module Nukadoko
|
|
|
65
105
|
# : (Symbol | String) -> Field?
|
|
66
106
|
def []: (Symbol | String) -> Field?
|
|
67
107
|
|
|
108
|
+
# The keys a value must hold: neither optional nor defaulted.
|
|
109
|
+
# : () -> Array[String]
|
|
110
|
+
def required_names: () -> Array[String]
|
|
111
|
+
|
|
68
112
|
# : (Array[String]) -> Schema
|
|
69
113
|
def without: (Array[String]) -> Schema
|
|
70
114
|
|
|
@@ -122,6 +166,15 @@ module Nukadoko
|
|
|
122
166
|
# : (untyped, untyped, String) -> Array[String]
|
|
123
167
|
def self.type_problems: (untyped, untyped, String) -> Array[String]
|
|
124
168
|
|
|
169
|
+
# A bound zod reports in its own words, once the type passed: a number's
|
|
170
|
+
# value, a string's length in UTF-16 units, an array's item count.
|
|
171
|
+
# : (Hash[Symbol, untyped], untyped, String) -> Array[String]
|
|
172
|
+
def self.check_problems: (Hash[Symbol, untyped], untyped, String) -> Array[String]
|
|
173
|
+
|
|
174
|
+
# A number as JavaScript prints it: 2.0 is 2.
|
|
175
|
+
# : (Numeric) -> String
|
|
176
|
+
def self.js: (Numeric) -> String
|
|
177
|
+
|
|
125
178
|
# zod's int: a finite whole number within Number.MAX_SAFE_INTEGER.
|
|
126
179
|
# : (untyped) -> String?
|
|
127
180
|
def self.integer_problem: (untyped) -> String?
|
|
@@ -132,8 +185,15 @@ module Nukadoko
|
|
|
132
185
|
# : (?root: bool, ?output: bool) -> Hash[Symbol, untyped]
|
|
133
186
|
def json_schema: (?root: bool, ?output: bool) -> Hash[Symbol, untyped]
|
|
134
187
|
|
|
135
|
-
#
|
|
136
|
-
|
|
188
|
+
# As z.toJSONSchema writes it, bounds included and in its key order.
|
|
189
|
+
# : (untyped, ?bool, ?Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
190
|
+
def self.json_type: (untyped, ?bool, ?Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
191
|
+
|
|
192
|
+
# : (Hash[Symbol, untyped], Integer?, Integer?) -> Hash[Symbol, untyped]
|
|
193
|
+
def self.number_bounds: (Hash[Symbol, untyped], Integer?, Integer?) -> Hash[Symbol, untyped]
|
|
194
|
+
|
|
195
|
+
# : (Hash[Symbol, untyped], Symbol, Symbol) -> Hash[Symbol, untyped]
|
|
196
|
+
def self.length_bounds: (Hash[Symbol, untyped], Symbol, Symbol) -> Hash[Symbol, untyped]
|
|
137
197
|
|
|
138
198
|
# : () -> Array[String]
|
|
139
199
|
def rbs_fields: () -> Array[String]
|
|
@@ -141,13 +201,17 @@ module Nukadoko
|
|
|
141
201
|
# : () -> String
|
|
142
202
|
def rbs_record: () -> String
|
|
143
203
|
|
|
204
|
+
# An optional key reads as nil when it is absent.
|
|
205
|
+
# : (Field) -> String
|
|
206
|
+
def self.rbs_field: (Field) -> String
|
|
207
|
+
|
|
144
208
|
# : (untyped) -> String
|
|
145
209
|
def self.rbs_type: (untyped) -> String
|
|
146
210
|
|
|
147
211
|
private
|
|
148
212
|
|
|
149
|
-
# : (Symbol, untyped, String?, ?bool) -> void
|
|
150
|
-
def add: (Symbol, untyped, String?, ?bool) -> void
|
|
213
|
+
# : (Symbol, untyped, String?, ?null: bool, ?optional: bool, ?default: untyped, **untyped) -> void
|
|
214
|
+
def add: (Symbol, untyped, String?, ?null: bool, ?optional: bool, ?default: untyped, **untyped) -> void
|
|
151
215
|
|
|
152
216
|
# : (String?, Symbol | String) -> String
|
|
153
217
|
def join: (String?, Symbol | String) -> String
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Generated from lib/nukadoko/step_fixtures.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# The fixtures a step body uses to say where it went, to wait for a state
|
|
4
|
+
# that is not there yet, and to keep evidence only it can produce. The
|
|
5
|
+
# TypeScript engine gives the same three on ctx. Each one fills a list the
|
|
6
|
+
# engine writes into the step record, also when the step raises, because a
|
|
7
|
+
# failed step is the one whose record a reader opens.
|
|
8
|
+
module Nukadoko
|
|
9
|
+
# poll gave up: the budget ended before the block returned a value.
|
|
10
|
+
class PollTimeoutError < StandardError
|
|
11
|
+
attr_reader timeout_ms: Numeric
|
|
12
|
+
|
|
13
|
+
attr_reader description: String?
|
|
14
|
+
|
|
15
|
+
# : (Numeric, String?) -> void
|
|
16
|
+
def initialize: (Numeric, String?) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# A timeout or interval that cannot be a budget. Raised before the first
|
|
20
|
+
# attempt, so it is not in the record: there is no attempt to count.
|
|
21
|
+
class InvalidPollOptionsError < ArgumentError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# An evidence name that would land outside the step's directory.
|
|
25
|
+
class InvalidEvidenceNameError < ArgumentError
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# An evidence name the engine itself writes into the step's directory.
|
|
29
|
+
class ReservedEvidenceNameError < ArgumentError
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# A pageAs name that cannot be part of a file name.
|
|
33
|
+
class InvalidContextNameError < ArgumentError
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# A pageAs call that asks an open context for options it was not made with.
|
|
37
|
+
class ContextOptionsConflictError < ArgumentError
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module Engine
|
|
41
|
+
# : () -> String
|
|
42
|
+
def self.now_iso: () -> String
|
|
43
|
+
|
|
44
|
+
# `section.("label")` marks that the body reached a stage. It is a bare
|
|
45
|
+
# marker, not a block wrapper, so nesting and an early return need no
|
|
46
|
+
# meaning: the record answers where the body stopped.
|
|
47
|
+
class Sections
|
|
48
|
+
attr_reader entries: Array[Hash[Symbol, String]]
|
|
49
|
+
|
|
50
|
+
# : () -> void
|
|
51
|
+
def initialize: () -> void
|
|
52
|
+
|
|
53
|
+
# : (String | Symbol) -> nil
|
|
54
|
+
def call: (String | Symbol) -> nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# `poll.(description:, timeout:, interval:) { value or nil }` calls the
|
|
58
|
+
# block until it gives a value other than nil. The budget holds the
|
|
59
|
+
# attempt in flight too, so a value that arrives after it is not
|
|
60
|
+
# returned. Every finished call is kept, so the record tells a wait that
|
|
61
|
+
# did nothing from one that took seconds.
|
|
62
|
+
class Polls
|
|
63
|
+
DEFAULT_TIMEOUT_MS: ::Integer
|
|
64
|
+
|
|
65
|
+
DEFAULT_INTERVAL_MS: ::Integer
|
|
66
|
+
|
|
67
|
+
# The longest timer Node accepts, kept so both engines refuse the same values.
|
|
68
|
+
MAX_MS: ::Integer
|
|
69
|
+
|
|
70
|
+
# An Exception, not a StandardError, so a block that rescues its own
|
|
71
|
+
# errors cannot swallow the end of its budget.
|
|
72
|
+
class AttemptOver < Exception
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
attr_reader entries: Array[Hash[Symbol, untyped]]
|
|
76
|
+
|
|
77
|
+
# : () -> void
|
|
78
|
+
def initialize: () -> void
|
|
79
|
+
|
|
80
|
+
# : [T] (?description: String?, ?timeout: Numeric?, ?interval: Numeric?) { () -> T? } -> T
|
|
81
|
+
def call: [T] (?description: String?, ?timeout: Numeric?, ?interval: Numeric?) { () -> T? } -> T
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
# The budget in seconds, from milliseconds.
|
|
86
|
+
# : (untyped, String) -> Float
|
|
87
|
+
def budget: (untyped, String) -> Float
|
|
88
|
+
|
|
89
|
+
# : () -> Float
|
|
90
|
+
def monotonic: () -> Float
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# `evidence.attach(name, body)` writes a file into the step's own
|
|
94
|
+
# directory, and `evidence.path(name)` gives a path there without
|
|
95
|
+
# writing. A name used twice keeps both files. A name that differs only
|
|
96
|
+
# by case counts as the same, since a case-insensitive volume would put
|
|
97
|
+
# the two on one file.
|
|
98
|
+
class Evidence
|
|
99
|
+
# The files and directories the engine writes into the same directory.
|
|
100
|
+
HARNESS: untyped
|
|
101
|
+
|
|
102
|
+
PROCESS_FILE: ::Regexp
|
|
103
|
+
|
|
104
|
+
NAMED_FILE: ::Regexp
|
|
105
|
+
|
|
106
|
+
MAX_ATTACHMENTS: ::Integer
|
|
107
|
+
|
|
108
|
+
# : (String, ?reserved: Array[String]) -> void
|
|
109
|
+
def initialize: (String, ?reserved: Array[String]) -> void
|
|
110
|
+
|
|
111
|
+
# : (String | Symbol, String) -> nil
|
|
112
|
+
def attach: (String | Symbol, String) -> nil
|
|
113
|
+
|
|
114
|
+
# : (String | Symbol) -> String
|
|
115
|
+
def path: (String | Symbol) -> String
|
|
116
|
+
|
|
117
|
+
# What the step left: its attachments, and each path it wrote to, by
|
|
118
|
+
# time, at most MAX_ATTACHMENTS of them, with the whole count when
|
|
119
|
+
# there were more.
|
|
120
|
+
# : () -> [Array[Hash[Symbol, String]], Integer?]
|
|
121
|
+
def snapshot: () -> [ Array[Hash[Symbol, String]], Integer? ]
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
# : (String) -> String
|
|
126
|
+
def allocate: (String) -> String
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -10,6 +10,8 @@ module Nukadoko
|
|
|
10
10
|
class Verdict
|
|
11
11
|
FIXES: untyped
|
|
12
12
|
|
|
13
|
+
TRAILER_KEY: String
|
|
14
|
+
|
|
13
15
|
attr_reader judged: String
|
|
14
16
|
|
|
15
17
|
attr_reader findings: Array[Hash[Symbol, untyped]]
|
|
@@ -32,6 +34,12 @@ module Nukadoko
|
|
|
32
34
|
# : () -> Hash[Symbol, untyped]
|
|
33
35
|
def envelope_fields: () -> Hash[Symbol, untyped]
|
|
34
36
|
|
|
37
|
+
# One git trailer line that stamps a commit with this answer. The tree
|
|
38
|
+
# named is the one the run recorded, so a reader compares it with the
|
|
39
|
+
# commit's own tree later and knows whether the stamp speaks for it.
|
|
40
|
+
# : () -> String
|
|
41
|
+
def trailer: () -> String
|
|
42
|
+
|
|
35
43
|
# : () -> String
|
|
36
44
|
def headline: () -> String
|
|
37
45
|
|
data/skills/nukadoko/SKILL.md
CHANGED
|
@@ -44,7 +44,7 @@ never commits, pushes, or publishes. Keep the narration short.
|
|
|
44
44
|
Run `nuka` from the directory that holds the config, and `nuka init` first
|
|
45
45
|
when there is none (`references/running.md`, "Setting up"); an app to start
|
|
46
46
|
needs the program in `nukadoko.config.ts` (`references/program.md`). A Ruby project
|
|
47
|
-
writes steps as
|
|
47
|
+
writes steps as `references/ruby.md` says. Pick one line:
|
|
48
48
|
|
|
49
49
|
1. **Prose only** (a ticket, a request, a conversation):
|
|
50
50
|
`references/from-prose.md`, then line 2.
|
|
@@ -91,6 +91,28 @@ Code's hook fields as of 2.1.317 (`hook_event_name`, `session_id`, `cwd`,
|
|
|
91
91
|
`stop_hook_active`; `decision: "block"` with `reason`); check them against
|
|
92
92
|
the version you run.
|
|
93
93
|
|
|
94
|
+
## Stamping each commit, before the hook blocks
|
|
95
|
+
|
|
96
|
+
A gate that blocks from its first day blocks on the cases nobody
|
|
97
|
+
measured. `nuka verdict --trailer` is the observing form: it prints one
|
|
98
|
+
git trailer line and exits 0 whatever it says, so it never stops a
|
|
99
|
+
commit. Add it in a `prepare-commit-msg` hook:
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
git interpret-trailers --in-place --trailer "$(npx nuka verdict --trailer)" "$1"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Git runs the hook at the repository's top. When the project is below it,
|
|
106
|
+
`cd` inside the `$(...)`, as `"$(cd app && npx nuka verdict --trailer)"`:
|
|
107
|
+
`$1` is a path from the top.
|
|
108
|
+
|
|
109
|
+
Every commit then carries `Nukadoko-Verdict: passed`, `failed`, `stale`,
|
|
110
|
+
`none` (no run ended), or `unknown` (no tree id), with the run id and the
|
|
111
|
+
tree the run recorded. The stamp speaks for the commit only when
|
|
112
|
+
`git rev-parse <commit>^{tree}` is that tree; a commit of part of the
|
|
113
|
+
working tree carries another. Count the commits that were not `passed`
|
|
114
|
+
for a while, then turn on the Stop hook above, which blocks.
|
|
115
|
+
|
|
94
116
|
## When the reviewer asks how risky it is
|
|
95
117
|
|
|
96
118
|
A pass and a clean intent still leave the reviewer's own question: what
|
|
@@ -93,3 +93,9 @@ never `unproven` (no base can break a claim that compares nothing), and
|
|
|
93
93
|
its judgment decides it. The summary names the judgment files the change
|
|
94
94
|
brings ("A judgment file changed since the base"), so the person reviews
|
|
95
95
|
each judgment with the feature.
|
|
96
|
+
|
|
97
|
+
A judgment the change itself added is the change judging its own output.
|
|
98
|
+
Such a row's `judgment` limit says `stands on a judgment by <name> that
|
|
99
|
+
this change added`, and each cited judgment in run.json carries `in_base:
|
|
100
|
+
false`. When the agent that wrote the change also recorded the judgment,
|
|
101
|
+
tell the person so, and ask a second agent or the person to judge it.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Writing steps in Ruby
|
|
2
|
+
|
|
3
|
+
The other references show steps in TypeScript. A Ruby project (the
|
|
4
|
+
`nukadoko` gem) reads the same feature files, runs the same loop, and
|
|
5
|
+
writes the same records; only the step files and the config differ. This
|
|
6
|
+
page says how each TypeScript shape in the other references reads in Ruby.
|
|
7
|
+
The full surface is the gem's README
|
|
8
|
+
(<https://github.com/meganemura/nukadoko/blob/main/ruby/README.md>), and
|
|
9
|
+
`conformance/cases/` in the repository holds the same projects in both
|
|
10
|
+
languages (`steps-ts/` beside `steps-rb/`), which both engines must judge
|
|
11
|
+
the same way.
|
|
12
|
+
|
|
13
|
+
Run every command as `bundle exec nuka`.
|
|
14
|
+
|
|
15
|
+
## A step
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
# features/steps/add_todo.rb is the step add-todo.
|
|
19
|
+
class AddTodo < Nukadoko::Step
|
|
20
|
+
pattern "a todo titled {title:string} is added"
|
|
21
|
+
description "Create a todo via POST /todos and return the created record"
|
|
22
|
+
args { string :title, "The title of the todo to create" }
|
|
23
|
+
returns do
|
|
24
|
+
string :id, "The id the server assigned"
|
|
25
|
+
boolean :done, "Whether the todo is done; false for a new one"
|
|
26
|
+
end
|
|
27
|
+
mutates true
|
|
28
|
+
|
|
29
|
+
def run(request:, args:)
|
|
30
|
+
request.post("/todos", data: { title: args.title }).json
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| TypeScript | Ruby |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `defineStep({ ... })` in `add-todo.ts` | `class AddTodo < Nukadoko::Step` in `add_todo.rb` |
|
|
38
|
+
| `z.object({ title: z.string().describe("...") })` | `args { string :title, "..." }` |
|
|
39
|
+
| `.optional()`, `.default(10)`, `.min(1)`, `.positive()` | `optional: true`, `default: 10`, `min: 1`, `positive: true` |
|
|
40
|
+
| `z.array(z.object({ ... }))` | `array :todos, "..." do ... end` |
|
|
41
|
+
| `async run({ request }, { title })` | `def run(request:, args:)`, reading `args.title` |
|
|
42
|
+
| `from: { id: [createTodo, "id"] }` | `from id: [CreateTodo, :id]` |
|
|
43
|
+
| `claims: [...]` and `observe` | `claims [...]` and `def observe(...)` |
|
|
44
|
+
| `parts: [createTodo]`, `await call(createTodo, args)` | `parts [CreateTodo]`, `call.(CreateTodo, title: "x")` |
|
|
45
|
+
|
|
46
|
+
The keyword arguments of `run` name the fixtures, as the destructured
|
|
47
|
+
first argument does in TypeScript; `nuka check` reads them without
|
|
48
|
+
calling the body. `args:` is there only when the body reads it.
|
|
49
|
+
|
|
50
|
+
## Fixtures
|
|
51
|
+
|
|
52
|
+
Each fixture has the TypeScript name. Four of them also take a snake_case
|
|
53
|
+
name, which passes RuboCop's naming cops and reaches the same fixture:
|
|
54
|
+
`base_url`, `require_env`, `page_as`, and `result_of`.
|
|
55
|
+
|
|
56
|
+
A fixture that TypeScript calls as a function is a lambda in Ruby, called
|
|
57
|
+
with `.()`: `section.("checkout")`, `require_env.("API_KEY")`,
|
|
58
|
+
`page_as.("aki")`, `result_of.(CreateTodo)`, and
|
|
59
|
+
`poll.(description: "the order", interval: 200) { value or nil }`, whose
|
|
60
|
+
block stands for the function TypeScript passes. `evidence.attach`,
|
|
61
|
+
`evidence.path`, `scratch.dir`, and `scratch.copy` are methods.
|
|
62
|
+
|
|
63
|
+
A project fixture goes in `nukadoko.config.rb`:
|
|
64
|
+
`Nukadoko.fixture(:store) { |use| use.(Store.new) }`, its keyword
|
|
65
|
+
arguments naming what it needs.
|
|
66
|
+
|
|
67
|
+
`Nukadoko.run_command(command, args, cwd:, env:, timeout:)` is the Ruby
|
|
68
|
+
form of `runCommand`. `unbundled: true` runs a command in another Ruby
|
|
69
|
+
project without nuka's Bundler environment.
|
|
70
|
+
|
|
71
|
+
## Playwright from Ruby
|
|
72
|
+
|
|
73
|
+
`page`, `context`, and `page_as` give playwright-ruby-client's objects,
|
|
74
|
+
whose method names are snake_case (`page.get_by_role`, `page.goto`). Two
|
|
75
|
+
calls do not behave as their TypeScript names suggest:
|
|
76
|
+
|
|
77
|
+
- `page.wait_for_url` takes a String or a Regexp. A Proc never matches, so
|
|
78
|
+
the wait runs to its timeout.
|
|
79
|
+
- `context.expect_page` raises ArgumentError. Wait for a new tab with
|
|
80
|
+
`context.expect_event("page") { page.get_by_text("Open").click }`.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nukadoko
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- meganemura
|
|
@@ -79,6 +79,7 @@ files:
|
|
|
79
79
|
- lib/nukadoko/criteria.rb
|
|
80
80
|
- lib/nukadoko/definition.rb
|
|
81
81
|
- lib/nukadoko/env_check.rb
|
|
82
|
+
- lib/nukadoko/error_frames.rb
|
|
82
83
|
- lib/nukadoko/features.rb
|
|
83
84
|
- lib/nukadoko/fixtures.rb
|
|
84
85
|
- lib/nukadoko/http_recording.rb
|
|
@@ -112,6 +113,7 @@ files:
|
|
|
112
113
|
- lib/nukadoko/skill.rb
|
|
113
114
|
- lib/nukadoko/spaces.rb
|
|
114
115
|
- lib/nukadoko/step.rb
|
|
116
|
+
- lib/nukadoko/step_fixtures.rb
|
|
115
117
|
- lib/nukadoko/summary.rb
|
|
116
118
|
- lib/nukadoko/table.rb
|
|
117
119
|
- lib/nukadoko/text_fit.rb
|
|
@@ -142,6 +144,7 @@ files:
|
|
|
142
144
|
- sig/generated/nukadoko/criteria.rbs
|
|
143
145
|
- sig/generated/nukadoko/definition.rbs
|
|
144
146
|
- sig/generated/nukadoko/env_check.rbs
|
|
147
|
+
- sig/generated/nukadoko/error_frames.rbs
|
|
145
148
|
- sig/generated/nukadoko/features.rbs
|
|
146
149
|
- sig/generated/nukadoko/fixtures.rbs
|
|
147
150
|
- sig/generated/nukadoko/http_recording.rbs
|
|
@@ -175,6 +178,7 @@ files:
|
|
|
175
178
|
- sig/generated/nukadoko/skill.rbs
|
|
176
179
|
- sig/generated/nukadoko/spaces.rbs
|
|
177
180
|
- sig/generated/nukadoko/step.rbs
|
|
181
|
+
- sig/generated/nukadoko/step_fixtures.rbs
|
|
178
182
|
- sig/generated/nukadoko/summary.rbs
|
|
179
183
|
- sig/generated/nukadoko/table.rbs
|
|
180
184
|
- sig/generated/nukadoko/text_fit.rbs
|
|
@@ -207,6 +211,7 @@ files:
|
|
|
207
211
|
- skills/nukadoko/references/perturbed-worlds.md
|
|
208
212
|
- skills/nukadoko/references/program.md
|
|
209
213
|
- skills/nukadoko/references/reviewing.md
|
|
214
|
+
- skills/nukadoko/references/ruby.md
|
|
210
215
|
- skills/nukadoko/references/running.md
|
|
211
216
|
- skills/nukadoko/references/scenario-rules.md
|
|
212
217
|
- skills/nukadoko/references/states.md
|