Skip to content

Commit

Permalink
Avoid hiding assertion failures in teardown.
Browse files Browse the repository at this point in the history
We don’t need to use a generalized `eventually` which listens for assertion errors in teardown, as we know what we are waiting for.
  • Loading branch information
tobiashm committed Nov 17, 2013
1 parent 3a5b296 commit eb133bb
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions spec/promises_aplus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,18 @@ def setup
end

def teardown
eventually { @done.must_equal true }
end

def done!
@done = true
end

def eventually(&block)
time_limit = Time.now + 2
loop do
begin
yield
rescue Minitest::Assertion => error
end
return if error.nil?
raise error if Time.now >= time_limit
return if @done == true
raise Minitest::Assertion.new("`done` was never called") if Time.now >= time_limit
sleep 0.05
end
end

def done!
@done = true
end

def self.test_fulfilled(base, value, &test)
base.it "already-fulfilled" do
test.call(resolved(value), method(:done!))
Expand Down

0 comments on commit eb133bb

Please sign in to comment.