-
Notifications
You must be signed in to change notification settings - Fork 579
Expand file tree
/
Copy pathheaders_spec.rb
More file actions
44 lines (33 loc) · 1.5 KB
/
Copy pathheaders_spec.rb
File metadata and controls
44 lines (33 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'
describe WebMock::Util::Headers do
it "should decode_userinfo_from_header handles basic auth" do
authorization_header = "Basic dXNlcm5hbWU6c2VjcmV0"
userinfo = WebMock::Util::Headers.decode_userinfo_from_header(authorization_header)
expect(userinfo).to eq("username:secret")
end
describe "sorted_headers_string" do
it "should return nice string for hash with string values" do
expect(WebMock::Util::Headers.sorted_headers_string({"a" => "b"})).to eq("{'A'=>'b'}")
end
it "should return nice string for hash with array values" do
expect(WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"]})).to eq("{'A'=>['b', 'c']}")
end
it "should return nice string for hash with array values and string values" do
expect(WebMock::Util::Headers.sorted_headers_string({"a" => ["b", "c"], "d" => "e"})).to eq("{'A'=>['b', 'c'], 'D'=>'e'}")
end
end
describe ".normalize_headers" do
it "normalizes capitalization for string header names" do
expect(described_class.normalize_headers({ "foo-BAR-bAz" => "qUx" }))
.to eq({ "Foo-Bar-Baz" => "qUx" })
end
it "stringifies and dasherizes symbol header names" do
expect(described_class.normalize_headers({ foo_bar: "qUx" }))
.to eq({ "Foo-Bar" => "qUx" })
end
it "respects choice of underscores for string header names" do
expect(described_class.normalize_headers({ "foo-BAR_bAz" => "qUx" }))
.to eq({ "Foo-Bar_Baz" => "qUx" })
end
end
end