Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of test_files configuration in a gemspec

Tags:

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?

like image 974
gtd Avatar asked Sep 18 '13 11:09

gtd


People also ask

What does ~> mean?

It means "equal to or greater than in the last digit", so e.g. ~> 2.3 means "equal to 2.3 or greater than 2.3, but less than 3.0", while ~> 2.3.

What is a Gemspec?

The gemspec defines what's in the gem, who made it, and the version of the gem. It's also your interface to RubyGems.org. All of the information you see on a gem page (like jekyll's) comes from the gemspec. Once your gemspec file is sorted out you build it to assemble your gem.


1 Answers

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)
like image 153
jleverenz Avatar answered Jan 22 '23 01:01

jleverenz