@@ -24,11 +24,19 @@ module WebDriver
24
24
module Remote
25
25
module Http
26
26
describe Common do
27
- it 'sends non-empty body header for POST requests without command data' do
27
+ subject ( :common ) do
28
28
common = described_class . new
29
29
common . server_url = URI . parse ( 'http://server' )
30
30
allow ( common ) . to receive ( :request )
31
31
32
+ common
33
+ end
34
+
35
+ after do
36
+ described_class . extra_headers = { }
37
+ end
38
+
39
+ it 'sends non-empty body header for POST requests without command data' do
32
40
common . call ( :post , 'clear' , nil )
33
41
34
42
expect ( common ) . to have_received ( :request )
@@ -37,17 +45,24 @@ module Http
37
45
end
38
46
39
47
it 'sends a standard User-Agent by default' do
40
- common = described_class . new
41
- common . server_url = URI . parse ( 'http://server' )
42
48
user_agent_regexp = %r{\A selenium/#{ WebDriver ::VERSION } \( ruby #{ Platform . os } \) \z }
43
- allow ( common ) . to receive ( :request )
44
49
45
50
common . call ( :post , 'session' , nil )
46
51
47
52
expect ( common ) . to have_received ( :request )
48
53
. with ( :post , URI . parse ( 'http://server/session' ) ,
49
54
hash_including ( 'User-Agent' => a_string_matching ( user_agent_regexp ) ) , '{}' )
50
55
end
56
+
57
+ it 'allows registering extra headers' do
58
+ described_class . extra_headers = { 'Foo' => 'bar' }
59
+
60
+ common . call ( :post , 'session' , nil )
61
+
62
+ expect ( common ) . to have_received ( :request )
63
+ . with ( :post , URI . parse ( 'http://server/session' ) ,
64
+ hash_including ( 'Foo' => 'bar' ) , '{}' )
65
+ end
51
66
end
52
67
end # Http
53
68
end # Remote
0 commit comments