Skip to content

Ship only the specs external adapters need - #1726

Merged
iMacTia merged 2 commits into
lostisland:mainfrom
sampokuokkanen:gemspec-adapter-specs-only
Oct 25, 2026
Merged

iMacTia merged 2 commits into
lostisland:mainfrom
sampokuokkanen:gemspec-adapter-specs-only

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

The gem includes all of spec/ (about 300 KB unpacked). External adapters only need spec/external_adapters/faraday_specs_setup.rb and the files it requires from spec/support, so this ships those two directories and leaves out Faraday's own specs, saving about 270 KB on every installation (e.g. production Docker images).

Those two directories stay because adapters that depend on the released gem load them from it: faraday-httpclient pins faraday >= 1.0, and OS packagers (OpenBSD ports, NetBSD pkgsrc) run adapter tests against the packaged Faraday. Adapters that use Faraday from git, like faraday-net_http, are unaffected either way.

Checked by building the gem, unpacking it and running require "faraday_specs_setup" from it.

Adapter gems load spec/external_adapters/faraday_specs_setup.rb, which
requires files from spec/support. Faraday's own specs aren't needed by
anyone installing the gem, and add about 270 KB to every installation
(e.g. production Docker images).

@iMacTia iMacTia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, it looks a bit extreme only to shave off 270KB, but I guess it won't hurt.

Only one ask though, add a comment on top of the require_relative list in spec/external_adapters/faraday_specs_setup.rb to signal that only the support folder is bundled with the gem, and therefore if new items are added to the list outside of that, it will require updating the gemspec

@sampokuokkanen

Copy link
Copy Markdown
Contributor Author

Thanks, I added the comment.

Yeah, it's not that much by itself, but can shave off a bit if multiple gems do it.

@iMacTia iMacTia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for adding the comment πŸ™!
I'm gonna merge this in and pack it with the next release πŸ‘

@iMacTia
iMacTia merged commit 745b0f3 into lostisland:main Oct 25, 2026
16 checks passed
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