class Bacon::FiberedContext

Constants

SpecTimeoutExceededError

Public Instance Methods

cancel_timer() click to toggle source
# File lib/em-spec/bacon.rb, line 57
def cancel_timer
  EM.cancel_timer($_em_timer) if $_em_timer
end
default_timeout(timeout) click to toggle source
# File lib/em-spec/bacon.rb, line 53
def default_timeout(timeout)
  $_em_default_time_to_finish = timeout
end
describe(*args, &block) click to toggle source
# File lib/em-spec/bacon.rb, line 78
def describe(*args, &block)
  context = Bacon::FiberedContext.new(args.join(' '), &block)
  @before.each { |b| context.before(&b) }
  @after.each { |b| context.after(&b) }
  context.run
end
done(succeed = true) click to toggle source
# File lib/em-spec/bacon.rb, line 85
def done(succeed = true)
  cancel_timer
  EM.next_tick{
    if succeed 
      :done.should == :done
    else
      should.flunk
    end
    $em_spec_fiber.resume if $em_spec_fiber
  }
end
it(*args) { || ... } click to toggle source
Calls superclass method
# File lib/em-spec/bacon.rb, line 66
def it *args
  super{
    if block_given?
      if $_em_default_time_to_finish
        timeout($_em_default_time_to_finish)
      end
      yield
      Fiber.yield
    end
  }
end
timeout(time_to_run) click to toggle source
# File lib/em-spec/bacon.rb, line 61
def timeout(time_to_run)
  cancel_timer
  $_em_timer = EM.add_timer(time_to_run) { done(false) }
end