Sha256: db8866da55abfe49d7f323055037dd8bdf7936a4cc70c06e9e2ff14f556304d0
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
require File.expand_path("../../test_helper", __FILE__) class SearchFlip::HTTPClientTest < SearchFlip::TestCase [:get, :put, :delete, :post, :head].each do |method| define_method :"test_#{method}" do stub_request(method, "http://localhost/path").with(body: "body", query: { key: "value" }).to_return(body: "success") assert_equal "success", SearchFlip::HTTPClient.send(method, "http://localhost/path", body: "body", params: { key: "value" }).body.to_s end end def test_headers stub_request(:get, "http://localhost/path").with(headers: { "X-Key" => "Value" }).to_return(body: "success") assert_equal "success", SearchFlip::HTTPClient.headers("X-Key" => "Value").get("http://localhost/path").body.to_s end def test_connection_error stub_request(:get, "http://localhost/path").to_raise(HTTP::ConnectionError) assert_raises SearchFlip::ConnectionError do SearchFlip::HTTPClient.get("http://localhost/path") end end def test_response_error stub_request(:get, "http://localhost/path").to_return(status: 500) assert_raises SearchFlip::ResponseError do SearchFlip::HTTPClient.get("http://localhost/path") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
search_flip-1.1.0 | test/search_flip/http_client_test.rb |
search_flip-1.0.0 | test/search_flip/http_client_test.rb |