# Running changed files

**URL:** <https://www.ruby-forum.com/t/running-changed-files/188988>\
**Category:** Ruby\
**Created:** [May 21, 2010, 12:47pm UTC](https://www.ruby-forum.com/t/running-changed-files/188988 "2010-05-21T12:47:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mszatanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mszatanik](https://www.ruby-forum.com/u/mszatanik)\
**Post date:** [May 21, 2010, 12:47pm UTC](https://www.ruby-forum.com/t/running-changed-files/188988/1 "2010-05-21T12:47:57Z")

</div>

Hi,

Ill try to explain my problem as clear and as short as possible.

I have a button which does:

Test::Unit::UI::Console::TestRunner.run(Testy)

and i have a class which loads the files if they are not already loaded

```
  tests_to_run_filtered.each do |test|
    if $tests_loaded.include?("#{test}") == false
      $tests_loaded[$loaded_i] = test
      $loaded_i = $loaded_i + 1
      load "#{test}"
    end
  end

```

and puts them into suite

$numberoftests = 0  
suite = Test::Unit::TestSuite.new  
suite \<\< START.suite  
$tests\_to\_run.each do |test|  
new\_str = test.delete “\n”  
new\_str = File.basename(new\_str, “.rb”).delete “\n”  
new\_strup = new\_str.upcase + “.suite”  
new\_strupc = eval("#{new\_strup}")  
suite \<\< new\_strupc  
$numberoftests = $numberoftests + 1  
end  
suite \<\< ENDING.suite  
return suite

it all works good.  
but  
-------------problem begins here----------------  
i want to be able to load a test everytime i press my button, tho if i  
do that  
tests are loaded again, and the program executes it twice.

Lets say i have a test “A” when i load it, program runs “A”  
if i have a check not to load files twice it will also run “A”  
if i dont check, program loads “A” twice and executes “A”“A”

I want to be able to run files after i change sth inside them without  
having to restart my aplication.

lets say that test “A” has puts “123” inside  
i start a program and run “A” and i get “123”  
if i change “123” to “321” i will still get “123” if i dont load the  
file again, but i cant do this cos it will run twice.

hope that this is understandable,  
i’ve been working on this for 3 days now, so i ask you to throw some  
ideas at me.

---

<div class="post-metadata">

**Author:** ![mszatanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mszatanik](https://www.ruby-forum.com/u/mszatanik)\
**Post date:** [May 26, 2010, 10:46am UTC](https://www.ruby-forum.com/t/running-changed-files/188988/2 "2010-05-26T10:46:12Z")

</div>

ok i changed a lot, and i just use

```
        $tests_to_run.each do |test|
          system("ruby '#{test}'")
        end

```

feel stupid i didn’t do that earlier 🙂 it does what i want, doesnt load  
to my application, just runs tests as a separate processes
