DEV Community

Vasily Polovnyov
Vasily Polovnyov

Posted on

Quick tip: stub requests to unix sockets

Sometimes, an application communicates with an external service not via Internet sockets, but via unix sockets:

Excon.get("unix:///ping", socket: "/tmp/unicorn.sock")
Enter fullscreen mode Exit fullscreen mode

To stub requests like this in tests, use Webmock:

stub_request(:get, "http://unix/ping").to_return(status: 200)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)