Class: Oktobertest::Test

Inherits:
Object
  • Object
show all
Includes:
Assertions
Defined in:
lib/oktobertest.rb

Instance Method Summary collapse

Methods included from Assertions

#assert, #assert_raises, #flunk, #skip

Constructor Details

#initialize(name = nil, &block) ⇒ Test

Returns a new instance of Test.



95
96
97
# File 'lib/oktobertest.rb', line 95

def initialize(name = nil, &block)
  @name, @block = name.to_s, block
end

Instance Method Details

#run ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/oktobertest.rb', line 99

def run
  instance_eval &@block
  print '.'
rescue TestFailed => error
  print 'F'
rescue TestSkipped => error
  print 'S'
rescue StandardError => error
  print 'E'
ensure
  Oktobertest.errors << error unless error.nil?
end

#run? ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/oktobertest.rb', line 112

def run?
  !ENV['T'] || ENV['T'] == @name
end