2

Bundler's gemspec template provides the following as the default for specifying a gems files:

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }

A lot of other (seemingly irrelevant) files like the .gitignore and .travis.yml file would be included, so why exclude the tests?

I've seen other high-profile gems ignore test files too.

fny
  • 31,255
  • 16
  • 96
  • 127

1 Answers1

2

Besides holding arbitrary metadata about a gem, one important thing that the Gemspec does is tell Rubygems which files are needed to build your gem.

I think Bundler recommends excluding tests because they aren't functional code that is needed for your gem to be built or run. Including every test suite for every Gem in the Ruby universe would be expensive. There isn't a compelling reason you would need to access Omniauth's tests from within your app.

The tests are important, and that's why they were exist as part of the repository. They just aren't necessary in production, so they don't get wrapped up in the package you download from Rubygems.

As for .gitignore and .travis.yml you can exclude these on your own. I don't think the Bundler team was trying to think of every scenario, just the most likely ones.

Jake Worth
  • 5,490
  • 1
  • 25
  • 35