Slow down a test thread so that the asset happens way after some code runs

44 views
Skip to first unread message

Jonathan Silverman

unread,
Jul 2, 2012, 3:29:03 PM7/2/12
to rubym...@googlegroups.com
I am trying to use guard in RubyMotion with bacon and having some success.

However, sometimes I want to run a slow piece of code and then wait a few seconds, until it finishes.

How can I wait for a part of bacon to catch up before testing something?

I mean like a Timeout thingy maybe?

I know there was a way to do this with Iphone's asynchronicity everywhere. LMK

Thanks,
jsilver

Justin Campbell

unread,
Jul 2, 2012, 3:53:59 PM7/2/12
to rubym...@googlegroups.com
Have you tried simply using sleep?

# setup some stuff
sleep 3
# asset some stuff

-Justin

Justin Campbell

unread,
Jul 2, 2012, 3:54:23 PM7/2/12
to rubym...@googlegroups.com
assert*

-Justin

Mateus

unread,
Jul 2, 2012, 4:35:36 PM7/2/12
to rubym...@googlegroups.com
since Rubymotion uses MacBacon, it should be possible to use this:
  it 'should perform a long running operation' do
    @ary.performSelector("addObject:", withObject:"soup", afterDelay:0.5)
    wait 0.6 do
      @ary.size.should.be 1
    end
  end

Jonathan Silverman

unread,
Jul 3, 2012, 2:03:45 AM7/3/12
to rubym...@googlegroups.com
Thanks Justin and Mateus.

Yes, have tried using sleep. I will try again with sleep and wait. This is just definitely something to be aware of when moving around from Rails to RM. :)

Jonathan Silverman

unread,
Jul 3, 2012, 2:36:35 AM7/3/12
to rubym...@googlegroups.com
This is exactly what I was looking for
Reply all
Reply to author
Forward
0 new messages