# A rake question...running rspec tests in different directories

**URL:** <https://www.ruby-forum.com/t/a-rake-question-running-rspec-tests-in-different-directories/163768>\
**Category:** Ruby\
**Created:** [March 24, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/a-rake-question-running-rspec-tests-in-different-directories/163768 "2009-03-24T18:51:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [March 24, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/a-rake-question-running-rspec-tests-in-different-directories/163768/1 "2009-03-24T18:51:16Z")

</div>

So, I have something I need to do with Rake that I don’t know how to  
do, but seems like it would be possible…

- I have RSpec tests in multiple directories (for different  
components). Each component has its own lib directory. The tests  
refer to their respective lib directory as a relative path (’./lib’).  
Everything works fine if I have a rake file that runs the test from  
the directory where the test file is. But if I try to set up a task  
to run all the tests, the tests get confused, because they can’t find  
the helper scripts and files in their respective lib directories. So,  
here is an example of how the directory structure is set up:

Component1  
« Test\_spec.rb  
«lib directory  
« component1\_helper.rb

Component2  
« Test\_spec.rb  
«lib directory  
« component2\_helper.rb

I want to run a single task that runs all the tests for component 1  
and component 2, and reports the results as a single test run.

So, it seems that for each component I need to change to the  
components directory, then run the tests from that directory context.  
Then, report the results as a single test run. Can this be done with  
Rake? I’m sorry if this is an easy question that’s been answered  
somewhere else…couldn’t find anywhere how to do this.

Thanks,

Jim

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [March 24, 2009, 7:40pm UTC](https://www.ruby-forum.com/t/a-rake-question-running-rspec-tests-in-different-directories/163768/2 "2009-03-24T19:40:56Z")

</div>

On Mar 24, 12:47špm, Jim K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Component1  
> « Test\_spec.rb  
> «lib directory  
> š « component1\_helper.rb
> 
> Component2  
> « Test\_spec.rb  
> «lib directory  
> š « component2\_helper.rb

Nice use of box-drawing characters.
