-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
safe option to around
?
#32
Comments
I might have run into that a few times ... can you make a PR with a failing
test-case ?
…On Thu, Nov 8, 2018 at 1:02 PM Josh Bodah ***@***.***> wrote:
I've been using around to run encapsulate some code that ran in
begin...ensure blocks. Errors in teardown's however are caught by
Minitest and thus the resulting ensure never runs
This feels unexpected to me. I haven't dug into it too much but my gut
tells me this is because of the use of Fibers and not ensure'ing the
Fiber yield
require 'test_helper'
class HelloTest < Minitest::Spec
around do |block|
begin
block.call
ensure
puts "it worked!"
end
end
after do
raise "woops"
end
it "works" do
assert true
endend
With output:
# Running tests with run options --seed 8681:
E
Error:
HelloTest#test_0001_works:
RuntimeError: woops
/Users/jbodah/repos/cg-ruby-sem/test/unit/hello_test.rb:13:in `block in <class:HelloTest>'
Finished tests in 0.002105s, 475.0594 tests/s, 475.0594 assertions/s.
Slowest tests:
0.000083s test_0001_works#HelloTest
1 tests, 1 assertions, 0 failures, 1 errors, 0 skips
Coverage report generated for Unit Tests to /Users/jbodah/repos/cg-ruby-sem/artifacts/coverage. 439 / 1053 LOC (41.69%) covered.
rake aborted!
Command failed with status (1)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#32>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAAsZ1n9FOc898L5VjOfNI5zSDkswlrqks5utJwAgaJpZM4YVerf>
.
|
Sure - I just dug into it a bit; the issue is actually the resume guard clause: From: /usr/local/bundle/gems/minitest-around-0.4.1/lib/minitest/around/spec.rb @ line 23 self.around:
18: raise
19: end
20: end
21: fib.resume(self, lambda { Fiber.yield })
22: end
=> 23: after { fib.resume unless fib == :failed }
24: end
25:
26: # Minitest does not support multiple before/after blocks
27: remove_method :before
28: def before(type=nil, &block)
[1] pry(#<MsnAccountSyncTest>)> fib == :failed
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been using
around
to run encapsulate some code that ran inbegin...ensure
blocks. Errors inteardown
's however are caught by Minitest and thus the resultingensure
never runsThis feels unexpected to me. I haven't dug into it too much but my gut tells me this is because of the use of Fibers and not
ensure
'ing the Fiber yieldWith output:
The text was updated successfully, but these errors were encountered: