Skip to content

Use the most recent stub of the same url #44

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions spec/webmock_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ describe WebMock do
end
end

it "uses the most recently called stub of the same url" do
WebMock.wrap do
WebMock.stub(:get, "www.example.com").to_return(body: "unu")
WebMock.stub(:get, "www.example.com").to_return(body: "du")

HTTP::Client.get("http://www.example.com").body.should eq("du")
end
end

it "stubs indefinitely" do
WebMock.wrap do
WebMock.stub(:get, "www.example.com").to_return(body: "unu")
Expand Down
2 changes: 1 addition & 1 deletion src/webmock/stub_registry.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct WebMock::StubRegistry

def stub(method, uri)
stub = Stub.new(method, uri)
@stubs << stub
@stubs.unshift(stub)
stub
end

Expand Down