nukadoko 0.4.0 → 0.5.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 +66 -0
- data/README.ja.md +10 -1
- data/README.md +9 -2
- data/lib/nukadoko/check.rb +15 -4
- data/lib/nukadoko/cli.rb +1 -1
- 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/run.rb +118 -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/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +1 -1
- data/lib/nukadoko.rb +2 -0
- data/llms.txt +2 -1
- 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/run.rbs +25 -4
- data/sig/generated/nukadoko/schema.rbs +91 -27
- data/sig/generated/nukadoko/step_fixtures.rbs +129 -0
- data/skills/nukadoko/SKILL.md +1 -1
- data/skills/nukadoko/references/ruby.md +80 -0
- metadata +6 -1
|
@@ -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
|
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.
|
|
@@ -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.5.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
|