Share an RSpec HTML report

Ruby teams have a good HTML formatter built in and almost nobody uses it, because the output has nowhere to go. rspec --format html --out rspec.html produces a clean, self-contained document — and then it sits in the working directory of whichever machine ran the suite, so the actual sharing mechanism stays what it always was: pasting a stack trace into Slack and hoping the indentation survives.

Publish it

bundle exec rspec --format progress --format html --out rspec.html
require "net/http"; require "json"; require "uri"

uri = URI("https://commareports.com/api/v1/reports")
res = Net::HTTP.post(
  uri,
  { title: "Specs — #{`git rev-parse --short HEAD`.strip}",
    html: File.read("rspec.html") }.to_json,
  "Authorization" => "Bearer #{ENV.fetch('COMMA_API_TOKEN')}",
  "Content-Type"  => "application/json",
)
puts JSON.parse(res.body)["url"]

Two formatters in one run means CI keeps its dots and you still get the document. No second suite execution, no separate reporting gem.

From CI, one URL per suite

curl -fsS -X PATCH "https://commareports.com/api/v1/reports/$REPORT_ID" \
  -H "Authorization: Bearer $COMMA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --rawfile html rspec.html '{html: $html}')"

Use a scoped token limited to reports:write. PATCHing one id appends a revision per run at a stable URL, which turns the two questions everyone actually asks — was this failing before? and what changed? — into a diff rather than a memory test.

Provider wiring: GitHub Actions, GitLab CI, CircleCI, Bitbucket Pipelines.

The part Slack can't do

A pasted backtrace is a dead end: no history, no anchor, and the reply that explains it scrolls away in an hour. A published report gives the failure an address.

  • Anchored comments on the example that failed — see commenting on HTML.
  • Revision history, so a flaky spec's pattern is visible.
  • Access per report — private, team, domain-gated, or named reviewers. See the sharing model.

Limits

  • HTML body: 5 MB. A very large suite's HTML can approach it; split by spec directory and publish one report per suite.
  • Scripts run, sandboxed: allow-scripts, no allow-same-origin.
  • 60 requests/minute per token.

Try it

Comma is free — unlimited reports, unlimited commenters, unlimited revision history.

Publish a spec report →

Related