@@ -23,47 +23,31 @@ module Selenium
23
23
module WebDriver
24
24
module Safari
25
25
describe Bridge do
26
- let ( :server ) { double ( Server , receive : response ) . as_null_object }
27
- let ( :browser ) { double ( Browser ) . as_null_object }
28
-
29
- let :response do
30
- {
31
- 'id' => '1' ,
32
- 'response' => {
33
- 'sessionId' => 'opaque' , 'value' => @default_capabilities ,
34
- 'status' => 0
35
- }
36
- }
37
- end
26
+ let ( :http ) { double ( Remote ::Http ::Default , call : resp ) . as_null_object }
27
+ let ( :resp ) { { 'sessionId' => 'foo' , 'value' => @default_capabilities } }
28
+ let ( :service ) { double ( Service , start : true , uri : 'http://example.com' ) }
29
+ let ( :caps ) { { } }
38
30
39
31
before do
40
32
@default_capabilities = Remote ::Capabilities . safari . as_json
41
33
42
- allow ( Server ) . to receive ( :new ) . and_return ( server )
43
- allow ( Browser ) . to receive ( :new ) . and_return ( browser )
34
+ allow ( Safari ) . to receive ( :driver_path ) . and_return ( '/foo' )
35
+ allow ( Remote ::Capabilities ) . to receive ( :safari ) . and_return ( caps )
36
+ allow ( Service ) . to receive ( :new ) . and_return ( service )
44
37
end
45
38
46
39
it 'takes desired capabilities' do
47
40
custom_caps = Remote ::Capabilities . new
48
41
custom_caps [ 'foo' ] = 'bar'
49
42
50
- expect ( server ) . to receive ( :send ) do |payload |
51
- expect ( payload [ :command ] [ :parameters ] [ :desiredCapabilities ] [ 'foo' ] ) . to eq ( 'bar' )
43
+ expect ( http ) . to receive ( :call ) do |_ , _ , payload |
44
+ expect ( payload [ :desiredCapabilities ] [ 'foo' ] ) . to eq 'bar'
45
+ resp
52
46
end
53
47
54
- Bridge . new ( desired_capabilities : custom_caps )
48
+ Bridge . new ( http_client : http , desired_capabilities : custom_caps )
55
49
end
56
50
57
- it 'lets direct arguments take presedence over capabilities' do
58
- custom_caps = Remote ::Capabilities . new
59
- custom_caps [ 'cleanSession' ] = false
60
-
61
- expect ( server ) . to receive ( :send ) do |payload |
62
- expect ( payload [ :command ] [ :parameters ] [ :desiredCapabilities ] [ 'safari.options' ] [ 'cleanSession' ] ) . to eq ( true )
63
- end
64
-
65
- Bridge . new ( clean_session : true )
66
- end
67
51
end
68
52
end # Safari
69
53
end # WebDriver
0 commit comments