mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Fixing should piggybacking [#39]
This commit is contained in:
parent
66fc5c31bf
commit
474f099fca
2 changed files with 15 additions and 8 deletions
|
@ -34,14 +34,12 @@ module Thoughtbot
|
|||
# Note: The part before <tt>should</tt> 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)
|
||||
|
|
|
@ -96,10 +96,15 @@ class ContextTest < Test::Unit::TestCase # :nodoc:
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue