
# Installing TestGlance for RSpec

## 1. Make tests emit JUnit XML

Add the JUnit formatter gem to the project's `Gemfile`:

```ruby
# Gemfile
group :test do
  gem 'rspec_junit_formatter'
end
```

Then `bundle install`.

Either pass the formatter on the command line in CI:

```bash
bundle exec rspec \
  --format progress \
  --format RspecJunitFormatter \
  --out test-results/rspec.xml
```

…or set it as a default by adding this to the project's `.rspec` file:

```text
# .rspec
--format progress
--format RspecJunitFormatter
--out test-results/rspec.xml
```

If `parallel_tests` is in use, each process writes its own report —
include the worker number in the filename, e.g.
`test-results/rspec-<%= ENV['TEST_ENV_NUMBER'] %>.xml`. TestGlance
auto-discovers anything under `test-results/`.

## 2. Add the TestGlance step to CI

If the project already has a CI workflow that runs the tests, add this step
to the test job (after the test step), and merge the `permissions:` block at
the workflow's top level:

```yaml
permissions:
  contents: read
  pull-requests: write

# ...inside the test job, after the test step:
- uses: testglance/action@v1
  if: always()
  with:
    github-token: ${{ github.token }}
```

If no CI workflow runs the tests yet, create
`.github/workflows/testglance.yml` that runs the project's tests and then
runs the TestGlance step.

`if: always()` matters — TestGlance should still run when tests fail.
TestGlance auto-discovers anything matching `**/test-results/*.xml`, so no
`report-path` is needed when reports land under `test-results/`.

## 3. Confirm with the user before committing

Summarize the diff and ask the user to confirm before staging or
committing. Do not push.
