Skip to content

Commit

Permalink
Merge pull request #223 from a-thousand-channels/ut/216-fix-feature-t…
Browse files Browse the repository at this point in the history
…esting-on-ubuntu

Fix feature tests with webdrivers on (my) ubuntu #216
  • Loading branch information
Sefux authored Feb 10, 2022
2 parents 15d4f88 + 40c4d16 commit 2f49dfb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/rubyonrails-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ env:
name: Rails - Install dependencies, run linters & rspec
on:
push:
branches: [main]
branches:
- main
- feature*
pull_request:
branches: [main]
branches:
- main
- feature*
jobs:
run-lint:
name: Rubocop & Brakeman
Expand Down
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
14 changes: 13 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
'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 +42,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 2f49dfb

Please sign in to comment.