# How to test a ruby script from another ruby script?

**URL:** <https://www.ruby-forum.com/t/how-to-test-a-ruby-script-from-another-ruby-script/191743>\
**Category:** Ruby\
**Created:** [July 17, 2010, 11:35am UTC](https://www.ruby-forum.com/t/how-to-test-a-ruby-script-from-another-ruby-script/191743 "2010-07-17T11:35:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saravanan77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@saravanan77](https://www.ruby-forum.com/u/saravanan77)\
**Post date:** [July 17, 2010, 11:35am UTC](https://www.ruby-forum.com/t/how-to-test-a-ruby-script-from-another-ruby-script/191743/1 "2010-07-17T11:35:43Z")

</div>

i have a ruby echo server script working, but to validate that its  
working fine, how to write a ruby script(test case) to provide fake  
stdin input to that echo server script and find if the same has been  
displayed back by the echo server script.

Can any point some examples on the same?

Thanks

---

<div class="post-metadata">

**Author:** ![saravanan77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@saravanan77](https://www.ruby-forum.com/u/saravanan77)\
**Post date:** [July 19, 2010, 2:06pm UTC](https://www.ruby-forum.com/t/how-to-test-a-ruby-script-from-another-ruby-script/191743/2 "2010-07-19T14:06:11Z")

</div>

Saravanan Sundaramoorthy wrote:

> i have a ruby echo server script working, but to validate that its  
> working fine, how to write a ruby script(test case) to provide fake  
> stdin input to that echo server script and find if the same has been  
> displayed back by the echo server script.
> 
> Can any point some examples on the same?

[http://en.wikibooks.org/wiki/Ruby\_Programming/Running\_Multiple\_Processes](http://en.wikibooks.org/wiki/Ruby_Programming/Running_Multiple_Processes)

might be of some service to you. I’ve also seen core do it by  
redirecting STDOUT and capturing what is written to it, if you don’t  
want to spawn new processes.  
GL.  
-r
