Class: Lemon::TestMethod::DSL

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

Overview

Scope for evaluating method test definitions.

Direct Known Subclasses

Lemon::TestClassMethod::DSL

Instance Method Summary collapse

Methods inherited from Lemon::TestCase::DSL

#after, #before, #initialize, #omit, #setup, #skip, #teardown

Methods inherited from Module

#namespace

Constructor Details

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

Instance Method Details

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

Create a sub-case of the method case.



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/lemon/test_method.rb', line 174

def context(label, *tags, &block)
  return if @_omit

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

#context_classObject

The class for which this is a DSL context.



142
143
144
# File 'lib/lemon/test_method.rb', line 142

def context_class
  TestMethod
end

#test(label = nil, *tags, &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


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/lemon/test_method.rb', line 154

def test(label=nil, *tags, &block)
  return if @_omit

  test  = TestProc.new(
    :context => @_testcase,
    :setup   => @_setup,
    :skip    => @_skip,
    :label   => label,
    :tags    => tags,
    &block
  )

  @_testcase.tests << test

  test
end