summaryrefslogtreecommitdiff
path: root/test/scheduler/test_http.rb
blob: 82aa73ca3593267ac7288330e29a34c8afb9ecc0 (plain)
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
27
28
# frozen_string_literal: true

require 'net/http'
require 'uri'
require 'openssl'

require 'test/unit'
require_relative 'scheduler'

class TestSchedulerHTTP < Test::Unit::TestCase
  def test_get
    Thread.new do
      scheduler = Scheduler.new
      Thread.current.scheduler = scheduler

      Fiber do
        uri = URI("https://www.ruby-lang.org/en/")

        http = Net::HTTP.new uri.host, uri.port
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        body = http.get(uri.path).body

        assert !body.empty?
      end
    end.join
  end
end