# Callbacks not firing with Ruby/GTK inside of test cases?

**URL:** <https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343>\
**Category:** Ruby-Gnome 2\
**Created:** [April 10, 2006, 5:20am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343 "2006-04-10T05:20:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 5:20am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/1 "2006-04-10T05:20:28Z")

</div>

Hi All,

Hope all is going well.

I’ve developed a simple GUI using Glade and are using the Ruby  
libglade bindings (awesome stuff) to present the GUI to the user. At  
this stage I’ve got a simple test case that using the  
Test::Unit::TestCase base class and all it does is create the GUI and  
wait for feedback.

The problem is that none of the callbacks work when you click on  
buttons, etc. They need to be there otherwise the GUI won’t be  
created, but unfortunately I can’t move onto any of the next screens  
as the buttons activate but the callbacks aren’t fired.

Is Ruby/GTK somehow incompatible/conflicting with the reflection  
going on inside of Test::Unit::TestCase.

Has anyone else seen this behaviour as well? Any thoughts what might  
be going wrong?

Cheers,

Marcus

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 5:35am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/2 "2006-04-10T05:35:30Z")

</div>

Hi,

I think there was a similar issue a few mounths ago and the answer was  
to use the “testrb” program instead of using “ruby” to run your tests.

Mathieu

Marcus C. a écrit :

> The problem is that none of the callbacks work when you click on  
> Cheers,  
> and join the prime developer group breaking into this new coding  
> territory!  
> [http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

–  
Mathieu B.  
[http://www.mblondel.org](http://www.mblondel.org)

---

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 6:39am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/3 "2006-04-10T06:39:23Z")

</div>

Hi Mathieu,

Thanks mate, I’m actually running the tests through Rake - presumably  
that doesn’t use testrb (or the same autorunner classes) internally?

Quite strange behaviour, I’ll try it with testrb then. Thanks for the  
tip.

Cheers,

Marcus

---

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 6:42am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/4 "2006-04-10T06:42:24Z")

</div>

For some strange reason, Ruby-GNOME2 needs to be loaded before  
Test::Unit. If you just make sure that all require ‘gtk2’ statements  
come before require ‘test/unit’, you should be fine. If you are  
running tests using the Rake, you can do the following in the TestTask  
definition:

Rake::TestTask.new do |t|  
t.test\_files = FileList[‘test/test\*.rb’]  
t.verbose = true  
t.ruby\_opts \<\< ‘-rgtk2’  
end

This will ensure that Ruby-GNOME2 is loaded before anything else. It  
is a very silly problem which will hopefully be corrected in a future  
release.

---

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 6:51am UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/5 "2006-04-10T06:51:30Z")

</div>

Hi Daniel,

Awesome mate, that was it - works fine now with the “t.ruby\_opts \<\< ‘-  
rgtk2’” added to my Rakefile.

Thanks for everyone’s help.

Cheers,

Marcus

---

<div class="post-metadata">

**Author:** ![kastorilo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@kastorilo](https://www.ruby-forum.com/u/kastorilo)\
**Post date:** [April 10, 2006, 4:39pm UTC](https://www.ruby-forum.com/t/callbacks-not-firing-with-ruby-gtk-inside-of-test-cases/57343/6 "2006-04-10T16:39:45Z")

</div>

Hi,

On Mon, 10 Apr 2006 00:40:46 -0400  
“Daniel H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> For some strange reason, Ruby-GNOME2 needs to be loaded before  
> Test::Unit.

The problem is both of Ruby/GLib and Test::Unit use “at\_exit” to  
run test scripts.

IMO, Test::Unit shouldn’t use it because you can’t run test  
libraries/applications which use “at\_exit”.  
#So you need to use testrb instead of ruby command.

If you interested in this issue, find this ML again.

> This will ensure that Ruby-GNOME2 is loaded before anything else. It  
> is a very silly problem which will hopefully be corrected in a future  
> release.

It may be silly, but I don’t have another good idea.  
So it won’t be changed by me.  
I hope you’ll fix it and post your patch here ;).

–  
.:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

This [SF.Net](http://SF.Net) email is sponsored by xPML, a groundbreaking scripting  
language  
that extends applications into web and mobile media. Attend the live  
webcast  
and join the prime developer group breaking into this new coding  
territory!  
[http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)
