diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 18:09:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 18:09:42 +0300 |
commit | a99d0fa6922be88307b1c80330a257c55c5d8270 (patch) | |
tree | 948c3d8d846bfa5ef2fd17c84cee467d678e6f1b /spec/support_specs | |
parent | 077b0a79d52753d020280ed8d58f97f8207b42de (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support_specs')
-rw-r--r-- | spec/support_specs/capybara_slow_finder_spec.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/support_specs/capybara_slow_finder_spec.rb b/spec/support_specs/capybara_slow_finder_spec.rb new file mode 100644 index 00000000000..cba75a7fba2 --- /dev/null +++ b/spec/support_specs/capybara_slow_finder_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Capybara::Node::Base::SlowFinder do # rubocop:disable RSpec/FilePath + context 'without timeout' do + context 'when element is found' do + let(:slow_finder) do + Class.new do + def synchronize(seconds = nil, errors: nil) + true + end + + prepend Capybara::Node::Base::SlowFinder + end.new + end + + it 'does not raise error' do + expect { slow_finder.synchronize }.not_to raise_error + end + end + + context 'when element is not found' do + let(:slow_finder) do + Class.new do + def synchronize(seconds = nil, errors: nil) + raise Capybara::ElementNotFound + end + + prepend Capybara::Node::Base::SlowFinder + end.new + end + + it 'raises Capybara::ElementNotFound error' do + expect { slow_finder.synchronize }.to raise_error(Capybara::ElementNotFound) + end + end + end + + context 'with timeout' do + let(:slow_finder) do + Class.new do + def synchronize(seconds = nil, errors: nil) + sleep 0.1 + + raise Capybara::ElementNotFound + end + + prepend Capybara::Node::Base::SlowFinder + end.new + end + + it 'raises a timeout error' do + expect { slow_finder.synchronize(0.01) }.to raise_error( + Capybara::ElementNotFound, + /Timeout reached while running a waiting Capybara finder./ + ) + end + end +end |