nukadoko 0.5.0 → 0.7.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 +553 -3
- data/README.ja.md +22 -6
- data/README.md +13 -7
- data/docs/ci.ja.md +542 -0
- data/docs/ci.md +635 -0
- data/docs/commands.ja.md +1524 -0
- data/docs/commands.md +1281 -0
- data/docs/engines.json +19 -0
- data/docs/execution-events.ja.md +336 -0
- data/docs/execution-events.md +423 -0
- data/docs/glossary.json +1348 -0
- data/docs/guide.ja.md +733 -0
- data/docs/guide.md +815 -0
- data/docs/intent.ja.md +133 -0
- data/docs/intent.md +156 -0
- data/docs/layout.ja.md +442 -0
- data/docs/layout.md +399 -0
- data/docs/releasing.ja.md +186 -0
- data/docs/releasing.md +237 -0
- data/docs/ruby/reference.ja.md +302 -0
- data/docs/ruby/reference.md +368 -0
- data/docs/spec.ja.md +8916 -0
- data/docs/spec.md +11250 -0
- data/docs/tutorial.ja.md +451 -0
- data/docs/tutorial.md +458 -0
- data/docs/typescript/adopting.ja.md +231 -0
- data/docs/typescript/adopting.md +251 -0
- data/docs/typescript/doors.ja.md +301 -0
- data/docs/typescript/doors.md +329 -0
- data/docs/typescript/migration-playwright-test.ja.md +189 -0
- data/docs/typescript/migration-playwright-test.md +212 -0
- data/docs/typescript/migration.ja.md +391 -0
- data/docs/typescript/migration.md +505 -0
- data/docs/typescript/reference.ja.md +176 -0
- data/docs/typescript/reference.md +197 -0
- data/docs/typescript/upgrading.ja.md +1774 -0
- data/docs/typescript/upgrading.md +2224 -0
- data/docs/web-app.ja.md +627 -0
- data/docs/web-app.md +659 -0
- data/docs/writing-scenarios.ja.md +544 -0
- data/docs/writing-scenarios.md +563 -0
- data/lib/nukadoko/base.rb +12 -5
- data/lib/nukadoko/changed_files.rb +95 -0
- data/lib/nukadoko/check.rb +459 -51
- data/lib/nukadoko/claim_drops.rb +271 -0
- data/lib/nukadoko/claim_line.rb +24 -4
- data/lib/nukadoko/claim_rules.rb +143 -1
- data/lib/nukadoko/claim_sides.rb +157 -9
- data/lib/nukadoko/cli.rb +403 -50
- data/lib/nukadoko/codes.json +246 -21
- data/lib/nukadoko/codes.rb +21 -4
- data/lib/nukadoko/command.rb +120 -13
- data/lib/nukadoko/command_help.rb +128 -0
- data/lib/nukadoko/compat.rb +469 -0
- data/lib/nukadoko/criteria.rb +1 -1
- data/lib/nukadoko/definition.rb +157 -7
- data/lib/nukadoko/error_frames.rb +6 -3
- data/lib/nukadoko/events/count.rb +146 -0
- data/lib/nukadoko/events/counted.rb +114 -0
- data/lib/nukadoko/events/format.rb +257 -0
- data/lib/nukadoko/events/lists.rb +154 -0
- data/lib/nukadoko/events/path.rb +285 -0
- data/lib/nukadoko/events/read.rb +284 -0
- data/lib/nukadoko/events/reader.rb +490 -0
- data/lib/nukadoko/events/selection.rb +252 -0
- data/lib/nukadoko/events/tally.rb +438 -0
- data/lib/nukadoko/features.rb +2 -2
- data/lib/nukadoko/fixtures.rb +160 -35
- data/lib/nukadoko/http_recording.rb +6 -2
- data/lib/nukadoko/intent.rb +364 -0
- data/lib/nukadoko/intent_file.rb +81 -0
- data/lib/nukadoko/intent_view.rb +190 -0
- data/lib/nukadoko/js_json.rb +2 -1
- data/lib/nukadoko/judge.rb +2 -2
- data/lib/nukadoko/judgment_file.rb +22 -1
- data/lib/nukadoko/judgments.rb +33 -3
- data/lib/nukadoko/measure_mcp.rb +202 -0
- data/lib/nukadoko/parts.rb +8 -2
- data/lib/nukadoko/path_view.rb +252 -0
- data/lib/nukadoko/place_rows.rb +161 -0
- data/lib/nukadoko/program.rb +1265 -51
- data/lib/nukadoko/program_log.rb +122 -0
- data/lib/nukadoko/program_shape.rb +385 -0
- data/lib/nukadoko/project_fixtures.rb +43 -10
- data/lib/nukadoko/project_program.rb +5 -4
- data/lib/nukadoko/repeated_prefix.rb +310 -0
- data/lib/nukadoko/report_run.rb +3 -3
- data/lib/nukadoko/run.rb +1156 -159
- data/lib/nukadoko/run_record.rb +70 -46
- data/lib/nukadoko/scaffold.rb +24 -6
- data/lib/nukadoko/schema.rb +15 -2
- data/lib/nukadoko/secrets.rb +55 -5
- data/lib/nukadoko/states.rb +478 -0
- data/lib/nukadoko/step.rb +71 -2
- data/lib/nukadoko/step_fixtures.rb +52 -3
- data/lib/nukadoko/summary.rb +803 -30
- data/lib/nukadoko/table.rb +4 -2
- data/lib/nukadoko/text_fit.rb +20 -7
- data/lib/nukadoko/trace.rb +152 -45
- data/lib/nukadoko/tree_passes.rb +95 -33
- data/lib/nukadoko/underneath.rb +311 -0
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +166 -23
- data/lib/nukadoko/walk.rb +2 -2
- data/lib/nukadoko/walk_step.rb +1 -1
- data/lib/nukadoko.rb +23 -0
- data/llms.txt +42 -35
- data/sig/generated/nukadoko/base.rbs +4 -4
- data/sig/generated/nukadoko/changed_files.rbs +42 -0
- data/sig/generated/nukadoko/check.rbs +147 -10
- data/sig/generated/nukadoko/claim_drops.rbs +135 -0
- data/sig/generated/nukadoko/claim_line.rbs +11 -0
- data/sig/generated/nukadoko/claim_rules.rbs +49 -4
- data/sig/generated/nukadoko/claim_sides.rbs +63 -12
- data/sig/generated/nukadoko/cli.rbs +80 -7
- data/sig/generated/nukadoko/codes.rbs +19 -4
- data/sig/generated/nukadoko/command.rbs +68 -1
- data/sig/generated/nukadoko/command_help.rbs +18 -0
- data/sig/generated/nukadoko/compat.rbs +392 -0
- data/sig/generated/nukadoko/criteria.rbs +1 -1
- data/sig/generated/nukadoko/definition.rbs +50 -0
- data/sig/generated/nukadoko/error_frames.rbs +1 -1
- data/sig/generated/nukadoko/events/count.rbs +69 -0
- data/sig/generated/nukadoko/events/counted.rbs +70 -0
- data/sig/generated/nukadoko/events/format.rbs +163 -0
- data/sig/generated/nukadoko/events/lists.rbs +47 -0
- data/sig/generated/nukadoko/events/path.rbs +161 -0
- data/sig/generated/nukadoko/events/read.rbs +109 -0
- data/sig/generated/nukadoko/events/reader.rbs +226 -0
- data/sig/generated/nukadoko/events/selection.rbs +100 -0
- data/sig/generated/nukadoko/events/tally.rbs +227 -0
- data/sig/generated/nukadoko/features.rbs +6 -4
- data/sig/generated/nukadoko/fixtures.rbs +67 -11
- data/sig/generated/nukadoko/http_recording.rbs +1 -1
- data/sig/generated/nukadoko/intent.rbs +132 -0
- data/sig/generated/nukadoko/intent_file.rbs +46 -0
- data/sig/generated/nukadoko/intent_view.rbs +69 -0
- data/sig/generated/nukadoko/judgment_file.rbs +7 -1
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
- data/sig/generated/nukadoko/parts.rbs +2 -2
- data/sig/generated/nukadoko/path_view.rbs +105 -0
- data/sig/generated/nukadoko/place_rows.rbs +43 -0
- data/sig/generated/nukadoko/program.rbs +627 -23
- data/sig/generated/nukadoko/program_log.rbs +67 -0
- data/sig/generated/nukadoko/program_shape.rbs +147 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
- data/sig/generated/nukadoko/project_program.rbs +2 -1
- data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
- data/sig/generated/nukadoko/report_run.rbs +1 -1
- data/sig/generated/nukadoko/run.rbs +286 -41
- data/sig/generated/nukadoko/run_record.rbs +20 -12
- data/sig/generated/nukadoko/scaffold.rbs +3 -0
- data/sig/generated/nukadoko/schema.rbs +5 -0
- data/sig/generated/nukadoko/secrets.rbs +26 -3
- data/sig/generated/nukadoko/states.rbs +214 -0
- data/sig/generated/nukadoko/step.rbs +58 -1
- data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
- data/sig/generated/nukadoko/summary.rbs +256 -2
- data/sig/generated/nukadoko/table.rbs +3 -2
- data/sig/generated/nukadoko/trace.rbs +108 -33
- data/sig/generated/nukadoko/tree_passes.rbs +36 -8
- data/sig/generated/nukadoko/underneath.rbs +141 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/sig/generated/nukadoko/vocabulary.rbs +45 -6
- data/skills/nukadoko/SKILL.md +18 -18
- data/skills/nukadoko/references/checking-steps.md +16 -83
- data/skills/nukadoko/references/diagnosing.md +6 -6
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/evidence.md +19 -6
- data/skills/nukadoko/references/exploring.md +22 -7
- data/skills/nukadoko/references/fixtures.md +12 -32
- data/skills/nukadoko/references/judgments.md +18 -0
- data/skills/nukadoko/references/maintenance.md +1 -1
- data/skills/nukadoko/references/merge-risk.md +1 -1
- data/skills/nukadoko/references/parts.md +46 -23
- data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
- data/skills/nukadoko/references/program.md +168 -169
- data/skills/nukadoko/references/reviewing.md +20 -20
- data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
- data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
- data/skills/nukadoko/references/ruby/fixtures.md +34 -0
- data/skills/nukadoko/references/ruby/program.md +112 -0
- data/skills/nukadoko/references/ruby/step-files.md +115 -0
- data/skills/nukadoko/references/running.md +34 -34
- data/skills/nukadoko/references/scenario-rules.md +7 -6
- data/skills/nukadoko/references/states.md +7 -1
- data/skills/nukadoko/references/step-files.md +41 -120
- data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
- data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
- data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
- data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
- data/skills/nukadoko/references/typescript/fixtures.md +56 -0
- data/skills/nukadoko/references/typescript/program.md +111 -0
- data/skills/nukadoko/references/typescript/step-files.md +104 -0
- data/skills/nukadoko/references/verdicts.md +10 -10
- data/skills/nukadoko/references/writing-steps.md +67 -67
- data/skills/nukadoko/references/writing-the-feature.md +1 -1
- data/skills/nukadoko-verification/SKILL.md +13 -8
- metadata +103 -7
- data/skills/nukadoko/references/ruby.md +0 -80
data/README.ja.md
CHANGED
|
@@ -11,7 +11,8 @@ TypeScript 版と同じ feature ファイルを読み、同じ判定を返す必
|
|
|
11
11
|
HTTP のステップ、ブラウザのステップ、コマンドラインのステップ、プロジェクトが定義するフィクスチャ、parts でできたステップ、poll する Then ステップ、`from`、docstring、Scenario Outline、条件つきの環境、control と proof run、判定表です。
|
|
12
12
|
`--base`、`--step`、`nuka do`、`nuka scaffold`、`nuka init` も動きます。
|
|
13
13
|
`nuka check` は、パターン、ステップの位置、タグ、Scenario Outline、`from` の順番、フィクスチャ、構文エラーについての指摘と、どこにも使われないステップ・フィクスチャ・`from` のキーや scaffold のままの説明についての注意を、TypeScript 版と同じく報告します。
|
|
14
|
-
|
|
14
|
+
TypeScript 版の機能の一部はまだありません。
|
|
15
|
+
何がないかは [llms.txt](../llms.txt) の Ruby の節にあります。
|
|
15
16
|
|
|
16
17
|
## インストール
|
|
17
18
|
|
|
@@ -22,6 +23,9 @@ Ruby 3.4 以上が要ります。
|
|
|
22
23
|
gem "nukadoko", group: :test
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
**nukadoko 0.7.0 以降**の gem はスキルを同梱し、[Rails Hyperdrive](https://github.com/rails-hyperdrive/rails-hyperdrive) の companion としての導入に対応します。
|
|
27
|
+
nukadoko を bundle している Rails アプリでは、`bin/rails hyperdrive:init` がスキルを `.claude/skills/nukadoko/SKILL.md` と `.claude/skills/nukadoko-verification/SKILL.md` に入れます。
|
|
28
|
+
|
|
25
29
|
## ステップ
|
|
26
30
|
|
|
27
31
|
`features/steps/` の下に 1 ファイル 1 ステップで書きます。
|
|
@@ -53,23 +57,27 @@ end
|
|
|
53
57
|
- `context` は `page` が属するブラウザコンテキストです。`page_as.("aki", { javaScriptEnabled: false })` は、その名前だけのブラウザコンテキストのページを返します。シナリオに 2 人目がいても、その人の cookie は別になります。同じ名前で後から呼ぶと、同じページが返ります。呼んだステップには `trace.aki.zip` が残り、シナリオの終わりに `final.aki.png` が残ります。
|
|
54
58
|
- `section.("label")` は本体がどこまで進んだかを記録の `sections` に残します。`poll.(description: "the order", timeout: 30_000, interval: 500) { 値か nil }` は、ブロックが値を返すまで呼び直します。時間切れなら `Nukadoko::PollTimeoutError` を出し、呼び出しごとに `polls` に残します。`evidence.attach(name, body)` はステップ自身のディレクトリにファイルを書き、`evidence.path(name)` はそこに書くためのパスを返します。どちらも記録の `evidence.attachments` に載ります。`result_of.(MakeTotal)` は、シナリオの前のステップが最後に返した値を読みます。まだなければ nil です。
|
|
55
59
|
- `base_url:`、`require_env:`、`page_as:`、`result_of:` は、`baseURL`、`requireEnv`、`pageAs`、`resultOf` の snake_case の名前です。RuboCop の命名の cop に引っかかりません。どちらの名前でも同じフィクスチャです。`require_env.("KEY")` はキーがないか空のときに例外を出し、記録の `required_env` に聞いたキーを並べます。
|
|
56
|
-
- Then ステップは `claims`
|
|
60
|
+
- Then ステップは `claims` と、system を読む `observe` を書きます。claim の判定は nukadoko が行います。claim が比べる args のキーは `observe` に渡されません。
|
|
57
61
|
|
|
58
62
|
## コマンド
|
|
59
63
|
|
|
60
64
|
- `nuka init` は、`nukadoko.config.rb`、空の `features/steps/`、`.nukadoko/` と `.env` のための `.gitignore` の行を書きます。
|
|
61
65
|
Rakefile に `scenarios` タスクがなければ、`bundle exec nuka run` を実行するタスクを足すので、人も CI も `rake scenarios` を実行します。
|
|
62
66
|
設定ファイルがすでにあれば断ります。
|
|
63
|
-
- `nuka
|
|
64
|
-
- `nuka
|
|
67
|
+
- `nuka <command> --help` は、そのコマンドの使い方、何のためのものか、読むフラグを出します。
|
|
68
|
+
- `nuka check [--json] [--fail-on <code>]... [--env <name>]...` は、実行前にまちがいを報告します。
|
|
69
|
+
`--fail-on` は、そのコードの指摘を注意も含めて検査の失敗にします。
|
|
70
|
+
`nuka check --codes` はすべてのコードと意味を並べます。
|
|
71
|
+
- `nuka run [<feature[:line]|dir>...] [--tag <expression>]... [--env <name>]... [--order file|shuffled[:<seed>]] [--repeat <n>] [--concurrency <n>] [--proof-runs <n>] [--step] [--records] [--json] [--no-check]` は、選んだ system ごとにプログラムを起動し、選んだシナリオを実行して、ステップごとの記録を `.nukadoko/runs/` に書きます。
|
|
65
72
|
対象を書かなければ `features/` を実行します。
|
|
66
73
|
`--order shuffled` は、ファイルを、そしてファイルの中のシナリオを、seed が決める順番で実行します。
|
|
67
74
|
seed が同じなら、TypeScript 版と同じ順番です。
|
|
68
75
|
`--concurrency` は、feature ファイルを丸ごと、その数の worker プロセスに分けて実行します。
|
|
69
76
|
Feature の行に `@nukadoko:serial` があるファイルは、ほかのファイルのあとに 1 つずつ実行します。
|
|
70
77
|
`--repeat` は選んだシナリオをその回数だけ実行し、`--proof-runs` は control を何回実行するかを決め、`--records` はシナリオの記録を終わるたびに stdout に書きます。
|
|
71
|
-
- `nuka verdict [--json]` は、いちばん新しい run が今の作業ツリーを判定し、赤を残さなかったかを答えます。
|
|
78
|
+
- `nuka verdict [--json] [--trailer]` は、いちばん新しい run が今の作業ツリーを判定し、赤を残さなかったかを答えます。
|
|
72
79
|
run は始めません。
|
|
80
|
+
`--trailer` は、その答えでコミットに印を付ける git の trailer を 1 行出し、終了コード 0 で終わります。
|
|
73
81
|
- `nuka judge <feature>:<line> [--run <id>] [--json]` は、Then が判断を求める基準(`judged-as` の claim)について、run が読んだ値を見せます。
|
|
74
82
|
`--meets` か `--misses` に `--by <who>` と `--because <一文>` を付けると、その値の判断を `judgments/<feature>.json` に記録します。
|
|
75
83
|
次の run は、この記録と照らして基準を読みます。
|
|
@@ -105,10 +113,14 @@ gem が入れる実行ファイルには、`bundle binstubs <gem>` が `bin/<nam
|
|
|
105
113
|
`--then` とキャプチャ 1 つと一緒に使うと、claim がその 2 つを比べるので、ステップは書き直さずに使えます。
|
|
106
114
|
- ブラウザの起動設定は `nukadoko.config.rb` に `Nukadoko.config(browser: { executablePath: "..." })` と書きます。`page` を使うステップは、シナリオごとに自分のブラウザコンテキストを持ちます。ステップの記録には、ページが送ったリクエストとステップのトレースが残ります。
|
|
107
115
|
- `scratch` を使うステップは `scratch.dir` で新しいディレクトリを得ます。シナリオが終わると消えます。`scratch.copy(source)` は、プロジェクトのファイルかディレクトリの写しを入れた新しいディレクトリを返します。`args:` キーワードを書かない本体は、args なしで呼ばれます。`Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` はプログラムを実行し、`{ exitCode:, signal:, stdout:, stderr: }` を返します。ステップの記録には実行したプロセスが残り、`redact:` に渡した値は `{{secret.NAME}}` になります。
|
|
116
|
+
`timeout:` の単位は秒です。
|
|
117
|
+
ステップの `timeout` と `poll` の `timeout_ms` はミリ秒なので、単位が違います。
|
|
118
|
+
`timeout:` で止めた実行には終了コードがないので、`Timeout::Error` を投げます。
|
|
108
119
|
プログラムは nuka の環境変数を受け継ぎ、`bundle exec` の下では nuka の Gemfile を指します。
|
|
109
120
|
別の Ruby プロジェクトのコマンド(`bin/rails runner` など)を動かすときは、`unbundled: true` で Bundler が入る前の環境変数を使います。
|
|
110
|
-
- `Nukadoko.config(envFiles: [".env"])` は env ファイルを `env` フィクスチャに読み込みます。config の `program:` の環境は、その後ろに自分の `envFiles:` を足せます。git が追跡していないファイルと HEAD と違うファイルは秘密の出どころです。その 4 文字以上の値は、ステップの記録、`http.jsonl`、`nuka do` の出力で `{{secret.NAME}}` に置き換わります。ステップが表示したものは、秘密を伏せて stderr に出ます。`secrets: { public: [...], redact: [...] }` で、そのようなキーを平文のままにしたり、追跡しているファイルのキーを伏せたりできます。`nuka check` は、無いファイル、読み飛ばした行、どのファイルにもない `secrets` のキーを警告し、値は表示しません。
|
|
121
|
+
- `Nukadoko.config(envFiles: [".env"])` は env ファイルを `env` フィクスチャに読み込みます。config の `program:` の環境は、その後ろに自分の `envFiles:` を足せます。git が追跡していないファイルと HEAD と違うファイルは秘密の出どころです。その 4 文字以上の値は、ステップの記録、`http.jsonl`、system の `program.log`、`nuka do` の出力で `{{secret.NAME}}` に置き換わります。ステップが表示したものは、秘密を伏せて stderr に出ます。`secrets: { public: [...], redact: [...] }` で、そのようなキーを平文のままにしたり、追跡しているファイルのキーを伏せたりできます。`nuka check` は、無いファイル、読み飛ばした行、どのファイルにもない `secrets` のキーを警告し、値は表示しません。
|
|
111
122
|
- `Nukadoko.config(parameterTypes: [{ name: "priority", regexp: /高|低/, transformer: ->(s) { s == "高" ? "high" : "low" } }])` は、TypeScript の config の `parameterTypes` と同じようにパラメータ型を登録します。前後に空白のない文の中の値も、`{p:priority}` で読めます。regexp は Ruby の Regexp か文字列です。transformer は省いてもよく、regexp が捕まえたグループを受け取ります。`nuka check` は、組み込みの名前を使う型、どのパターンも使わない型、transformer が書き換えた値と比べる主張を報告します。
|
|
123
|
+
- cucumber-ruby のスイートは、そのまま取り込めます。step 定義と `features/support/` のファイルは cucumber-ruby と同じ順に読み込まれ、`Given`、`When`、`Then`、`Before`、`After`、`AfterStep`、`BeforeAll`、`AfterAll`、`World`、`ParameterType` がトップレベルにあります。compat step が受け持つ行は、`compat: <pattern>` という名前の step record をそれぞれ持って動き、step は 1 つずつ `Nukadoko::Step` に移せます。compat step には契約がないので、Then の位置にあれば `nuka check` が警告します(`then-compat-step`)。扉が受け付けるものと拒否するものは [docs/ruby/reference.ja.md](../docs/ruby/reference.ja.md#compat-steps移行の扉) にあります。
|
|
112
124
|
- プロジェクトのフィクスチャは `nukadoko.config.rb` に書きます。ブロックは値を `use` に渡し、その後ろが後片付けです。例: `Nukadoko.fixture(:store) { |use| use.(Store.new) }`。`scope: :process` にすると、環境ごとの実行全体で 1 つの値を使います。キーワード引数は、フィクスチャが使うもの(別のプロジェクトのフィクスチャか、`page`、`request`、`env`、`requireEnv`、`baseURL`、`scratch` などの組み込み)を表します。組み込みと同じ名前のフィクスチャは、すべてのステップでそれを置き換えます。そのフィクスチャ自身の `page:` は組み込みの page なので、包んで渡せます。例: `Nukadoko.fixture(:page) { |use, page:| page.set_default_navigation_timeout(10_000); use.(page) }`。`page`、`context`、`pageAs` のどれも受け取らない `page` の上書きは、`nuka check` が `page-override-unowned` で止めます。
|
|
113
125
|
- `parts [CreateTodo, CompleteById]` で、ステップが呼べるステップを宣言します。`call.(CreateTodo, title: args.title)` で 1 つを実行し、args と返り値を確かめます。パターンのない part も書けます。呼び出しは、呼んだステップの記録の `calls` に残ります。`nuka check` は、`parts` の循環と、`mutates false` なのに `mutates true` の part を持つステップを報告します。
|
|
114
126
|
- `poll timeout_ms: 3000` は、すべての claim が 2 回続けて成り立つか時間切れになるまで、100 ミリ秒おきに `observe` を読み直します。`settled:` には、一度なったら変わらない状態を書きます。2 回続けてその状態なら、壊れた claim を待つのをやめます。読んだ結果はすべてステップの記録に残ります。
|
|
@@ -125,6 +137,10 @@ Nukadoko.config(
|
|
|
125
137
|
)
|
|
126
138
|
```
|
|
127
139
|
|
|
140
|
+
`ready` が `timeout_ms`(既定は 60000)のうちに 2xx を返した時点で、system の準備ができたとみなします。
|
|
141
|
+
コマンドは空白で分け、シェルは通しません。
|
|
142
|
+
すべてのフィールドは [docs/ruby/reference.ja.md](../docs/ruby/reference.ja.md#プログラム) にあります。
|
|
143
|
+
|
|
128
144
|
## 開発
|
|
129
145
|
|
|
130
146
|
- このディレクトリで `bundle install` を実行します。
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The Ruby engine of [nukadoko](../README.md): typed step contracts for Gherkin, written in Ruby, so a scenario can be told wrong before it runs.
|
|
4
4
|
It reads the same feature files as the TypeScript engine and must judge them the same way; the cases in [`../conformance/`](../conformance/README.md) hold it to that.
|
|
5
5
|
|
|
6
|
-
Status: it passes every scenario under `conformance/engine/`, which runs each `nuka` command against both engines, and the ten cases in `conformance/`: HTTP steps, browser steps, command-line steps, fixtures a project defines, steps made of parts, polling Then steps, `from`, docstrings, Scenario Outlines, environments with conditions, controls with proof runs, and the verdict table. It runs `--base`, `--step`, `nuka do`, `nuka scaffold`, and `nuka init`. `nuka check` reports the pattern, position, tag, outline, `from` order, fixture, and parse findings the TypeScript engine reports, and its notes on unbound steps, unused fixtures, unused `from` keys, and scaffold descriptions. Some of what the TypeScript engine does is not here yet
|
|
6
|
+
Status: it passes every scenario under `conformance/engine/`, which runs each `nuka` command against both engines, and the ten cases in `conformance/`: HTTP steps, browser steps, command-line steps, fixtures a project defines, steps made of parts, polling Then steps, `from`, docstrings, Scenario Outlines, environments with conditions, controls with proof runs, and the verdict table. It runs `--base`, `--step`, `nuka do`, `nuka scaffold`, and `nuka init`. `nuka check` reports the pattern, position, tag, outline, `from` order, fixture, and parse findings the TypeScript engine reports, and its notes on unbound steps, unused fixtures, unused `from` keys, and scaffold descriptions. Some of what the TypeScript engine does is not here yet; the Ruby section of [llms.txt](../llms.txt) lists it.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@ Add it to the Gemfile of the project under test. It needs Ruby 3.4 or later.
|
|
|
13
13
|
gem "nukadoko", group: :test
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
**nukadoko 0.7.0 and later** bundle the skills and offer [Rails Hyperdrive](https://github.com/rails-hyperdrive/rails-hyperdrive) companion installation. For Rails apps bundling nukadoko, `bin/rails hyperdrive:init` installs them to `.claude/skills/nukadoko/SKILL.md` and `.claude/skills/nukadoko-verification/SKILL.md`.
|
|
17
|
+
|
|
16
18
|
## A step
|
|
17
19
|
|
|
18
20
|
One step per file under `features/steps/`. The file name is the step name (`add_todo.rb` is `add-todo`).
|
|
@@ -43,14 +45,15 @@ end
|
|
|
43
45
|
- `context` is the browser context `page` belongs to. `page_as.("aki", { javaScriptEnabled: false })` gives the page of a browser context of its own for the name, so a second person in the scenario keeps cookies of their own. A later call for the name gets the same page. Each step that calls it keeps `trace.aki.zip`, and the scenario ends with `final.aki.png`.
|
|
44
46
|
- `section.("label")` marks a stage the body reached, in the record's `sections`. `poll.(description: "the order", timeout: 30_000, interval: 500) { value or nil }` calls the block until it gives a value, raises `Nukadoko::PollTimeoutError` when the time runs out, and keeps each call in `polls`. `evidence.attach(name, body)` writes a file into the step's own directory, and `evidence.path(name)` gives a path there to write to; the record lists both in `evidence.attachments`. `result_of.(MakeTotal)` reads what an earlier step of the scenario last returned, or nil.
|
|
45
47
|
- `base_url:`, `require_env:`, `page_as:`, and `result_of:` are the snake_case names of `baseURL`, `requireEnv`, `pageAs`, and `resultOf`, so a body passes RuboCop's naming cops. Either name reaches the same fixture. `require_env.("KEY")` raises when the key is missing or empty, and the record lists each key asked for in `required_env`.
|
|
46
|
-
- A Then step declares `claims` and an `observe` that reads the
|
|
48
|
+
- A Then step declares `claims` and an `observe` that reads the system. nukadoko judges the claims. `observe` does not receive an args key that a claim compares with.
|
|
47
49
|
|
|
48
50
|
## Commands
|
|
49
51
|
|
|
50
52
|
- `nuka init` writes `nukadoko.config.rb`, the empty `features/steps/`, and the `.gitignore` entries for `.nukadoko/` and `.env` files. A Rakefile with no `scenarios` task gets one that runs `bundle exec nuka run`, so people and CI run `rake scenarios`. It refuses when the config file exists.
|
|
51
|
-
- `nuka
|
|
52
|
-
- `nuka
|
|
53
|
-
- `nuka
|
|
53
|
+
- `nuka <command> --help` prints the command's usage, what it is for, and the flags it reads.
|
|
54
|
+
- `nuka check [--json] [--fail-on <code>]... [--env <name>]...` reports what is wrong before anything runs. `--fail-on` makes a finding of that code fail the check, a note included, and `nuka check --codes` lists every code with its meaning.
|
|
55
|
+
- `nuka run [<feature[:line]|dir>...] [--tag <expression>]... [--env <name>]... [--order file|shuffled[:<seed>]] [--repeat <n>] [--concurrency <n>] [--proof-runs <n>] [--step] [--records] [--json] [--no-check]` starts the program in each selected system, runs the selected scenarios, and writes a record per step under `.nukadoko/runs/`. With no target it runs `features/`. `--order shuffled` plays the files, then each file's scenarios, in an order a seed names, the same order the TypeScript engine plays for that seed. `--repeat` plays the selection that many times, `--concurrency` spreads whole feature files over that many worker processes (a file tagged `@nukadoko:serial` on its Feature line runs alone, after them), `--proof-runs` sets how many times each control runs, and `--records` writes each scenario record to stdout as it ends.
|
|
56
|
+
- `nuka verdict [--json] [--trailer]` says whether the newest run judged the working tree as it is now and left nothing red. It never starts a run. `--trailer` prints one git trailer line that stamps a commit with that answer, and exits 0.
|
|
54
57
|
- `nuka judge <feature>:<line> [--run <id>] [--json]` shows the values a run read for a criterion whose Then asks for a judgment (a `judged-as` claim). With `--meets` or `--misses`, `--by <who>`, and `--because <one sentence>` it records a judgment of them in `judgments/<feature>.json`, which the next run reads the criterion against.
|
|
55
58
|
- `nuka report [run] --format markdown|messages|allure [--out <path>] [--json]` renders a run again from its run directory alone, the newest run when none is named. `markdown` is its `summary.md`. `messages` is a cucumber-messages stream, one envelope per line, so a formatter or a JUnit step that reads cucumber's protocol keeps working: a claim step's claims and each criterion's verdict ride as attachments. `allure` is a directory of Allure results, `.nukadoko/export/allure-results` unless `--out` names another: one result per execution, each claim a child step of its Then, with the history id the TypeScript engine's results of the same scenario carry.
|
|
56
59
|
- `nuka run <feature>:<line> --step` walks one scenario a step at a time: after each step it waits until `nuka step` answers. `nuka step wait [--walk <n>] [--timeout <s>] [--json]` prints where the walk stands: the step it paused after, its record, and a screenshot and an ARIA snapshot of the page it left open. `nuka step next <pause> --walk <n>` runs the next step, and `nuka step stop <pause> --walk <n>` skips the rest, which leaves the scenario stopped and its row red. Either engine's `nuka step` answers either engine's walk.
|
|
@@ -59,9 +62,10 @@ end
|
|
|
59
62
|
- `nuka do <step> [--args <json>] [--use <step-id>]...` runs one step outside any scenario and prints its step record. `--use` fills the step's `from` args from an earlier record, of a `do` or of a run.
|
|
60
63
|
- `nuka scaffold <name> [--pattern <p>] [--then] [--description <text>] [--replace]` writes `features/steps/<name>.rb`, a step whose body raises `not implemented` until someone writes it. `nuka scaffold --feature <path>` writes one for each line no step matches, its pattern read from the line. `--command <entry point>` writes a step that runs the program under Ruby in a scratch directory and returns `exitCode`, `stdout`, and `stderr` (`--cwd <key>` runs it in the directory an args key holds, and `--argv <key>` splits one capture into its arguments). For an executable a gem installs, `bundle binstubs <gem>` writes `bin/<name>`, an entry point `--command` can run. `--request "<METHOD> <path>"` writes a step that sends one request and returns `status` and `body` (`--body <key>` sends that args key). `--from <step>.<key>` fills an args key from an earlier step's returns; with `--then` and one capture, the claim compares the two, so the step needs no edit.
|
|
61
64
|
- Browser launch options go in `nukadoko.config.rb`, as `Nukadoko.config(browser: { executablePath: "..." })`. A step that names `page` gets a browser context of its own for each scenario; each step record holds the requests the page sent and a trace of the step.
|
|
62
|
-
- A step that names `scratch` gets `scratch.dir`, a fresh directory that is removed when the scenario ends, and `scratch.copy(source)`, one that holds a copy of a file or directory of the project. A body that names no `args:` keyword is called without them. `Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` runs a program and returns `{ exitCode:, signal:, stdout:, stderr: }`; the step record lists each run, with each `redact:` value the step holds written as `{{secret.NAME}}`. The program inherits nuka's environment, which under `bundle exec` names nuka's Gemfile; `unbundled: true` runs it with the environment from before Bundler, for a command in another Ruby project such as `bin/rails runner`.
|
|
63
|
-
- `Nukadoko.config(envFiles: [".env"])` loads env files into the `env` fixture, and an environment of the config's `program:` adds its own `envFiles:` after them. A file git does not track, or one that differs from HEAD, is a secret source: each of its values four characters or longer is written as `{{secret.NAME}}` in every step record, `http.jsonl`, and what `nuka do` prints, and what a step prints reaches stderr with them redacted. `secrets: { public: [...], redact: [...] }` keeps one such key plain, or redacts one key of a tracked file. `nuka check` warns about a missing file, a line it skipped, and a `secrets` key no file defines, and never prints a value.
|
|
65
|
+
- A step that names `scratch` gets `scratch.dir`, a fresh directory that is removed when the scenario ends, and `scratch.copy(source)`, one that holds a copy of a file or directory of the project. A body that names no `args:` keyword is called without them. `Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` runs a program and returns `{ exitCode:, signal:, stdout:, stderr: }`; the step record lists each run, with each `redact:` value the step holds written as `{{secret.NAME}}`. Its `timeout:` is in seconds, unlike the step's `timeout` and `poll`'s `timeout_ms`, which are milliseconds; a run it stops raises `Timeout::Error`, since it has no exit code. The program inherits nuka's environment, which under `bundle exec` names nuka's Gemfile; `unbundled: true` runs it with the environment from before Bundler, for a command in another Ruby project such as `bin/rails runner`.
|
|
66
|
+
- `Nukadoko.config(envFiles: [".env"])` loads env files into the `env` fixture, and an environment of the config's `program:` adds its own `envFiles:` after them. A file git does not track, or one that differs from HEAD, is a secret source: each of its values four characters or longer is written as `{{secret.NAME}}` in every step record, `http.jsonl`, the system's `program.log`, and what `nuka do` prints, and what a step prints reaches stderr with them redacted. `secrets: { public: [...], redact: [...] }` keeps one such key plain, or redacts one key of a tracked file. `nuka check` warns about a missing file, a line it skipped, and a `secrets` key no file defines, and never prints a value.
|
|
64
67
|
- `Nukadoko.config(parameterTypes: [{ name: "priority", regexp: /高|低/, transformer: ->(s) { s == "高" ? "high" : "low" } }])` registers a parameter type, as `parameterTypes` does in the TypeScript config, so `{p:priority}` reads a value inside a sentence with no spaces around it. The regexp is a Ruby Regexp or a string, and the transformer, which may be left out, is given the groups the regexp captured. `nuka check` reports a type that takes a built-in name, one no pattern names, and a claim that compares with a capture a transformer rewrote.
|
|
68
|
+
- A cucumber-ruby suite comes in as it is: its step definitions and `features/support/` files load in cucumber-ruby's order, with `Given`, `When`, `Then`, `Before`, `After`, `AfterStep`, `BeforeAll`, `AfterAll`, `World`, and `ParameterType` at the top level. Each line a compat step binds runs with a step record of its own, named `compat: <pattern>`, and each step can move to a `Nukadoko::Step` on its own. A compat step has no contract, so `nuka check` warns of one in Then position (`then-compat-step`). [docs/ruby/reference.md](../docs/ruby/reference.md#compat-steps-the-migration-door) lists what the door takes and what it refuses.
|
|
65
69
|
- A project fixture goes in `nukadoko.config.rb`. The block calls `use` with the value, and what follows is the teardown: `Nukadoko.fixture(:store) { |use| use.(Store.new) }`. `scope: :process` keeps one value for the whole run of an environment. A keyword argument names what the fixture needs: another project fixture, or a builtin (such as `page`, `request`, `env`, `requireEnv`, `baseURL`, `scratch`). A fixture with a builtin's name replaces it for every step, and its own `page:` is the builtin, so it can wrap it: `Nukadoko.fixture(:page) { |use, page:| page.set_default_navigation_timeout(10_000); use.(page) }`. `nuka check` refuses a `page` override that names none of `page`, `context`, and `pageAs` (`page-override-unowned`).
|
|
66
70
|
- `parts [CreateTodo, CompleteById]` declares the steps a step may run, and `call.(CreateTodo, title: args.title)` runs one, with its args and returns checked. A part needs no pattern. Each call is kept under `calls` in the calling step's record. `nuka check` reports a cycle in `parts` and a `mutates false` step whose part declares `mutates true`.
|
|
67
71
|
- `poll timeout_ms: 3000` reads `observe` again, 100 ms apart, until every claim holds on two readings in a row or the time runs out. `settled:` names a state that cannot change once reached, so two settled readings in a row stop the wait for a claim that broke. Every reading is kept in the step record.
|
|
@@ -78,6 +82,8 @@ Nukadoko.config(
|
|
|
78
82
|
)
|
|
79
83
|
```
|
|
80
84
|
|
|
85
|
+
The system is ready once `ready` answers 2xx within `timeout_ms` (default 60000). The command is split on whitespace and never goes through a shell; [docs/ruby/reference.md](../docs/ruby/reference.md#program) has every field.
|
|
86
|
+
|
|
81
87
|
## Development
|
|
82
88
|
|
|
83
89
|
- `bundle install` in this directory.
|