Skip to content

Commit

Permalink
[ruby] fix FrozenError: can't modify frozen String exception
Browse files Browse the repository at this point in the history
  • Loading branch information
camelmasa authored and p0deje committed May 28, 2019
1 parent f8ce3f9 commit b9830bc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/firefox/binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def path
@path = Platform.cygwin_path(@path, windows: true) if Platform.cygwin?

unless File.file?(@path.to_s)
error = "Could not find Firefox binary (os=#{Platform.os}). "
error << "Make sure Firefox is installed or set the path manually with #{self}.path="
error = "Could not find Firefox binary (os=#{Platform.os}). " \
"Make sure Firefox is installed or set the path manually with #{self}.path="
raise Error::WebDriverError, error
end

Expand Down
38 changes: 38 additions & 0 deletions rb/spec/unit/selenium/webdriver/firefox/binary_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require File.expand_path('../spec_helper', __dir__)

module Selenium
module WebDriver
module Firefox
describe Binary do
describe ".path" do
context "when could't find binary file" do
it 'raises Selenium::WebDriver::Error::WebDriverError' do
expect(File).to receive(:file?).and_return(false)

expect { Binary.path }.to raise_error(Selenium::WebDriver::Error::WebDriverError)
end
end
end
end
end # Firefox
end # WebDriver
end # Selenium

0 comments on commit b9830bc

Please sign in to comment.