Module: EventMachine::Test

Defined in:
lib/em-spec/test.rb

Class Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/em-spec/test.rb', line 70

def self.included(cls)
  cls.class_eval(<<-HERE_DOC, __FILE__, __LINE__)
    def self.default_timeout(timeout)
      self.send(:remove_const, :DefaultTimeout)
      self.send(:const_set, :DefaultTimeout, timeout)
    end
    
    include TestHelper

    alias_method :run_without_em, :run
    def run(result, &block)
      em(DefaultTimeout) { run_without_em(result, &block) }
    rescue Exception => e
      if RUBY_VERSION >= "1.9.1"
        result.puke(self.class, @name, e)
      else
        add_error($!)
      end
    end
    
  HERE_DOC
  
end