Skip to content

Commit 6135b68

Browse files
committed
Modernize specs and add spec for remote website.
1 parent 0e69cf3 commit 6135b68

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

spec/async/http/faraday/adapter_spec.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
require 'async/http/faraday'
2222
require 'async/http/server'
2323
require 'async/http/endpoint'
24-
require 'async/reactor'
24+
25+
require 'async'
2526

2627
RSpec.describe Async::HTTP::Faraday::Adapter do
2728
let(:endpoint) {
@@ -35,21 +36,34 @@
3536

3637
server = Async::HTTP::Server.new(app, endpoint)
3738

38-
Async::Reactor.run do |task|
39+
Async do |task|
3940
server_task = task.async do
4041
server.run
4142
end
4243

43-
conn = Faraday.new(:url => endpoint.url) do |faraday|
44+
connection = Faraday.new(:url => endpoint.url) do |faraday|
4445
faraday.response :logger
4546
faraday.adapter :async_http
4647
end
4748

48-
response = conn.get("/index")
49+
response = connection.get("/index")
4950

5051
expect(response.body).to be == "Hello World"
5152

5253
server_task.stop
5354
end
5455
end
56+
57+
it "can get remote resource" do
58+
Async do |task|
59+
connection = Faraday.new(:url => "http://www.google.com") do |faraday|
60+
faraday.response :logger
61+
faraday.adapter :async_http
62+
end
63+
64+
response = connection.get("/search?q=cats")
65+
66+
expect(response).to be_success
67+
end
68+
end
5569
end

0 commit comments

Comments
 (0)