Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpep committed Sep 19, 2023
1 parent 63af66a commit aa99635
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
7 changes: 1 addition & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,4 @@
end
end

Dir["./spec/support/**/*.rb"].sort.each do |f|
puts "!!!! rspec support load: #{f}"
require f
end

# Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
18 changes: 6 additions & 12 deletions spec/support/mock_server.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require "net/http"
require "socket"

module Helpers
module MockServer
def mock_server
def mock_server(host, *args)
raise Net::OpenTimeout if host =~ /timeout/

client_socket, server_socket = Socket.pair(:UNIX, :STREAM, 0)

allow(client_socket).to receive(:setsockopt)
Expand Down Expand Up @@ -30,20 +33,11 @@ def mock_server
end


puts "!!! Net::HTTP::VERSION: #{Net::HTTP::VERSION}"

RSpec.configure do |config|
config.include Helpers::MockServer

config.before do
allow(Socket).to receive(:tcp) do |host, *args|
raise Net::OpenTimeout if host =~ /timeout/

mock_server
end

# allow(TCPSocket).to receive(:open).and_wrap_original do |original_method, *args|
# client_socket
# end
allow(Socket).to receive(:tcp, &method(:mock_server))
allow(TCPSocket).to receive(:open, &method(:mock_server))
end
end

0 comments on commit aa99635

Please sign in to comment.