class Oktobertest::Scope
Public Class Methods
new(name = nil, &block)
click to toggle source
# File lib/oktobertest.rb, line 50 def initialize(name = nil, &block) @name, @block = name.to_s, block @setup, @teardown = [], [] end
Public Instance Methods
run()
click to toggle source
# File lib/oktobertest.rb, line 55 def run instance_eval &@block end
run?()
click to toggle source
# File lib/oktobertest.rb, line 59 def run? !ENV['S'] || ENV['S'] == @name end
Protected Instance Methods
scope(name = nil, &block)
click to toggle source
# File lib/oktobertest.rb, line 83 def scope(name = nil, &block) scope = Scope.new name, &block singleton_methods.each { |m| scope.define_singleton_method m, &method(m) } @setup.each { |b| scope.setup &b } @teardown.each { |b| scope.teardown &b } scope.run if scope.run? end
setup(&block)
click to toggle source
# File lib/oktobertest.rb, line 75 def setup(&block) @setup << block end
teardown(&block)
click to toggle source
# File lib/oktobertest.rb, line 79 def teardown(&block) @teardown << block end
test(name = nil, &block)
click to toggle source
# File lib/oktobertest.rb, line 65 def test(name = nil, &block) test = Test.new name, &block public_methods(false).reject { |m| m == :run || m == :run? }.each { |m| test.define_singleton_method m, &method(m) } if test.run? @setup.each { |b| test.instance_eval &b } test.run @teardown.each { |b| test.instance_eval &b } end end