diff --git a/lib/shoulda/gem/shoulda.rb b/lib/shoulda/gem/shoulda.rb index d229371..3daad6a 100644 --- a/lib/shoulda/gem/shoulda.rb +++ b/lib/shoulda/gem/shoulda.rb @@ -34,14 +34,12 @@ module Thoughtbot # Note: The part before should in the test name is gleamed from the name of the Test::Unit class. def should(name, &blk) - should_eventually(name) && return unless block_given? - if Shoulda.current_context - Shoulda.current_context.should(name, &blk) + block_given? ? Shoulda.current_context.should(name, &blk) : Should.current_context.should_eventually(name) else context_name = self.name.gsub(/Test/, "") context = Thoughtbot::Shoulda::Context.new(context_name, self) do - should(name, &blk) + block_given? ? should(name, &blk) : should_eventually(name) end context.build end @@ -157,7 +155,11 @@ module Thoughtbot end def should(name, &blk) - self.shoulds << { :name => name, :block => blk } + if block_given? + self.shoulds << { :name => name, :block => blk } + else + self.should_eventuallys << { :name => name } + end end def should_eventually(name, &blk) diff --git a/test/other/context_test.rb b/test/other/context_test.rb index 2a17e24..65f84b3 100644 --- a/test/other/context_test.rb +++ b/test/other/context_test.rb @@ -64,10 +64,15 @@ class ContextTest < Test::Unit::TestCase # :nodoc: end end - should_eventually "should pass, since it's unimplemented" do + should_eventually "pass, since it's unimplemented" do flunk "what?" end + + should_eventually "not require a block when using should_eventually" + should "pass without a block, as that causes it to piggyback to should_eventually" - should_eventually "should not require a block when using should_eventually" - should "should pass without a block, as that causes it to piggyback to should_eventually" + context "context for testing should piggybacking" do + # I do not think this works inside a context + should "call should_eventually as we are not passing a block" + end end