Skip to content

Expose the request context on the RSpec controller helpers response - #316

Merged
povilasjurcys merged 3 commits into
masterfrom
feature/BAC-530-response-context
Oct 19, 2026
Merged

povilasjurcys merged 3 commits into
masterfrom
feature/BAC-530-response-context

Conversation

@povilasjurcys

@povilasjurcys povilasjurcys commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

What's the reason for this feature?

Currently, the RSpec controller helpers keep the request private, so a matcher judging response can't see the context the action ran with. rspec_extra_matchers' be_successful_graphql_request needs it to call model fields that read graphql_context, as GraphqlRails does at runtime.

This PR adds response.context, which returns the request's context (the hash-like FakeContext, not a GraphQL::Query::Context).

Reviewers should know:

  • FakeContext delegates only [], []=, to_h, key? and fetch. Decorators that call graphql_context&.dig(...) will raise once the matcher passes this context. That is still open: adding dig to FakeContext here is the likely fix.

povilasjurcys and others added 3 commits October 19, 2026 06:56
…pers response

Matchers that judge a response need the context the action ran with,
e.g. to call model fields that read graphql_context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.17%. Comparing base (2f27ea3) to head (497b80e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #316   +/-   ##
=======================================
  Coverage   98.17%   98.17%           
=======================================
  Files          68       68           
  Lines        1920     1922    +2     
=======================================
+ Hits         1885     1887    +2     
  Misses         35       35           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@povilasjurcys povilasjurcys changed the title Refs #BAC-530: Expose the request context on the RSpec controller helpers response Expose the request context on the RSpec controller helpers response Oct 19, 2026
@povilasjurcys
povilasjurcys merged commit 4300ee4 into master Oct 19, 2026
13 checks passed
@povilasjurcys
povilasjurcys deleted the feature/BAC-530-response-context branch October 19, 2026 05:26
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