Only expand the path if not already absolute

This commit is contained in:
Thomas Walpole 2019-07-12 15:40:35 -07:00
parent 03052637e5
commit 482dfb35e3
2 changed files with 6 additions and 1 deletions

View File

@ -300,7 +300,10 @@ private
def set_file(value) # rubocop:disable Naming/AccessorMethodName
path_names = value.to_s.empty? ? [] : value
native.send_keys(Array(path_names).map(&File.method(:expand_path)).join("\n"))
file_names = Array(path_names).map do |pn|
Pathname.new(pn).absolute? ? pn : File.expand_path(pn)
end.join("\n")
native.send_keys(file_names)
end
def set_content_editable(value) # rubocop:disable Naming/AccessorMethodName

View File

@ -323,6 +323,8 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
end
it 'can attach a relative file' do
pending 'Geckdoriver on windows requires alternate file separator which path expansion replaces' if Gem.win_platform? && firefox?(session)
session.visit('/form')
session.attach_file('Single Document', 'spec/fixtures/capybara.csv')
session.click_button('Upload Single')