| Class | Uttk::Strategies::Block |
| In: |
lib/uttk/strategies/Block.rb
|
| Parent: | IOBased |
I can evaluate a Ruby block. The test fails if block raise an excption or return a false/nil value.
# File lib/uttk/strategies/Block.rb, line 17 def self.create ( *a, &block ) raise ArgumentError, 'need a block' if block.nil? strategy = new(*a) strategy.test = block strategy end
# File lib/uttk/strategies/Block.rb, line 25 def test=(block1=nil, &block2) if block2 @test = block2 elsif not block1.nil? @test = block1 else raise ArgumentError, 'no block given' end end
# File lib/uttk/strategies/Block.rb, line 61 def assertion fail @raised_exception if @raised_exception pass if @result fail @result end
# File lib/uttk/strategies/Block.rb, line 36 def prologue super if @test.is_a?(String) str = @test.dup @test = lambda { eval str.do_symtbl_gsub(@symtbl) } end @result, @raised_exception = nil, nil end