Skip to content

Validate Rakefile-style snippets in customization guide#1196

Open
myronmarston wants to merge 1 commit into
mainfrom
myron/validate-rake-task-snippets
Open

Validate Rakefile-style snippets in customization guide#1196
myronmarston wants to merge 1 commit into
mainfrom
myron/validate-rake-task-snippets

Conversation

@myronmarston
Copy link
Copy Markdown
Collaborator

Summary

  • The 4 Rakefile snippets added in Add user guide for namespaced queries #1191 (schema_element_name_form, schema_element_name_overrides, derived_type_name_formats, type_name_overrides) were never validated—they were extracted as plain text from rake_task_examples.rb without being executed.
  • Moves them into a real Rakefile in a new schema_customization_rake_tasks example project so the setter calls execute at load time, catching syntax errors and API renames.
  • A separate example project is necessary because the Rakefile settings change derived type names (e.g. FilterInputFilter), conflicting with the existing schema_customization/schema.rb which hardcodes names like "OrderFilterInput".

Test plan

  • Individually broke each of the 4 snippets with boom and confirmed rake site:examples:schema_customization_rake_tasks:extract_snippets fails
  • Confirmed renaming a method (e.g. schema_element_name_form_typo=) produces NoMethodError
  • Ran rake site:examples:extract_snippets and confirmed all examples pass (pre-existing [Bug] Psych::DisallowedClass: Tried to load unspecified class: Symbol #1021 issue with music example is unrelated)

🤖 Generated with Claude Code

@myronmarston myronmarston force-pushed the myron/validate-rake-task-snippets branch 4 times, most recently from 5cdc293 to 22d2749 Compare May 20, 2026 01:05
@myronmarston myronmarston changed the base branch from main to myron/schema-customization-guide-followups May 20, 2026 01:41
@myronmarston myronmarston force-pushed the myron/validate-rake-task-snippets branch from 22d2749 to f0d0618 Compare May 20, 2026 01:42
Base automatically changed from myron/schema-customization-guide-followups to main May 20, 2026 17:48
@myronmarston myronmarston force-pushed the myron/validate-rake-task-snippets branch 5 times, most recently from acd2f76 to f746501 Compare May 20, 2026 18:37
The 4 Rakefile snippets (schema_element_name_form, schema_element_name_overrides,
derived_type_name_formats, type_name_overrides) from #1191 were extracted as
text from `rake_task_examples.rb` but never actually executed—a typo or
API rename would go undetected by CI.

Fixes:
- Move snippets into a real `Rakefile` in a new `schema_customization_rake_tasks`
  example project, loaded by the site Rakefile.
- Add `RakeTasks.new` to the `music` example's existing Rakefile.
- Add context comments to snippets showing where the code belongs.
- Add Coverage-based line-level validation: uses Ruby's Coverage module
  to verify every executable snippet line ran during the build.

The Coverage guard:
- Starts `Coverage.start(lines: true)` before loading example Rakefiles
- In `extract_snippets`, checks all `.rb` files were loaded AND all
  executable lines within `:snippet-start:`/`:snippet-end:` fences
  (or all lines for whole-file snippets) were executed
- Supports `# :nocov:` markers for justified coverage gaps
- Loads `validate.rb` in-process (via `load`) instead of as a subprocess
  so Coverage can track lines exercised by validation scripts

A separate example project is needed because the Rakefile settings
(e.g. `derived_type_name_formats = {FilterInput: "%{base}Filter"}`) change
derived type names, conflicting with the `schema_customization` schema.rb
that hardcodes names like `"OrderFilterInput"` in `customize_derived_types`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@myronmarston myronmarston force-pushed the myron/validate-rake-task-snippets branch from f746501 to 1e1b172 Compare May 20, 2026 18:49
@myronmarston myronmarston marked this pull request as ready for review May 20, 2026 18:51
@myronmarston myronmarston enabled auto-merge (squash) May 20, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants