-
Notifications
You must be signed in to change notification settings - Fork 108
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
Support config option to start without ExUnit hooks. #9
Comments
Hi James, Bypass needs ExUnit's |
Okay. I'll have a think about how we could have it work. I'd suggest that we abstract it into separate "drivers" for each test framework. |
Hi @jamesotron, just wanted to check if you found a workaround in the meantime? |
@MSch this is what I did that seems to work against master: before_all do
Application.ensure_all_started(:bypass)
end
let :bypass, do: start_bypass
finally do
case Bypass.Instance.call(bypass.pid, :on_exit) do
:ok ->
:ok
:ok_call ->
:ok
{:error, :not_called} ->
raise ESpec.AssertionError, "No HTTP request arrived at Bypass"
{:error, :unexpected_request} ->
raise ESpec.AssertionError, "Bypass got an HTTP request but wasn't expecting one"
{:exit, {class, reason, stacktrace}} ->
:erlang.raise(class, reason, stacktrace)
end
end
def start_bypass do
case Supervisor.start_child(Bypass.Supervisor, []) do
{:ok, pid} ->
port = Bypass.Instance.call(pid, :port)
%Bypass{pid: pid, port: port}
other ->
other
end
end |
This looks excellent. We are not using espec ourselves, but if you submit a PR on top of #36 we can merge this in. 👍 |
FYI I just released 0.8.0 of bypass with @tompave's ESpec support included ❤️ |
Hi there.
I'm using Bypass with espec. It'd be amazing if it were possible to just call
Bypass.open
without it exploding - I'm currently starting and stopping the bypass supervisor in my test setup and teardown.The text was updated successfully, but these errors were encountered: