Class: Cancun::Test::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/cancun/test.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ TestCase

Returns a new instance of TestCase.



37
38
39
# File 'lib/cancun/test.rb', line 37

def initialize(model)
  @model = model
end

Instance Method Details

#and_type(*args) ⇒ Object



52
53
54
55
56
# File 'lib/cancun/test.rb', line 52

def and_type(*args)
  run
  @model.input_write << [*args].flatten.join("\n") + "\n"
  sleep 0.01
end

#execute(&block) ⇒ Object



41
42
43
44
# File 'lib/cancun/test.rb', line 41

def execute(&block)
  @block = block
  self
end

#execute!(&block) ⇒ Object



46
47
48
49
50
# File 'lib/cancun/test.rb', line 46

def execute!(&block)
  execute(&block)
  run
  sleep 0.01
end

#runObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cancun/test.rb', line 58

def run
  Thread.new do
    Thread.abort_on_exception = true
    begin
      if Cancun.timeout?
        Timeout.timeout(0.3){ @exit_code = @block.call }
      else
        @exit_code = @block.call
      end
    rescue ::Timeout::Error
      warn 'WARNING: cancun timeout, you can set Cancun::Highline.no_timeout!'
    end
  end
end