Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/unit/selenium/webdriver/spec_helper.rb
1864 views
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
begin
21
require 'debug/session'
22
DEBUGGER__::CONFIG[:fork_mode] = :parent
23
DEBUGGER__.open(nonstop: true)
24
rescue LoadError
25
# not supported on JRuby and TruffleRuby
26
end
27
28
require 'rubygems'
29
require 'time'
30
require 'rspec'
31
require 'webmock/rspec'
32
require 'selenium-webdriver'
33
require 'securerandom'
34
require 'pathname'
35
require_relative '../../../rspec_matchers'
36
37
module Selenium
38
module WebDriver
39
module UnitSpecHelper
40
def with_env(hash)
41
hash.each { |k, v| ENV[k.to_s] = v.to_s }
42
yield
43
ensure
44
hash.each_key { |k| ENV.delete(k) }
45
end
46
end
47
end
48
end
49
50
RSpec.configure do |c|
51
c.define_derived_metadata do |meta|
52
meta[:aggregate_failures] = true
53
end
54
Selenium::WebDriver.logger(ignored: :logger_info)
55
56
root = Pathname.new('../../../../../../').realpath(__FILE__)
57
$LOAD_PATH.insert(0, root.join('bazel-bin/rb/lib').to_s) if File.exist?(root.join('bazel-bin/rb/lib'))
58
59
c.include Selenium::WebDriver::UnitSpecHelper
60
61
c.filter_run_when_matching :focus
62
c.run_all_when_everything_filtered = true
63
c.default_formatter = c.files_to_run.count > 1 ? 'progress' : 'doc'
64
65
c.before do
66
# https://github.com/ruby/debug/issues/797
67
allow(File).to receive(:exist?).and_call_original
68
end
69
end
70
71