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



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

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



46
47
48
49
50
51
# File 'lib/assert/context/test_dsl.rb', line 46

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



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

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?
    # create a test from the given code block
    self.suite.on_test(Assert::Test.for_block(
      desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro,
      Assert::ContextInfo.new(self, called_from, first_caller || caller.first),
      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



27
28
29
30
31
32
33
34
35
36
# File 'lib/assert/context/test_dsl.rb', line 27

def test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block)
  # create a test from a proc that just skips
  ci = Assert::ContextInfo.new(self, called_from, first_caller || caller.first)
  self.suite.on_test(Assert::Test.for_block(
    desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro,
    ci,
    self.suite.config,
    &proc { skip('TODO', ci.called_from) }
  ))
end