Capybara 2.4.4 will fail silently on Windows when trying to use an otherwise valid (Unix) file path with attach_file.

Based on slash and backslash in Ruby, I put the following in my spec_helper.rb:

USING_WINDOWS = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM=~ /mswin|mingw/))

In some_file_upload_spec.rb:

file_to_attach = File.join(Rails.root, 'spec/fixtures/files/cool_avatar.jpg')
    file_to_attach = file_to_attach.gsub('/', '\\')
page.attach_file('file_input_dom_id', file_to_attach)

77 words. Post tags: Capybara, attach_file, rails, and Windows.

Post content is written by Jason Zerbe and licensed CC BY-NC 3.0.