webmock 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +7 -0
- data/README.md +1 -0
- data/lib/webmock/request_pattern.rb +4 -0
- data/lib/webmock/stub_request_snippet.rb +3 -3
- data/lib/webmock/util/headers.rb +15 -0
- data/lib/webmock/version.rb +1 -1
- data/spec/unit/request_signature_snippet_spec.rb +2 -2
- data/spec/unit/stub_request_snippet_spec.rb +15 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9824be80903ce63b7e2f3a3b61c5924ba3d884ff
|
4
|
+
data.tar.gz: 4666fd52ab43ddd61feabf9b53b565b332d56d17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e1a7c45d9e2ae020ebb116edcd3d52b529df4a29495f0539f234738f34dff65d2e38c45de3a2361cb203be364c94d1e1eebd88ccbdaac27d0c0ed15e7f614c
|
7
|
+
data.tar.gz: 421aca9b146365fa1f0c6425435620b290323e10230acdf39fe6b572fc3072aad7bca874243176b4cf03a39eb4ed239a3063b640f2abe3e7ebf9e6b15fb44785
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1053,6 +1053,7 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
1053
1053
|
* Olia Kremmyda
|
1054
1054
|
* Michał Matyas
|
1055
1055
|
* Matt Brictson
|
1056
|
+
* Olia Kremmyda
|
1056
1057
|
|
1057
1058
|
For a full list of contributors you can visit the
|
1058
1059
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
@@ -16,13 +16,13 @@ module WebMock
|
|
16
16
|
with = "".dup
|
17
17
|
|
18
18
|
if (request_pattern.body_pattern)
|
19
|
-
with << "body: #{request_pattern.body_pattern.to_s}"
|
19
|
+
with << "\n body: #{request_pattern.body_pattern.to_s}"
|
20
20
|
end
|
21
21
|
|
22
22
|
if (request_pattern.headers_pattern)
|
23
|
-
with << ",\n
|
23
|
+
with << ",\n " unless with.empty?
|
24
24
|
|
25
|
-
with << "headers: #{request_pattern.headers_pattern.
|
25
|
+
with << " headers: #{request_pattern.headers_pattern.pp_to_s}"
|
26
26
|
end
|
27
27
|
string << ".\n with(#{with})" unless with.empty?
|
28
28
|
if with_response
|
data/lib/webmock/util/headers.rb
CHANGED
@@ -34,6 +34,21 @@ module WebMock
|
|
34
34
|
str << '}'
|
35
35
|
end
|
36
36
|
|
37
|
+
def self.pp_headers_string(headers)
|
38
|
+
headers = WebMock::Util::Headers.normalize_headers(headers)
|
39
|
+
seperator = "\n\t "
|
40
|
+
str = "{#{seperator} ".dup
|
41
|
+
str << headers.map do |k,v|
|
42
|
+
v = case v
|
43
|
+
when Regexp then v.inspect
|
44
|
+
when Array then "["+v.map{|w| "'#{w.to_s}'"}.join(", ")+"]"
|
45
|
+
else "'#{v.to_s}'"
|
46
|
+
end
|
47
|
+
"'#{k}'=>#{v}"
|
48
|
+
end.sort.join(",#{seperator} ")
|
49
|
+
str << "\n }"
|
50
|
+
end
|
51
|
+
|
37
52
|
def self.decode_userinfo_from_header(header)
|
38
53
|
header.sub(/^Basic /, "").unpack("m").first
|
39
54
|
end
|
data/lib/webmock/version.rb
CHANGED
@@ -60,7 +60,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
|
|
60
60
|
result = subject.request_stubs
|
61
61
|
result.sub!("registered request stubs:\n\n", "")
|
62
62
|
expect(result).to eq(
|
63
|
-
"stub_request(:get, \"https://www.example.com/\").\n with(body: {\"a\"=>\"b\"})"
|
63
|
+
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: {\"a\"=>\"b\"})"
|
64
64
|
)
|
65
65
|
end
|
66
66
|
|
@@ -74,7 +74,7 @@ RSpec.describe WebMock::RequestSignatureSnippet do
|
|
74
74
|
result = subject.request_stubs
|
75
75
|
result.sub!("registered request stubs:\n\n", "")
|
76
76
|
expect(result).to eq(
|
77
|
-
"stub_request(:get, \"https://www.example.com/\").\n with(body: {\"a\"=>\"b\"})\n\nBody diff:\n [[\"-\", \"key\", \"different value\"], [\"+\", \"a\", \"b\"]]\n"
|
77
|
+
"stub_request(:get, \"https://www.example.com/\").\n with(\n body: {\"a\"=>\"b\"})\n\nBody diff:\n [[\"-\", \"key\", \"different value\"], [\"+\", \"a\", \"b\"]]\n"
|
78
78
|
)
|
79
79
|
end
|
80
80
|
end
|
@@ -16,7 +16,7 @@ describe WebMock::StubRequestSnippet do
|
|
16
16
|
it "should print stub request snippet with body if available" do
|
17
17
|
@request_signature.body = "abcdef"
|
18
18
|
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
|
19
|
-
"\n with(body: \"abcdef\")." +
|
19
|
+
"\n with(\n body: \"abcdef\")." +
|
20
20
|
"\n to_return(status: 200, body: \"\", headers: {})"
|
21
21
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
22
22
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
@@ -25,7 +25,7 @@ describe WebMock::StubRequestSnippet do
|
|
25
25
|
it "should print stub request snippet with multiline body" do
|
26
26
|
@request_signature.body = "abc\ndef"
|
27
27
|
expected = %Q(stub_request(:get, "http://www.example.com/?a=b&c=d").)+
|
28
|
-
"\n with(body: \"abc\\ndef\")." +
|
28
|
+
"\n with(\n body: \"abc\\ndef\")." +
|
29
29
|
"\n to_return(status: 200, body: \"\", headers: {})"
|
30
30
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
31
31
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
@@ -34,7 +34,7 @@ describe WebMock::StubRequestSnippet do
|
|
34
34
|
it "should print stub request snippet with headers if any" do
|
35
35
|
@request_signature.headers = {'B' => 'b', 'A' => 'a'}
|
36
36
|
expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
|
37
|
-
"\n with(headers: {\'A\'=>\'a\'
|
37
|
+
"\n with( headers: {\n\t\ 'A\'=>\'a\',\n\t \'B\'=>\'b\'\n })." +
|
38
38
|
"\n to_return(status: 200, body: \"\", headers: {})"
|
39
39
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
40
40
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
@@ -44,7 +44,7 @@ describe WebMock::StubRequestSnippet do
|
|
44
44
|
@request_signature.body = "abcdef"
|
45
45
|
@request_signature.headers = {'B' => 'b', 'A' => 'a'}
|
46
46
|
expected = 'stub_request(:get, "http://www.example.com/?a=b&c=d").'+
|
47
|
-
"\n with(body: \"abcdef\",\n
|
47
|
+
"\n with(\n body: \"abcdef\",\n headers: {\n\t \'A\'=>\'a\',\n\t \'B\'=>\'b\'\n })." +
|
48
48
|
"\n to_return(status: 200, body: \"\", headers: {})"
|
49
49
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
50
50
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected)
|
@@ -52,7 +52,7 @@ describe WebMock::StubRequestSnippet do
|
|
52
52
|
|
53
53
|
it "should not print to_return part if not wanted" do
|
54
54
|
expected = 'stub_request(:get, "http://www.example.com/").'+
|
55
|
-
"\n with(body: \"abcdef\")"
|
55
|
+
"\n with(\n body: \"abcdef\")"
|
56
56
|
stub = WebMock::RequestStub.new(:get, "www.example.com").with(body: "abcdef").to_return(body: "hello")
|
57
57
|
expect(WebMock::StubRequestSnippet.new(stub).to_s(false)).to eq(expected)
|
58
58
|
end
|
@@ -68,8 +68,11 @@ describe WebMock::StubRequestSnippet do
|
|
68
68
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
69
69
|
expected = <<-STUB
|
70
70
|
stub_request(:post, "http://www.example.com/").
|
71
|
-
with(
|
72
|
-
|
71
|
+
with(
|
72
|
+
body: {"user"=>{"first_name"=>"Bartosz"}},
|
73
|
+
headers: {
|
74
|
+
\t 'Content-Type'=>'application/x-www-form-urlencoded'
|
75
|
+
}).
|
73
76
|
to_return(status: 200, body: \"\", headers: {})
|
74
77
|
STUB
|
75
78
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
|
@@ -82,8 +85,11 @@ stub_request(:post, "http://www.example.com/").
|
|
82
85
|
@request_stub = WebMock::RequestStub.from_request_signature(@request_signature)
|
83
86
|
expected = <<-STUB
|
84
87
|
stub_request(:post, "http://www.example.com/").
|
85
|
-
with(
|
86
|
-
|
88
|
+
with(
|
89
|
+
body: "#{multipart_form_body}",
|
90
|
+
headers: {
|
91
|
+
\t 'Content-Type'=>'multipart/form-data; boundary=ABC123'
|
92
|
+
}).
|
87
93
|
to_return(status: 200, body: \"\", headers: {})
|
88
94
|
STUB
|
89
95
|
expect(WebMock::StubRequestSnippet.new(@request_stub).to_s).to eq(expected.strip)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Blimke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
398
|
version: '0'
|
399
399
|
requirements: []
|
400
400
|
rubyforge_project: webmock
|
401
|
-
rubygems_version: 2.
|
401
|
+
rubygems_version: 2.6.13
|
402
402
|
signing_key:
|
403
403
|
specification_version: 4
|
404
404
|
summary: Library for stubbing HTTP requests in Ruby.
|