Skip to content

Add comprehensive request specs for ErrorsController#236

Merged
stefan-burke merged 2 commits intomainfrom
terragon/increase-errors-controller-test-coverage
Aug 22, 2025
Merged

Add comprehensive request specs for ErrorsController#236
stefan-burke merged 2 commits intomainfrom
terragon/increase-errors-controller-test-coverage

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • Adds extensive request specs for ErrorsController covering 404 and 500 error responses
  • Tests HTML, JSON, XML, and plain text response formats
  • Verifies Sentry exception capturing behavior in production and non-production environments

Changes

Request Specs for ErrorsController

  • Created spec/requests/errors_controller_spec.rb with 150 lines of tests
  • Tests for GET /404 and GET /500 endpoints
  • Validates correct HTTP status codes and response bodies for different formats:
    • HTML: renders error page with localized titles and messages
    • JSON: returns JSON error response with correct content type
    • XML and text: returns only status code with blank body

Sentry Exception Capture Tests

  • Mocks Rails environment to test production vs non-production behavior
  • Confirms Sentry captures exceptions only in production when exceptions are present
  • Ensures no Sentry capture occurs when no exception is present or in non-production environments

Test plan

  • Run RSpec suite to verify all new request specs pass
  • Confirm coverage increase for ErrorsController
  • Validate Sentry integration behavior through mocks and expectations

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/2ecb15d6-213d-42dc-8a30-4b6c935242c5

stefan-burke and others added 2 commits August 22, 2025 18:35
…ing 404 and 500

Add comprehensive request specs for ErrorsController to test responses for 404 (not_found) and 500 (internal_server_error) errors. Specs cover HTML, JSON, XML, and text formats, and verify Sentry exception capturing behavior in production and non-production environments.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
Refactor the Sentry exception capture tests in ErrorsController specs:
- Move tests from request specs to private method specs
- Use controller instance and doubles instead of request environment stubbing
- Add checks for production and non-production environments
- Improve response body checks for error views

This improves test clarity and isolates private method behavior.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke marked this pull request as ready for review August 22, 2025 19:21
@stefan-burke stefan-burke merged commit d5f2826 into main Aug 22, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/increase-errors-controller-test-coverage branch August 22, 2025 19:21
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