Skip to content

Commit

Permalink
try different monkeypatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jlbyrne committed May 21, 2024
1 parent 00c7aea commit 2d73942
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,34 @@
end

module WebMock
# class RequestPattern
# alias_method :_matches?, :matches?
class RequestPattern
alias_method :_matches?, :matches?

# def matches?(request_signature)
# return if request_signature.uri.host == '127.0.0.1' && request_signature.uri.path == '/__identify__'
# _matches?(request_signature)
# end
# end

def self.net_connect_explicit_allowed?(allowed, uri=nil)
case allowed
when Array
allowed.any? { |allowed_item| net_connect_explicit_allowed?(allowed_item, uri) }
when Regexp
(uri.to_s =~ allowed) != nil ||
(uri.omit(:port).to_s =~ allowed) != nil && uri.port == uri.default_port
when String
allowed == uri.to_s ||
allowed == uri.host ||
allowed == "#{uri.host}:#{uri.port}" ||
allowed == "#{uri.scheme}://#{uri.host}:#{uri.port}" ||
(allowed == uri.omit(:port).to_s && uri.port == uri.default_port)
else
if allowed.respond_to?(:call)
allowed.call(uri)
end
def matches?(request_signature)
return if request_signature.uri.host == '127.0.0.1' && request_signature.uri.path == '/__identify__'
_matches?(request_signature)
end
end

# def self.net_connect_explicit_allowed?(allowed, uri=nil)
# case allowed
# when Array
# allowed.any? { |allowed_item| net_connect_explicit_allowed?(allowed_item, uri) }
# when Regexp
# (uri.to_s =~ allowed) != nil ||
# (uri.omit(:port).to_s =~ allowed) != nil && uri.port == uri.default_port
# when String
# allowed == uri.to_s ||
# allowed == uri.host ||
# allowed == "#{uri.host}:#{uri.port}" ||
# allowed == "#{uri.scheme}://#{uri.host}:#{uri.port}" ||
# (allowed == uri.omit(:port).to_s && uri.port == uri.default_port)
# else
# if allowed.respond_to?(:call)
# allowed.call(uri)
# end
# end
# end
end

module ActiveSupport
Expand Down

0 comments on commit 2d73942

Please sign in to comment.