Skip to content

Don't ship tests in the gem - #301

Merged
apotonick merged 1 commit into
trailblazer:masterfrom
sampokuokkanen:gemspec-without-tests
Oct 21, 2026
Merged

apotonick merged 1 commit into
trailblazer:masterfrom
sampokuokkanen:gemspec-without-tests

Conversation

@sampokuokkanen

Copy link
Copy Markdown

The gem currently packs everything git ls-files lists, including test/, which isn't needed at runtime and is more than half of the gem (79 KB packed, about 215 KB unpacked → 34 KB packed). It ends up in every installation, e.g. production Docker images.

This rejects test/, spec/ and features/ from spec.files (the same paths spec.test_files named), and removes spec.test_files, which RubyGems ignores. rake test uses its own FileList, so it is unaffected.

test/ isn't needed at runtime and is more than half of the packed gem
(79 KB -> 34 KB). spec.test_files is ignored by RubyGems, so it goes too.
Comment thread representable.gemspec

spec.files = `git ls-files`.split("\n")
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
spec.files = `git ls-files`.split("\n").reject { |f| f.start_with?("test/", "spec/", "features/") }

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.

Do you understand why the old version doesn't play anymore? It's generic bundler gem logic.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

rubygems/guides#90 (comment)
test_files still ships the test files. The documentation about it has been removed, and it has been soft deprecated.

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.

Thanks @sampokuokkanen 🍻 !

@apotonick
apotonick merged commit d97f5d0 into trailblazer:master Oct 21, 2026
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