Skip to content

Commit 0e9519c

Browse files
authored
Merge branch 'master' into fix-version-checking
2 parents f6ed904 + 0771fbc commit 0e9519c

25 files changed

+151
-39
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,27 @@ jobs:
1414
matrix:
1515
ruby:
1616
- head
17+
- '3.2'
1718
- '3.1'
1819
- '3.0'
1920
- '2.7'
2021
- '2.6'
21-
- '2.5'
2222
- jruby
2323
continue-on-error: ${{ matrix.ruby == 'head' }}
2424
name: Ruby ${{ matrix.ruby }}
2525
env:
2626
JRUBY_OPTS: "--debug"
2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
2929
- name: Install Apt Packages
3030
run: |
3131
sudo apt-get install libcurl4-openssl-dev -y
3232
- uses: ruby/setup-ruby@v1
33-
continue-on-error: true
33+
continue-on-error: false
3434
with:
3535
ruby-version: ${{ matrix.ruby }}
3636
bundler-cache: true
37+
rubygems: 'latest'
38+
bundler: 'latest'
3739
- run: |
3840
bundle exec rake

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ WebMock
44
[![Build Status](https://github.com/bblimke/webmock/workflows/CI/badge.svg?branch=master)](https://github.com/bblimke/webmock/actions)
55
[![Code Climate](https://codeclimate.com/github/bblimke/webmock/badges/gpa.svg)](https://codeclimate.com/github/bblimke/webmock)
66
[![Mentioned in Awesome Ruby](https://awesome.re/mentioned-badge.svg)](https://github.com/markets/awesome-ruby)
7-
[![Inline docs](http://inch-ci.org/github/bblimke/webmock.svg?branch=master)](http://inch-ci.org/github/bblimke/webmock)
8-
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=webmock&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=webmock&package-manager=bundler&version-scheme=semver)
97

108
Library for stubbing and setting expectations on HTTP requests in Ruby.
119

@@ -40,12 +38,12 @@ Supported HTTP libraries
4038

4139
Supported Ruby Interpreters
4240
---------------------------
43-
44-
* MRI 2.5
4541
* MRI 2.6
4642
* MRI 2.7
43+
* MRI 3.0
44+
* MRI 3.1
45+
* MRI 3.2
4746
* JRuby
48-
* Rubinius
4947

5048
## Installation
5149

@@ -540,7 +538,7 @@ RestClient.get('www.example.org:8080', '/') # ===> Allowed
540538
With a `Regexp` matching the URI:
541539

542540
```ruby
543-
WebMock.disable_net_connect!(allow: %r{ample.org/foo})
541+
WebMock.disable_net_connect!(allow: %r{ample\.org/foo})
544542

545543
RestClient.get('www.example.org', '/foo/bar') # ===> Allowed
546544
RestClient.get('sample.org', '/foo') # ===> Allowed

lib/webmock/http_lib_adapters/em_http_request_adapter.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup(response, uri, error = nil)
101101

102102
def connection_completed
103103
@state = :response_header
104-
send_request(request_signature.headers, request_signature.body)
104+
send_request(*headers_and_body_processed_by_middleware)
105105
end
106106

107107
def send_request(head, body)
@@ -168,12 +168,18 @@ def build_webmock_response
168168
webmock_response
169169
end
170170

171-
def build_request_signature
172-
headers, body = build_request, @req.body
173-
174-
@conn.middleware.select {|m| m.respond_to?(:request) }.each do |m|
175-
headers, body = m.request(self, headers, body)
171+
def headers_and_body_processed_by_middleware
172+
@headers_and_body_processed_by_middleware ||= begin
173+
head, body = build_request, @req.body
174+
@conn.middleware.each do |m|
175+
head, body = m.request(self, head, body) if m.respond_to?(:request)
176+
end
177+
[head, body]
176178
end
179+
end
180+
181+
def build_request_signature
182+
headers, body = headers_and_body_processed_by_middleware
177183

178184
method = @req.method
179185
uri = @req.uri.clone

lib/webmock/request_pattern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def matches?(body, content_type = "")
283283
matching_body_hashes?(body_as_hash(body, content_type), @pattern, content_type)
284284
elsif (@pattern).is_a?(Array)
285285
matching_body_array?(body_as_hash(body, content_type), @pattern, content_type)
286-
elsif (@pattern).is_a?(WebMock::Matchers::HashIncludingMatcher)
286+
elsif (@pattern).is_a?(WebMock::Matchers::HashArgumentMatcher)
287287
@pattern == body_as_hash(body, content_type)
288288
else
289289
empty_string?(@pattern) && empty_string?(body) ||

lib/webmock/util/version_checker.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def compare_version
8686
when @major < @min_major then :too_low
8787
when @major == @min_major && @minor < @min_minor then :too_low
8888
when @major == @min_major && @minor == @min_minor && @patch < @min_patch then :too_low
89-
9089
when @max_major && @major > @max_major then :too_high
9190
when @max_major && @major == @max_major && @max_minor && @minor > @max_minor then :too_high
9291

minitest/test_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require 'minitest/autorun'
1111
require 'webmock/minitest'
1212

13-
test_class = defined?(MiniTest::Test) ? MiniTest::Test : MiniTest::Unit::TestCase
13+
test_class = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
1414

1515
test_class.class_eval do
1616

@@ -28,7 +28,7 @@ def assert_raise_with_message(e, message, &block)
2828
end
2929

3030
def assert_fail(message, &block)
31-
assert_raise_with_message(MiniTest::Assertion, message, &block)
31+
assert_raise_with_message(Minitest::Assertion, message, &block)
3232
end
3333

3434
end

minitest/test_webmock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
22
require File.expand_path(File.dirname(__FILE__) + '/../test/shared_test')
33

4-
test_class = defined?(MiniTest::Test) ? MiniTest::Test : MiniTest::Unit::TestCase
4+
test_class = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
55

66

77
class MiniTestWebMock < test_class

spec/acceptance/async_http_client/async_http_client_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
require 'acceptance/webmock_shared'
44
require_relative './async_http_client_spec_helper'
55

6-
require 'protocol/http/body/file'
6+
unless RUBY_PLATFORM =~ /java/
7+
require 'protocol/http/body/file'
78

8-
Async.logger.debug! if ENV['ASYNC_LOGGER_DEBUG']
9+
Async.logger.debug! if ENV['ASYNC_LOGGER_DEBUG']
910

10-
unless RUBY_PLATFORM =~ /java/
1111
describe 'Async::HTTP::Client' do
1212
include AsyncHttpClientSpecHelper
1313

spec/acceptance/async_http_client/async_http_client_spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def connection_refused_exception_class
4444
Errno::ECONNREFUSED
4545
end
4646

47+
def connection_error_class
48+
HTTP::ConnectionError
49+
end
50+
4751
def http_library
4852
:async_http_client
4953
end

spec/acceptance/curb/curb_spec_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def setup_request(uri, curl, options={})
3737
curl.password = options[:basic_auth][1]
3838
end
3939
curl.timeout = 30
40-
curl.connect_timeout = 30
40+
curl.connect_timeout = 5
4141

4242
if headers = options[:headers]
4343
headers.each {|k,v| curl.headers[k] = v }
@@ -54,6 +54,9 @@ def connection_refused_exception_class
5454
Curl::Err::ConnectionFailedError
5555
end
5656

57+
def connection_error_class
58+
end
59+
5760
def http_library
5861
:curb
5962
end

0 commit comments

Comments
 (0)