Scenario: Reject an email that is not a valid address
Given the shopper is on the checkout form
When the shopper submits the email "not-an-email"
Then the page shows "Enter a valid email address" beside the email field
And the order is not placed
檢查清單
- Submitting the email "not-an-email" shows "Enter a valid email address" beside the email field.
- The order is not placed.
When 只留一個。第二個動作就是第二個情境。And 延續同一個關鍵字:另一個 Given,或另一個 Then。不要用 And 夾帶第二個行為。
The checkout form should handle bad input gracefully and feel fast.
可驗證
When the shopper submits the email "not-an-email", the checkout page shows "Enter a valid email address" beside that field and does not place the order.
同一條 lint 命令不檢查情境步驟的關鍵字。specscore rehearse 執行情境檔案:Rehearse 指南在圍欄命令上方使用 ## Given 或 ## When 這樣的標題,並用 **Use:** 呼叫可重複使用的檢查。一個檔案裡有一個 Given 和數個 When 分支時,會作為各自獨立的案例執行。specscore rehearse new <feature-slug>#ac:<ac-slug> 讀取功能 README,並把該標準裡的 Given/When/Then 行抽到 spec/features/<feature-slug>/_tests/<ac-slug>.md。這些都不在 dogfood 工作流程裡執行。工作流程執行的是 specscore spec lint。
內嵌標準,出自驗收標準規範
## Acceptance Criteria
### AC: invalid-email-rejected
**Requirements:** checkout#req:reject-invalid-email
An email that is not a valid address is rejected, and the order is not placed.
精簡標準檔案,rehearse acs 讀取的形態
# AC: invalid-email-rejected
**Status:** accepted
**Verifies:** checkout#req:reject-invalid-email
## Statement
An email that is not a valid address is rejected, and the order is not placed.
情境檔案,出自情境規範
# Scenario: Reject an invalid email
**Validates:** [checkout#ac:invalid-email-rejected](../README.md#ac-invalid-email-rejected)
## Steps
GIVEN the shopper is on the checkout form
WHEN the shopper submits the email "not-an-email"
THEN the page shows "Enter a valid email address" beside the email field
AND the order is not placed
Rehearse 情境,Rehearse 指南裡的形態
# Rehearse: Reject an invalid email
## Given a submitted email that is not a valid address
```bash
printf 'email=not-an-email\n' > form.txt
```
## When the response is recorded
```bash
printf 'Enter a valid email address\n' > out.txt
```
## Then the message is the invalid-email text
```bash
grep -q 'Enter a valid email address' out.txt
```