Class: Lemon::TestMethod::Scope

Inherits:
Lemon::TestCase::Scope show all
Defined in:
lib/lemon/test_method.rb

Overview

Scope for evaluating method test definitions.

Instance Method Summary collapse

Methods inherited from Lemon::TestCase::Scope

#after, #before, #initialize, #setup, #teardown

Constructor Details

This class inherits a constructor from Lemon::TestCase::Scope

Instance Method Details

#context(label, &block) ⇒ Object Also known as: Context

Create a sub-case ofr the method case.



159
160
161
162
163
164
165
166
167
168
# File 'lib/lemon/test_method.rb', line 159

def context(label, &block)
  @_testcase.tests << TestMethod.new(
    :context => @_testcase,
    :target  => @_testcase.target,
    :setup   => @_setup,
    :skip    => @_skip,
    :label   => label,
    &block
  )
end

#omit(label = true, &block) ⇒ Object Also known as: Omit

Omit tests.

Examples:

omit "reason" do
  test do
    ...
  end
end


180
181
182
183
184
# File 'lib/lemon/test_method.rb', line 180

def omit(label=true, &block)
  @_omit = label
  block.call
  @_omit = nil
end

#skip(label = true, &block) ⇒ Object Also known as: Skip

Skip tests. Unlike omit, skipped tests are not executed at all.

Examples:

skip "reason" do
  test do
    ...
  end
end


196
197
198
199
200
# File 'lib/lemon/test_method.rb', line 196

def skip(label=true, &block)
  @_skip = label
  block.call
  @_skip = nil
end

#test(label = nil, &block) ⇒ Object Also known as: Test

Define a unit test for this case.

Examples:

test "print message with new line to stdout" do
  puts "Hello"
end


144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/lemon/test_method.rb', line 144

def test(label=nil, &block)
  block = Omission.new(@_omit).to_proc if @_omit
  test  = TestProc.new(
    :context => @_testcase,
    :setup   => @_setup,
    :skip    => @_skip,
    :label   => label,
    &block
  )
  @_testcase.tests << test
  test
end