Class: Testo::Test

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/testo/test.rb

Defined Under Namespace

Classes: FailedAssertion, Report

Constant Summary collapse

TIMEOUT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Test

Returns a new instance of Test.



24
25
26
# File 'lib/testo/test.rb', line 24

def initialize &block
  @block = block
end

Instance Attribute Details

#itObject (readonly)

Returns the value of attribute it.



31
32
33
# File 'lib/testo/test.rb', line 31

def it
  @it
end

Instance Method Details

#[](it = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/testo/test.rb', line 32

def [] it = nil
  message = { test: self, it: it }.merge in_isolation {
    message = { pid: Process.pid }

    begin
      run it
    rescue Exception
      message[:error] = $!
    end

    message
  }
  
  Report.new message
end

#debug(it) ⇒ Object

Currently, this method is expected to be run from a Pry session only.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/testo/test.rb', line 49

def debug it
  PryByebug::BreakCommand.new.send :add_breakpoint, "Testo::Test#run", nil
  # How to "next next step" automatically when the breakpoint is hit?

  begin
    run it
    raise "Cannot reproduce. It might be a heisebug."
  rescue
    $!
  end
end