Skip to content

Commit

Permalink
Update Capybara/Selenium configuration for system specs
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Nov 29, 2024
1 parent 45f876f commit 3e22bee
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ jobs:
- name: Run Specs
run: bundle exec rake

- name: Keep screenshots from failed feature specs
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/capybara
if-no-files-found: ignore

- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/automatic_resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

feature 'Automatic resources', js: true do
feature 'Automatic resources', type: :system do
include FeatureHelper

scenario 'index' do
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/modal_form_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

feature 'Modal forms', js: true do
feature 'Modal forms', type: :system do
include FeatureHelper

scenario 'index' do
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

feature 'Resources', js: true do
feature 'Resources', type: :system do
include FeatureHelper

scenario 'index' do
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/scopes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

feature "Scopes" do
feature "Scopes", type: :system do
before(:each) do
Post.create!(title: "Unpublished 1")
Post.create!(title: "Unpublished 2")
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/shakedown_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

feature 'Shakedown' do
feature 'Shakedown', type: :system do
scenario 'Admin index' do
visit '/admin'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/feature/singular_resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

feature 'Singular resources' do
feature 'Singular resources', type: :system do
scenario 'show' do
create_test_post

Expand Down
17 changes: 4 additions & 13 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
require 'capybara/rails'

Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument '--headless'
options.add_argument '--disable-gpu'
options.add_argument '--no-sandbox'

Capybara::Selenium::Driver.new app, browser: :chrome, options: options
RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
end
end

Capybara.javascript_driver = :chrome

Capybara.asset_host = "http://localhost:3000" unless ENV["CI"]
2 changes: 1 addition & 1 deletion spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
DatabaseCleaner.strategy = :transaction
end

config.before(:each, type: :feature) do
config.before(:each, type: :system) do
# :rack_test driver's Rack app under test shares database connection
# with the specs, so we can use transaction strategy for speed.
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
Expand Down

0 comments on commit 3e22bee

Please sign in to comment.