View as Markdown

RSpec Integration with Mergify

Report your test results from RSpec to Mergify


This guide explains how to integrate RSpec with Test Insights using the rspec-mergify gem. Once installed, test results are automatically uploaded to Test Insights without any extra workflow changes.

You need to install the rspec-mergify gem to automatically upload your test results to Test Insights.

Add the gem to your Gemfile:

group :test do
gem 'rspec-mergify'
end

Then run:

Terminal window
bundle install

Alternatively, install it directly:

Terminal window
gem install rspec-mergify

Your workflow should run your tests as usual while exporting the secret MERGIFY_TOKEN as an environment variable.

Add the following to the GitHub Actions step running your tests:

env:
MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}

For example:

- name: Run RSpec Tests 🧪
env:
MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}
run: bundle exec rspec

Set MERGIFY_TOKEN as an environment variable in your pipeline step:

steps:
- label: "Run RSpec Tests 🧪"
command: bundle exec rspec
env:
MERGIFY_TOKEN: "${MERGIFY_TOKEN}"

The gem automatically collects your test results and sends them to Test Insights.

Check the Test Insights dashboard afterward to view execution metrics, detect flaky tests, and review test trends.

VariablePurposeDefault
MERGIFY_TOKENAPI authentication tokenRequired
MERGIFY_API_URLAPI endpoint locationhttps://api.mergify.com
RSPEC_MERGIFY_ENABLEForce-enable outside CIfalse
RSPEC_MERGIFY_DEBUGPrint spans to consolefalse
MERGIFY_TRACEPARENTW3C distributed trace contextOptional
MERGIFY_TEST_JOB_NAMETest job name identifierOptional

Was this page helpful?