Module: Assert::Context::TestDSL
- Included in:
- Assert::Context
- Defined in:
- lib/assert/context/test_dsl.rb
Instance Method Summary collapse
- #should(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object
- #should_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object (also: #should_skip)
- #test(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object
- #test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object (also: #test_skip)
Instance Method Details
#should(desc_or_macro, called_from = nil, first_caller = nil, &block) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/assert/context/test_dsl.rb', line 38 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
45 46 47 48 49 50 |
# File 'lib/assert/context/test_dsl.rb', line 45 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 23 24 |
# 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? # create a test from the given code block self.suite.tests << Assert::Test.for_block( desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro, Assert::Suite::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
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/assert/context/test_dsl.rb', line 26 def test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block) # create a test from a proc that just skips ci = Assert::Suite::ContextInfo.new(self, called_from, first_caller || caller.first) self.suite.tests << 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 |