# Creating tests

**URL:** <https://www.ruby-forum.com/t/creating-tests/124150>\
**Category:** Ruby\
**Created:** [December 25, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/creating-tests/124150 "2007-12-25T15:36:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [December 25, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/creating-tests/124150/1 "2007-12-25T15:36:55Z")

</div>

Hi!  
I guess, my problem will scarcely take you very long 🙂  
Recently I faced with a trouble connected with creating the tests for my  
program. It usually occured to be sufficient to use the methods within  
the class I was testing and compare the rusult with the neccesary value  
of variable or method which is used for variable. But for the current  
program I need a test that would simulate the input.  
In other words, for an instance let us have the following ‘program’:

### 

a=0  
puts(“answer is #{a+=gets.to\_f}”) while true

### 

The test must input the numbers sequently and assert the equality of the  
actual output with the necessary string after each step of the cycle.  
So, could you please give me an example of how such tests are supposed  
to be written?  
I’d be very thankful for your help!

---

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [December 25, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/creating-tests/124150/2 "2007-12-25T15:59:13Z")

</div>

Druhie A. wrote:

> a=0  
> puts(“answer is #{a+=gets.to\_f}”) while true
> 
> ### 
> 
> The test must input the numbers sequently and assert the equality of the  
> actual output with the necessary string after each step of the cycle.  
> So, could you please give me an example of how such tests are supposed  
> to be written?  
> I’d be very thankful for your help!

Unless I haven’t misunderstood something: Overwrite gets() so it outputs  
the required user simulation, either on system level, class level or  
instance level.

Best regards,

Jari W.
