-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathbitly_test.rb
26 lines (22 loc) · 933 Bytes
/
bitly_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require_relative "test_helper"
require "net/http"
class BitlyTest < Minitest::Test
def test_connect
Bitly::API.send(:remove_const, "BASE_URL")
Bitly::API.const_set("BASE_URL", URI(connect_url))
assert_timeout(Net::OpenTimeout) do
adapter = Bitly::HTTP::Adapters::NetHTTP.new(request_opts: { open_timeout: 1 })
http_client = Bitly::HTTP::Client.new(adapter)
Bitly::API::Client.new(token: "123", http: http_client).shorten(long_url: "http://bit.ly/wQaT")
end
end
def test_read
Bitly::API.send(:remove_const, "BASE_URL")
Bitly::API.const_set("BASE_URL", URI(read_url))
assert_timeout(Net::ReadTimeout) do
adapter = Bitly::HTTP::Adapters::NetHTTP.new(request_opts: { read_timeout: 1, use_ssl: false })
http_client = Bitly::HTTP::Client.new(adapter)
Bitly::API::Client.new(token: "123", http: http_client).shorten(long_url: "http://bit.ly/wQaT")
end
end
end