mix reqord.edit (reqord v0.4.0)

View Source

Edit cassette entries in your editor with automatic JSON encoding/decoding.

This task opens cassette entries in your configured editor (via $EDITOR or $VISUAL), handles JSONL parsing and formatting, and validates changes before saving.

Useful for manually redacting sensitive data like emails, account IDs, or other PII from response bodies.

Usage

# Edit all entries in a cassette (relative to cassette dir)
mix reqord.edit my_test.jsonl

# Edit with full/relative path
mix reqord.edit test/support/cassettes/auth_param_test.jsonl

# Edit a specific entry by index (0-based)
mix reqord.edit my_test.jsonl --entry 0

# Edit entries matching a URL pattern
mix reqord.edit my_test.jsonl --grep "/users"

# Use a specific cassette directory (for short names only)
mix reqord.edit my_test.jsonl --dir test/fixtures

Options

  • --entry INDEX - Edit only the entry at INDEX (0-based)
  • --grep PATTERN - Edit only entries matching URL pattern
  • --dir PATH - Cassette directory (default: test/support/cassettes)

Workflow

  1. Task loads cassette entries from JSONL file
  2. Filters entries based on --entry or --grep if specified
  3. Formats entries as pretty-printed JSON
  4. Opens your editor with the JSON content
  5. Validates JSON after you save and close the editor
  6. Writes valid entries back to the cassette file

Editor Configuration

The task uses your configured editor in this order:

  1. $VISUAL environment variable
  2. $EDITOR environment variable
  3. Falls back to 'vim' if neither is set

Example: Redacting Emails

# Edit the cassette
mix reqord.edit AccountTest/fetches_user.jsonl

# In your editor, find the response body and change:
# "email": "user@example.com"
# to:
# "email": "[REDACTED]"

# Save and close - the task validates and writes back to JSONL

Error Handling

  • If JSON is invalid after editing, the task shows errors and exits without saving
  • Original cassette is preserved if validation fails
  • Use mix reqord.show to verify changes after editing