@@ -24,11 +24,19 @@ module WebDriver
2424 module Remote
2525 module Http
2626 describe Common do
27- it 'sends non-empty body header for POST requests without command data' do
27+ subject ( :common ) do
2828 common = described_class . new
2929 common . server_url = URI . parse ( 'http://server' )
3030 allow ( common ) . to receive ( :request )
3131
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
3240 common . call ( :post , 'clear' , nil )
3341
3442 expect ( common ) . to have_received ( :request )
@@ -37,17 +45,24 @@ module Http
3745 end
3846
3947 it 'sends a standard User-Agent by default' do
40- common = described_class . new
41- common . server_url = URI . parse ( 'http://server' )
4248 user_agent_regexp = %r{\A selenium/#{ WebDriver ::VERSION } \( ruby #{ Platform . os } \) \z }
43- allow ( common ) . to receive ( :request )
4449
4550 common . call ( :post , 'session' , nil )
4651
4752 expect ( common ) . to have_received ( :request )
4853 . with ( :post , URI . parse ( 'http://server/session' ) ,
4954 hash_including ( 'User-Agent' => a_string_matching ( user_agent_regexp ) ) , '{}' )
5055 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
5166 end
5267 end # Http
5368 end # Remote
0 commit comments