Module: Assert::Context::TestDSL

Included in:
Assert::Context
Defined in:
lib/assert/context/test_dsl.rb

Instance Method Summary collapse

Instance Method Details

#should(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object



34
35
36
37
38
39
# File 'lib/assert/context/test_dsl.rb', line 34

def should(desc_or_macro, called_from=nil, first_caller=nil, &block)
  if !desc_or_macro.kind_of?(Assert::Macro)
    desc_or_macro = "should #{desc_or_macro}"
  end
  test(desc_or_macro, called_from, first_caller || caller.first, &block)
end

#should_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object Also known as: should_skip



41
42
43
44
45
46
# File 'lib/assert/context/test_dsl.rb', line 41

def should_eventually(desc_or_macro, called_from=nil, first_caller=nil, &block)
  if !desc_or_macro.kind_of?(Assert::Macro)
    desc_or_macro = "should #{desc_or_macro}"
  end
  test_eventually(desc_or_macro, called_from, first_caller || caller.first, &block)
end

#test(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/assert/context/test_dsl.rb', line 10

def test(desc_or_macro, called_from=nil, first_caller=nil, &block)
  if desc_or_macro.kind_of?(Assert::Macro)
    instance_eval(&desc_or_macro)
  elsif block_given?
    ci = Assert::Suite::ContextInfo.new(self, called_from, first_caller || caller.first)
    test_name = desc_or_macro

    # create a test from the given code block
    self.suite.tests << Assert::Test.new(test_name, ci, self.suite.config, &block)
  else
    test_eventually(desc_or_macro, called_from, first_caller || caller.first, &block)
  end
end

#test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object Also known as: test_skip



24
25
26
27
28
29
30
31
# File 'lib/assert/context/test_dsl.rb', line 24

def test_eventually(desc_or_macro, called_from=nil, first_caller=nil, &block)
  ci = Assert::Suite::ContextInfo.new(self, called_from, first_caller || caller.first)
  test_name = desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro
  skip_block = block.nil? ? Proc.new { skip 'TODO' } : Proc.new { skip }

  # create a test from a proc that just skips
  self.suite.tests << Assert::Test.new(test_name, ci, self.suite.config, &skip_block)
end