Comments (6)
Hi James,
Bypass needs ExUnit's on_exit
callbacks to check if a request actually arrived at the started Plug (and to rethrow an exception that happened). If you can come up with a solution that makes Bypass work with ExUnit as well was espec I'd be happy to merge it. I'm assuming adding an application configuration to tell bypass whether it's running in ExUnit or espec would make sense, what do you think?
from bypass.
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.
from bypass.
Hi @jamesotron, just wanted to check if you found a workaround in the meantime?
from bypass.
@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
from bypass.
This looks excellent. We are not using espec ourselves, but if you submit a PR on top of #36 we can merge this in. 👍
from bypass.
FYI I just released 0.8.0 of bypass with @tompave's ESpec support included ❤️
from bypass.
Related Issues (20)
- Pipe expectations
- Add 'headers' param in expect and expect_once function HOT 1
- Building error with erlang 22 HOT 3
- Update cowlib dependency HOT 3
- Cannot wait (with timeout) for expectations HOT 4
- How to use bypass with Finch? HOT 2
- How to test request timeout with bypass? HOT 2
- Any support for ranch 2.x? HOT 3
- Crash on shutdown in `dispatch_awaiting_callers` HOT 2
- bypass randomly fails with eaddrinuse error
- bypass does not support paths containing ":" HOT 2
- Error initializing bypass HOT 1
- Match on request body HOT 1
- dialyzer issue
- Elixir 1.15 incompatible? HOT 1
- Warning on Elixir 1.16 HOT 3
- Support for bandit instead plug_cowboy HOT 1
- Multiple expect_once HOT 4
- New release? HOT 5
- Move primary documentation out of the README HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bypass.