Skip to content

Commit

Permalink
fix acceptance tests for all http verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Oct 17, 2024
1 parent a8b3a5c commit e8852ee
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions script/acceptance_tests/tests.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@ require "spec"
describe "All HTTP Methods" do
["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"].each do |method|
it "successfully validates a #{method} request" do
client = Kemal::Hmac::Client.new("my_standard_client", "my_secret_2")
hmac_client = Kemal::Hmac::Client.new("my_standard_client", "my_secret_2")

path = "/catch-all"

headers = HTTP::Headers.new
client.generate_headers(path).each do |key, value|
hmac_client.generate_headers(path).each do |key, value|
headers.add(key, value)
end

response = HTTP::Client.get("http://localhost:3000#{path}", headers: headers)

request = HTTP::Request.new(
method,
"/api",
path,
headers: headers,
)

uri = URI.parse("http://localhost:3000")
http_client = HTTP::Client.new(uri)

response = http_client.exec(request)

response.status_code.should eq 200
response.body.should contain "Hi, my_standard_client!"
response.body.should contain "Hi, my_standard_client! Welcome to catch-all"
end
end
end
Expand Down

0 comments on commit e8852ee

Please sign in to comment.