Skip to content

Commit

Permalink
Fix feature tests with webdrivers on (my) ubuntu #216
Browse files Browse the repository at this point in the history
  • Loading branch information
ut committed Feb 10, 2022
1 parent c55c1fb commit 77547e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/helpers/places_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

describe 'image_link' do
it 'it returns an polymorphic image link' do
p = create(:place)
i = Image.new
i.place = p
i.attach(io: File.open(Rails.root.join('spec', 'support', 'files', 'test.jpg')), filename: 'attachment.jpg', content_type: 'image/jpeg')
expect(helper.image_link(i)).to eq("http://test.host#{polymorphic_path(i.file.variant(resize: '800x800').processed)}")
end
Expand Down
15 changes: 14 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
'chromedriver.storage.googleapis.com'
])


# special setup to make feature tests run on ubuntu 20.4 LTS
if ENV['UBUNTU']
puts 'Running Rspecs on Ubuntu'
# Webdrivers.logger.level = :debug
# On Ubuntu >= 20 Chrome is installed via snap, so provide the path here
::Selenium::WebDriver::Chrome.path = '/snap/chromium/current/usr/lib/chromium-browser/chrome'
# For the moment, at my machine, Chromedriver v98 fails with Chromium v98 (sic!)
Webdrivers::Chromedriver.required_version = '97.0.4692.71'
else
puts 'Running Rspecs on Linux (If you use Ubuntu and encounter problems you might try to call this with "UBUNTU=true"'
end

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Expand All @@ -30,7 +43,7 @@
capabilities: options
end

Selenium::WebDriver.logger.ignore(:driver_path)
# Selenium::WebDriver.logger.ignore(:driver_path)

# switch to :chrome for watching the tests in browser
Capybara.default_driver = :headless_chrome
Expand Down

0 comments on commit 77547e8

Please sign in to comment.