Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed May 16, 2024
1 parent af1334a commit ef02ebf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/req/test_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ defmodule Req.TestTest do

test "module" do
defmodule Foo do
def init(options), do: options
def call(conn, []), do: Plug.Conn.send_resp(conn, 200, "hi")
def init([]), do: "default"
def init(other), do: other
def call(conn, string), do: Plug.Conn.send_resp(conn, 200, string)
end

Req.Test.stub(:foo, Foo)
assert Req.get!(plug: {Req.Test, :foo}).body == "default"

Req.Test.stub(:foo, {Foo, "hi"})
assert Req.get!(plug: {Req.Test, :foo}).body == "hi"
end
end
Expand Down

0 comments on commit ef02ebf

Please sign in to comment.