Skip to content

Add specification-drvien test suite#69

Merged
patch0 merged 20 commits into
mainfrom
test-against-specs
May 14, 2026
Merged

Add specification-drvien test suite#69
patch0 merged 20 commits into
mainfrom
test-against-specs

Conversation

@patch0
Copy link
Copy Markdown
Contributor

@patch0 patch0 commented May 1, 2026

What's changed

Spec-driven test suite

Adds a formal spec document and test runner so the Ruby renderer can be validated against canonical examples.

  • spec/fixtures/kramdown_rpf-legacy-spec.md — the legacy spec for kramdown-rpf, covering all supported block types (hint, hints, task, challenge, code, collapse, save, new-page, no-print, print-only, quiz, knowledge quiz, microbit, scratch). Each example shows the markdown input and expected HTML output, separated by a · middle dot. The spec is also published in the documentation repo as the canonical human-readable reference.

  • spec/fixtures/raspberry-flavoured-markdown-draft-spec.md — the transitional spec for kramdown-rpf to render our new RFM syntax.

CI

  • .github/workflows/ci.yml — spec tests are now run as part of the test job, using the spec bundled in this repo. Previously the job attempted to curl the spec from the private documentation repo (which required a PAT); the spec is now versioned here directly.

Tags in specs

Examples in the specs can be tagged

```example not-kramdown foo

and that would add tags to the specs allowing individual bits to be skipped. The tag not-kramdown skips that example in this library, leading to output like:

        example 1 (PENDING: Excluded by tag: not-kramdown)

README

  • Added a Testing against the spec section documenting how to run the spec tests and noting that spec/fixtures/*-spec.md must be kept in sync with the copy in the documentation repo when examples change.

Test results

I've removed the legacy examples and tests in favour of the new spec-based tests.

Finished in 0.26661 seconds (files took 0.2421 seconds to load)
188 examples, 0 failures

@patch0 patch0 marked this pull request as ready for review May 1, 2026 16:11
Copilot AI review requested due to automatic review settings May 1, 2026 16:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a markdown “legacy spec” document and wires RSpec up to execute all spec examples as tests, replacing the existing example-file conversion suite.

Changes:

  • Add spec/kramdown_rpf-legacy-spec.md and a parser-driven RSpec suite to run each ```example block as a test.
  • Add an HTML structural matcher + diff output helper in spec_helper.
  • Skip the old examples/-based conversion tests and update CI/README to run against the spec file.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
spec/specification_spec.rb New spec runner that parses the spec markdown and generates RSpec examples.
spec/spec_helper.rb Adds HTML comparison matcher/diff utilities and shared Kramdown options.
spec/kramdown_rpf_spec.rb Reorders conversion fixtures and skips the conversion suite in favor of spec-driven tests.
spec/kramdown_rpf-legacy-spec.md Adds the formal legacy specification (inputs + expected HTML).
spec/i18n_spec.rb Uses an around hook to restore locale after each locale context.
README.md Documents running the spec-based tests and overriding the spec file via SPEC_MD.
Gemfile Adds new dev dependencies for spec-based HTML comparison.
.github/workflows/ci.yml Sets SPEC_MD in CI when running specs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/specification_spec.rb Outdated
Comment thread spec/specification_spec.rb Outdated
Comment thread spec/specification_spec.rb Outdated
Comment thread Gemfile
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment on lines +155 to +156
**If you add or change examples in `examples/`, you must update the spec file accordingly** — both here in `spec/kramdown_rpf-v0-spec.md` and in the canonical copy in the [documentation repository](https://github.com/RaspberryPiFoundation/documentation) at `docs/technology/codebases-and-products/raspberry-flavoured-markdown/kramdown_rpf-legacy-spec.md`.

@patch0 patch0 changed the title Add specification spec Add specification-drvien test suite May 1, 2026
Copy link
Copy Markdown
Contributor

@rammodhvadia rammodhvadia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished in 0.36953 seconds (files took 0.46481 seconds to load)
139 examples, 0 failures

Looks like the new tests aren't running

@patch0 patch0 merged commit a499754 into main May 14, 2026
4 checks passed
@patch0 patch0 deleted the test-against-specs branch May 14, 2026 13: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.

3 participants