# Testing Gems

**URL:** <https://www.ruby-forum.com/t/testing-gems/95013>\
**Category:** Ruby\
**Created:** [January 11, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/testing-gems/95013 "2006-01-11T14:46:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caleb\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/977dab/32.png) [@Caleb\_T](https://www.ruby-forum.com/u/Caleb_T)\
**Post date:** [January 11, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/testing-gems/95013/1 "2006-01-11T14:46:17Z")

</div>

According to [http://docs.rubygems.org/read/chapter/20#test\_files](http://docs.rubygems.org/read/chapter/20#test_files), the  
test\_files section of the gemspec file lists test files that are loaded  
“when  
the user requests a gem to be unit tested”.

Is there a gem command to run the tests? I can’t see one listed in the  
help,  
but I may just be missing it.

Caleb

---

<div class="post-metadata">

**Author:** ![Caleb\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/977dab/32.png) [@Caleb\_T](https://www.ruby-forum.com/u/Caleb_T)\
**Post date:** [January 11, 2006, 3:17pm UTC](https://www.ruby-forum.com/t/testing-gems/95013/2 "2006-01-11T15:17:15Z")

</div>

Hi,

I recently had exactly the same question… So, maybe the Gemspec  
Reference should be updated.

The install command has the --test or -t option.  
Have a look at gem help install.

So, for example:  
gem install examplegem --test

Robin

---

<div class="post-metadata">

**Author:** ![Caleb\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/977dab/32.png) [@Caleb\_T](https://www.ruby-forum.com/u/Caleb_T)\
**Post date:** [January 11, 2006, 3:20pm UTC](https://www.ruby-forum.com/t/testing-gems/95013/3 "2006-01-11T15:20:21Z")

</div>

On Wed, 11 Jan 2006 13:45:04 -0000, Caleb T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> According to [http://docs.rubygems.org/read/chapter/20#test\_files](http://docs.rubygems.org/read/chapter/20#test_files), the  
> test\_files section of the gemspec file lists test files that are loaded  
> “when  
> the user requests a gem to be unit tested”.
> 
> Is there a gem command to run the tests? I can’t see one listed in the  
> help,  
> but I may just be missing it.

Try something like:

```
$ gem install --test somegem

```

There is detail with:

```
$ gem help install
$ gem help examples

```

If the tests succeed, there’s no output (at least by default?) but they  
do  
run if they’re there (after Rdoc I think).

Cheers,

---

<div class="post-metadata">

**Author:** ![Caleb\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/977dab/32.png) [@Caleb\_T](https://www.ruby-forum.com/u/Caleb_T)\
**Post date:** [January 11, 2006, 3:23pm UTC](https://www.ruby-forum.com/t/testing-gems/95013/4 "2006-01-11T15:23:40Z")

</div>

On 1/11/06, Robin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I recently had exactly the same question… So, maybe the Gemspec  
> Reference should be updated.
> 
> The install command has the --test or -t option.  
> Have a look at gem help install.
> 
> So, for example:  
> gem install examplegem --test

Interesting thing about running the tests this way …  
If the gem has no tests, it outputs “There are no unit tests to run”.  
If any tests fail, it prompts whether to keep the gem.  
If no tests fail, there is no output and no indication that tests were  
run.

I don’t really like that last part. I wish there was some output  
indicating that the tests were actually run.
