# Testing Gems

**URL:** <https://rubytalk.org/t/testing-gems/24028>\
**Category:** ruby-talk\
**Created:** [11 January 2006 13:45 UTC](https://rubytalk.org/t/testing-gems/24028 "2006-01-11T13:45:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caleb\_Tennis](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Caleb\_Tennis](https://rubytalk.org/u/Caleb_Tennis)\
**Post date:** [11 January 2006 13:45 UTC](https://rubytalk.org/t/testing-gems/24028/1 "2006-01-11T13:45:04Z")

</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:** ![Robin\_Stocker1](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@Robin\_Stocker1](https://rubytalk.org/u/Robin_Stocker1)\
**Post date:** [11 January 2006 14:15 UTC](https://rubytalk.org/t/testing-gems/24028/2 "2006-01-11T14:15:54Z")

</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

&nbsp;&nbsp;&nbsp;Robin

Caleb Tennis 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.
> > 
> > Caleb

---

<div class="post-metadata">

**Author:** ![Ross\_Bamford2](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@Ross\_Bamford2](https://rubytalk.org/u/Ross_Bamford2)\
**Post date:** [11 January 2006 14:18 UTC](https://rubytalk.org/t/testing-gems/24028/3 "2006-01-11T14:18:05Z")

</div>

Try something like:

&nbsp;&nbsp;$ gem install --test somegem

There is detail with:

&nbsp;&nbsp;$ gem help install  
&nbsp;&nbsp;$ 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,

> **···**
>
> On Wed, 11 Jan 2006 13:45:04 -0000, Caleb Tennis \<caleb@aei-tech.com\> 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.
> 
> --  
> Ross Bamford - rosco@roscopeco.remove.co.uk

---

<div class="post-metadata">

**Author:** ![Mark\_Volkmann1](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Mark\_Volkmann1](https://rubytalk.org/u/Mark_Volkmann1)\
**Post date:** [11 January 2006 14:20 UTC](https://rubytalk.org/t/testing-gems/24028/4 "2006-01-11T14:20:59Z")

</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

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.

> **···**
>
> On 1/11/06, Robin Stocker \<robin@nibor.org\> wrote:
> 
> > Caleb Tennis 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.  
> > \>  
> > \> Caleb
> 
> --  
> R. Mark Volkmann  
> Partner, Object Computing, Inc.
