lib/assert/context/test_dsl.rb in assert-2.14.0 vs lib/assert/context/test_dsl.rb in assert-2.15.0
- old
+ new
@@ -5,41 +5,45 @@
module Assert; end
class Assert::Context
module TestDSL
- def test(desc_or_macro, called_from=nil, first_caller=nil, &block)
+ 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)
+ 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
- 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 }
-
+ def test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block)
# create a test from a proc that just skips
- self.suite.tests << Assert::Test.new(test_name, ci, self.suite.config, &skip_block)
+ 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
alias_method :test_skip, :test_eventually
- def should(desc_or_macro, called_from=nil, first_caller=nil, &block)
+ 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)
+ 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