Skip to content

Commit

Permalink
add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Jul 29, 2024
1 parent d3cfbf4 commit e986c70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/integration/resource_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ describe Crest::Response do
body["path"].should eq("/get")
end

it "do GET request with nested path" do
resource = Crest::Resource.new("#{TEST_SERVER_URL}/foo")
response = resource.get("bar")

body = JSON.parse(response.body)

body["path"].should eq("/foo/bar")
end

it "do GET request with []" do
site = Crest::Resource.new("#{TEST_SERVER_URL}")
response = site["/get"].get
Expand Down
2 changes: 2 additions & 0 deletions spec/support/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ server = HTTP::Server.new([HTTP::BasicAuthHandler.new("username", "password")])
context.response.print render_response(context)
when "/delete"
context.response.print render_response(context)
when "/foo/bar"
context.response.print render_response(context)
when "/404"
context.response.respond_with_status(:not_found, "404 error")
when "/500"
Expand Down

0 comments on commit e986c70

Please sign in to comment.