Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix specs #28

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@
end
end

Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
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 }
16 changes: 6 additions & 10 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 @@ -34,14 +37,7 @@ def mock_server
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