Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Add failing tests for url that needs to be stripped
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Sep 12, 2017
1 parent c867555 commit 5d89cf1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/service_test.rb
Expand Up @@ -120,6 +120,33 @@ def test_http_only_with_prefix_and_fqdn
end
end

def test_http_get_url_strip
stubs = Faraday::Adapter::Test::Stubs.new
stubs.get("/") { |env| [200, {}, "ok"] }
stubs.get("/ ") { |env| [200, {}, "nope"] }

service = TestService.new(:push, "data", "payload")
service.http :adapter => [:test, stubs]

service.http_get "https://example.com/ "
http_call = service.http_calls[0]
assert_equal "https://example.com/", http_call[:request][:url]
assert_equal "ok", http_call[:response][:body]
end

def test_http_post_url_strip
stubs = Faraday::Adapter::Test::Stubs.new
stubs.post("/") { |env| [200, {}, "ok"] }
stubs.post("/ ") { |env| [200, {}, "nope"] }

service = TestService.new(:push, "data", "payload")
service.http :adapter => [:test, stubs]

service.http_post "https://example.com/ "
http_call = service.http_calls[0]
assert_equal "https://example.com/", http_call[:request][:url]
assert_equal "ok", http_call[:response][:body]
end

def test_json_encoding
payload = {'unicodez' => "rtiaü\n\n€ý5:q"}
Expand Down

0 comments on commit 5d89cf1

Please sign in to comment.