Sha256: d054b637666cfe7d37265a51528ca4e383cb24afb0cf3a37d4a102fb4226cf44
Contents?: true
Size: 1.88 KB
Versions: 4
Compression:
Stored size: 1.88 KB
Contents
require 'assert/context_info' require 'assert/macro' require 'assert/suite' require 'assert/test' module Assert; end class Assert::Context module TestDSL 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 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 alias_method :test_skip, :test_eventually 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 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 alias_method :should_skip, :should_eventually end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
assert-2.16.3 | lib/assert/context/test_dsl.rb |
assert-2.16.2 | lib/assert/context/test_dsl.rb |
assert-2.16.1 | lib/assert/context/test_dsl.rb |
assert-2.16.0 | lib/assert/context/test_dsl.rb |