"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/rb/spec/unit/selenium/webdriver/remote/http/common_spec.rb" (17 Feb 2023, 2103 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "common_spec.rb": 4.7.0_vs_4.8.0.

    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('../../spec_helper', __dir__)
   21 
   22 module Selenium
   23   module WebDriver
   24     module Remote
   25       module Http
   26         describe Common do
   27           it 'sends non-empty body header for POST requests without command data' do
   28             common = described_class.new
   29             common.server_url = URI.parse('http://server')
   30             allow(common).to receive(:request)
   31 
   32             common.call(:post, 'clear', nil)
   33 
   34             expect(common).to have_received(:request)
   35               .with(:post, URI.parse('http://server/clear'),
   36                     hash_including('Content-Length' => '2'), '{}')
   37           end
   38 
   39           it 'sends a standard User-Agent by default' do
   40             common = described_class.new
   41             common.server_url = URI.parse('http://server')
   42             user_agent_regexp = %r{\Aselenium/#{WebDriver::VERSION} \(ruby #{Platform.os}\)\z}
   43             allow(common).to receive(:request)
   44 
   45             common.call(:post, 'session', nil)
   46 
   47             expect(common).to have_received(:request)
   48               .with(:post, URI.parse('http://server/session'),
   49                     hash_including('User-Agent' => a_string_matching(user_agent_regexp)), '{}')
   50           end
   51         end
   52       end # Http
   53     end # Remote
   54   end # WebDriver
   55 end # Selenium