Skip to content

Validate Rakefile-style snippets in customization guide#1196

Draft
myronmarston wants to merge 1 commit into
myron/schema-customization-guide-followupsfrom
myron/validate-rake-task-snippets
Draft

Validate Rakefile-style snippets in customization guide#1196
myronmarston wants to merge 1 commit into
myron/schema-customization-guide-followupsfrom
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
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.

Fix: move them into a real `Rakefile` in a new `schema_customization_rake_tasks`
example project. The site Rakefile now `load`s an example's `Rakefile` if one
exists, using it instead of the inline `RakeTasks.new` instantiation. Also adds
`RakeTasks.new` to the `music` example's existing Rakefile so it works with
this pattern.

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

Also adds context comments to snippets extracted from within blocks so
readers know where the code goes (e.g. "Within `ElasticGraph.define_schema
{ ... }` in your schema definition:").

Finally, adds a Coverage-based guard that ensures every .rb file in an
example directory is actually loaded during validation. This prevents
future regressions where a snippet file could be added but never executed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@myronmarston myronmarston force-pushed the myron/validate-rake-task-snippets branch from 22d2749 to f0d0618 Compare May 20, 2026 01:42
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.

1 participant