gtd
gtd

Reputation: 17246

What is the purpose of test_files configuration in a gemspec

The RubyGems Specification Reference says:

A collection of unit test files. They will be loaded as unit tests when the user requests a gem to be unit tested.

However there is no gem test command, and unlike the files config which is used in the packaging, I don't see any obvious place this is used. Google also seems not to turn up anything.

Is there any point for specifying test_files in a gem?

Upvotes: 24

Views: 1938

Answers (1)

jleverenz
jleverenz

Reputation: 411

I've been trying to find an answer to this as well, and while I haven't turned up a definitive "don't use test_files" it seems that support has been somewhat deprecated.

From what I can tell, the answer to your question is "it depends". There are some points to specifying test_files, but they might not be what you expect/want:

  1. From a test perspective, rubygems doesn't seem to do anything as far as running the test files specified.
  2. From a packaging standpoint, they will be installed, which may or may not be useful for an end user.

Some references:

  • An open Issue #735 to not install test_files, deferred to a post-2.x RubyGems release due to 'backward compatibility'
  • Commit 429f88... in the RubyGems github repo, which removed code that tests gems (included back in v1.5.0)
  • A closed Bug #27507 to remove -t from gem install (it was removed after some discussion included in the bug)

Upvotes: 22

Related Questions