Top Level Namespace

Defined Under Namespace

Modules: Matest Classes: ExampleBlock

Instance Method Summary collapse

Instance Method Details

#capture_exception(exception_class = nil, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/matest/capture_exception.rb', line 6

def capture_exception(exception_class=nil, &block)
  expected_exception = exception_class || BasicObject
  begin
    block.call
    if exception_class
      raise Matest::NoExceptionRaised.new("Expected '#{exception_class.inspect}' from the block, but none was raised.")
    else
      raise Matest::NoExceptionRaised.new("Expected an Exception from the block, but none was raised.")
    end
    false
  rescue Matest::NoExceptionRaised => e
    raise e
  rescue expected_exception => e
    e
  rescue BasicObject => e
    raise e
  end
end

#scope(description = nil, &block) ⇒ Object Also known as: describe, context, group



1
2
3
# File 'lib/matest/top_level_methods.rb', line 1

def scope(description=nil, &block)
  Matest::Runner.runner << Matest::ExampleGroup.new(block)
end

#xscope(description = nil, &block) ⇒ Object Also known as: xdescribe, xcontext, xgroup



5
6
7
# File 'lib/matest/top_level_methods.rb', line 5

def xscope(description=nil, &block)
  Matest::Runner.runner << Matest::SkippedExampleGroup.new(block)
end