Skip to content

Commit 35827eb

Browse files
committed
[rb] Fix DevTools old version loader spec
1 parent 440a388 commit 35827eb

4 files changed

Lines changed: 63 additions & 26 deletions

File tree

rb/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
selenium-devtools (0.112.0)
4+
selenium-devtools (0.113.0)
55
selenium-webdriver (~> 4.2)
66
selenium-webdriver (4.9.0)
77
rexml (~> 3.2, >= 3.2.5)

rb/spec/integration/selenium/webdriver/devtools_spec.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,6 @@ module WebDriver
3535
expect(driver.devtools.dom_debugger).not_to be_nil
3636
end
3737

38-
context 'when the devtools version is too high' do
39-
let(:existing_devtools_version) { driver.send(:devtools_version) }
40-
let(:imaginary_devtools_version) { existing_devtools_version + 1 }
41-
42-
before do
43-
# set the devtools version to a newer one than exists
44-
allow(driver).to receive(:devtools_version).and_return(imaginary_devtools_version)
45-
46-
# forget what the actual version was
47-
Selenium::DevTools.remove_instance_variable(:@version)
48-
end
49-
50-
it 'can fall back to an older devtools if necessary' do
51-
expect { driver.devtools }
52-
.to output(
53-
a_string_matching(
54-
/
55-
Could\ not\ load\ selenium-devtools\ v#{imaginary_devtools_version}.\ Trying\ older\ versions.\n
56-
Using\ selenium-devtools\ version\ v\d+,\ some\ features\ may\ not\ work\ as\ expected.\n
57-
/x
58-
)
59-
).to_stderr
60-
end
61-
end
62-
6338
it 'supports events', except: {browser: :firefox,
6439
reason: 'https://bugzilla.mozilla.org/show_bug.cgi?id=1819965'} do
6540
expect { |block|

rb/spec/unit/selenium/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ load("@rules_ruby//ruby:defs.bzl", "rb_test")
22

33
package(default_visibility = ["//rb:__subpackages__"])
44

5+
rb_test(
6+
name = "devtools",
7+
srcs = ["devtools_spec.rb"],
8+
args = ["rb/spec/"],
9+
main = "@bundle//:bin/rspec",
10+
tags = ["no-sandbox"],
11+
deps = [
12+
"//rb/lib/selenium:devtools",
13+
"@bundle",
14+
],
15+
)
16+
517
rb_test(
618
name = "server",
719
srcs = ["server_spec.rb"],
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
# Licensed to the Software Freedom Conservancy (SFC) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The SFC licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
require File.expand_path('webdriver/spec_helper', __dir__)
21+
require 'selenium/devtools'
22+
23+
module Selenium
24+
describe DevTools do
25+
describe '.load_version' do
26+
let(:current_version) { Gem::Version.new(Selenium::DevTools::VERSION).segments[1] }
27+
28+
around do |example|
29+
described_class.version = version
30+
example.call
31+
ensure
32+
described_class.version = nil
33+
end
34+
35+
context 'when the version is too high' do
36+
let(:version) { current_version + 1 }
37+
38+
it 'can fall back to an older devtools if necessary' do
39+
expect { described_class.load_version }
40+
.to output(
41+
a_string_including(<<~MSG)
42+
Could not load selenium-devtools v#{version}. Trying older versions.
43+
Using selenium-devtools version v#{current_version}, some features may not work as expected.
44+
MSG
45+
).to_stderr
46+
end
47+
end
48+
end
49+
end # DevTools
50+
end # Selenium

0 commit comments

Comments
 (0)