Skip to content

Conversation

davidcornu
Copy link
Member

@davidcornu davidcornu commented Sep 24, 2025

Summary of the problem

Prior art

Because our test suite makes external API calls and relies on certain credentials being available,

  • It does not run successfully for third-party (including Dependabot) PRs as we don't provision all the environment variables
  • It is a pain to get running locally as you need credentials for a bunch of services
  • It does not run without a network connection

Describe your changes

I commented out my local .env file, configured WebMock to block all requests, and chipped away at all the errors until the whole thing ran successfully. This ended up involving:

  1. Adding fallback values for TEST_URL_HOST (this seems like an odd thing to require in the first place)
  2. Generating a fake Stripe API key when one isn't configured (only in the test env)
  3. Generating an ephemeral encryption key for Lockbox if one isn't configured (only in the test env)
  4. Generating ephemeral encryption keys for ActoveRecord::Encryption if they aren't configured (only in the test env)
  5. Added a cached version of the EuCentralBank values for use in the test env
  6. Added stubs and/or performed additional refactors to impacted tests

When (2), (3), and (4) take effect we log the ephemeral values to STDERR:

CleanShot 2025-09-24 at 16 40 37

I've also removed WebMock.allow_net_connect! so any newly-introduced network calls will fail.

Notes

@davidcornu davidcornu marked this pull request as ready for review September 24, 2025 20:43
@davidcornu davidcornu requested review from a team as code owners September 24, 2025 20:43
@davidcornu davidcornu force-pushed the david/push-zxmoqxwzlqwz branch from 19886fb to e748f42 Compare September 25, 2025 16:34
Copy link
Member

@garyhtou garyhtou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very nice to have!

require "rails_helper"

RSpec.describe Donation, type: :modal do
RSpec.describe Donation, type: :model do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@davidcornu davidcornu added this pull request to the merge queue Sep 29, 2025
Merged via the queue into hackclub:main with commit 323c971 Sep 29, 2025
9 checks passed
@davidcornu davidcornu deleted the david/push-zxmoqxwzlqwz branch September 29, 2025 21:01
@davidcornu davidcornu mentioned this pull request Sep 29, 2025
3 tasks
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.

2 participants