lib/shoulda/context/context.rb in shoulda-context-1.0.0.beta1 vs lib/shoulda/context/context.rb in shoulda-context-1.0.0

- old
+ new

@@ -71,11 +71,11 @@ def should(name_or_matcher, options = {}, &blk) if Shoulda::Context.current_context Shoulda::Context.current_context.should(name_or_matcher, options, &blk) else - context_name = self.name.gsub(/Test/, "") + context_name = self.name.gsub(/Test/, "") if self.name context = Shoulda::Context::Context.new(context_name, self) do should(name_or_matcher, options, &blk) end context.build end @@ -90,11 +90,11 @@ # should_not set_the_flash def should_not(matcher) if Shoulda::Context.current_context Shoulda::Context.current_context.should_not(matcher) else - context_name = self.name.gsub(/Test/, "") + context_name = self.name.gsub(/Test/, "") if self.name context = Shoulda::Context::Context.new(context_name, self) do should_not(matcher) end context.build end @@ -300,10 +300,14 @@ self.teardown_blocks = [] self.shoulds = [] self.should_eventuallys = [] self.subcontexts = [] - merge_block(&blk) + if block_given? + merge_block(&blk) + else + merge_block { warn " * WARNING: Block missing for context '#{full_name}'" } + end Shoulda::Context.remove_context end def merge_block(&blk) blk.bind(self).call