diff --git a/spec/support/downloads.rb b/spec/support/downloads.rb index ec2d15240..7dabe5b76 100644 --- a/spec/support/downloads.rb +++ b/spec/support/downloads.rb @@ -1,18 +1,17 @@ # frozen_string_literal: true module Downloads - TIMEOUT = Capybara.default_max_wait_time - PATH = Rails.root.join("tmp/downloads") + PATH = Rails.root.join("tmp/downloads") class << self def clear FileUtils.rm_f(downloads) end - def content_for(filename) - wait_for_download(filename) - - File.read(PATH.join(filename)) + def content_for(page, filename) + page.document.synchronize(errors: [Errno::ENOENT]) do + File.read(PATH.join(filename)) + end end private @@ -20,14 +19,6 @@ def content_for(filename) def downloads Dir[PATH.join("*")] end - - def wait_for_download(filename) - Timeout.timeout(TIMEOUT) { sleep(0.1) until downloaded?(filename) } - end - - def downloaded?(filename) - File.exist?(PATH.join(filename)) - end end end diff --git a/spec/system/export_spec.rb b/spec/system/export_spec.rb index 364176d46..4e1f4109a 100644 --- a/spec/system/export_spec.rb +++ b/spec/system/export_spec.rb @@ -7,7 +7,7 @@ click_on "Export" - xml = Capybara.string(Downloads.content_for("stringer.opml")) + xml = Capybara.string(Downloads.content_for(page, "stringer.opml")) expect(xml).to have_css("outline[title='#{feed.name}']") end end