From: Allison N. <dem...@ma...> - 2008-06-12 12:06:17
|
Ha! Yup, thanks Eloy, that fixed it. I thought it must be something like that :-) Alli On Thursday, June 12, 2008, at 01:49PM, "Eloy Duran" <elo...@gm...> wrote: >Hi Alli, > >The cause might be that there's no runloop. >In all my RC tests I do the following in a test helper: > >Thread.new { OSX.CFRunLoopRun } > >(See http://github.com/alloy/webapp-app/tree/webapp-app/WebAppApplication/test/test_helper.rb > for an example.) > >Eloy > >On Jun 12, 2008, at 1:39 PM, Allison Newman wrote: > >> Hi everyone, >> >> I'm trying to write a unit test at the moment that uses rspec, and >> I'm having some problems. >> >> In my app I have an NSTimer that fires every second after I call a >> start method on my controller. The callback function of the timer >> updates some values on the screen. It works like a charm in the >> real app. >> >> In my unitary tests, I try to call the same 'start' method, and then >> sleep the test thread for x seconds, at the end of which I try to >> verify that a counter has been incremented in my controller 5 >> times. The problem is that the timer callback is never called, so >> the counter is never updated. >> >> I'm guessing that this has something to do with run loops in Cocoa, >> and specifically that I never actually set up a Cocoa runtime in my >> rspec test. Can anyone confirm this? Does anyone have a nice >> elegant way of doing this sort of test? >> >> If not, I guess I can always manually call the timer callback >> manually in the test, to simulate a timer. Trouble is, that means >> that I'm not actually testing the timer functionality itself, which >> is nevertheless an important part of my app. >> >> Any ideas? >> >> Alli >> >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php >> _______________________________________________ >> Rubycocoa-talk mailing list >> Rub...@li... >> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > >------------------------------------------------------------------------- >Check out the new SourceForge.net Marketplace. >It's the best place to buy or sell services for >just about anything Open Source. >http://sourceforge.net/services/buy/index.php >_______________________________________________ >Rubycocoa-talk mailing list >Rub...@li... >https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > |