Skip to content

Instantly share code, notes, and snippets.

@spllr
Created February 25, 2011 13:57
Show Gist options
  • Save spllr/843814 to your computer and use it in GitHub Desktop.
Save spllr/843814 to your computer and use it in GitHub Desktop.
Test code in an nsrunloop with bacon
class Bacon::Context
def runloop(duration=0.6)
Thread.new {
runloop = NSRunLoop.currentRunLoop
yield
runloop.runUntilDate(NSDate.dateWithTimeIntervalSinceNow(duration))
}.join
end
end
describe 'runloop things' do
it 'does something which depends on a runloop' do
runloop_wanting_instance = MyRunloopSchedualingObject.new
runloop do
runloop_wanting_instance.start
end
runloop_wanting_instance.something.should.equal 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment