Skip to content
Permalink
Browse files

Use system, transactional fixtures and webdrivers for chrome

  • Loading branch information
bricesanchez committed Oct 16, 2019
1 parent b5fd155 commit e954f3d34e2918b252ca4bc1e0c43277b890c378
@@ -2,20 +2,19 @@ language: ruby
dist: bionic
sudo: false
addons:
apt:
packages:
- chromium-chromedriver
postgresql: '10'
services:
- mysql
cache: bundler
cache:
bundler: true
directories:
- /home/travis/.webdrivers/
before_install:
- gem update --system
- gem install bundler
bundler_args: --without development
before_script:
- export RETRY_COUNT=3
- export PATH=$PATH:/usr/lib/chromium-browser/
- bin/rake refinery:testing:dummy_app
script:
- bin/rspec $EXTENSION/spec
@@ -14,7 +14,7 @@ gem 'listen'

gem 'spring'
gem 'spring-commands-rspec'
gem 'selenium-webdriver', require: false

gem 'activejob'

# Add support for refinerycms-acts-as-indexed
@@ -3,7 +3,7 @@
RSpec.configure do |config|
config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller
config.include Refinery::Testing::ControllerMacros::Routes, :type => :controller
config.extend Refinery::Testing::FeatureMacros::Authentication, :type => :feature
config.extend Refinery::Testing::FeatureMacros::Authentication, :type => :system

# set some config values so that image and resource factories don't fail to create
config.before do
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "custom", type: :feature do
describe "custom", type: :system do
refinery_login

let(:custom_js){ Refinery.roots('refinery/core').join('spec/support/fixtures/custom_js.js') }
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "dialog", type: :feature do
describe "dialog", type: :system do
refinery_login

context "links" do
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "Crudify", type: :feature do
describe "Crudify", type: :system do
refinery_login

describe "xhr_paging", :js do
@@ -1,7 +1,7 @@
require 'spec_helper'

module Refinery
describe 'layout', :type => :feature do
describe 'layout', :type => :system do
refinery_login

let(:home_page) do
@@ -2,7 +2,7 @@

module Refinery
module Core
describe Engine, :type => :feature do
describe Engine, :type => :system do
describe "#refinery_inclusion!" do
it "should be idempotent" do
expect { visit(refinery.root_path) }.not_to raise_error
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "site bar", :type => :feature do
describe "site bar", :type => :system do
refinery_login

describe "logout link" do
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "dialog", :type => :feature do
describe "dialog", :type => :system do
refinery_login

context 'When there are many images' do
@@ -1,7 +1,7 @@
require "spec_helper"

module Refinery
describe "the Admin Images Tab", type: :feature do
describe "the Admin Images Tab", type: :system do
refinery_login
include_context 'admin images tab'

@@ -25,7 +25,7 @@ def switch_page_form_locale(locale)

module Refinery
module Admin
describe "Pages", :type => :feature do
describe "Pages", :type => :system do
refinery_login

context "when no pages" do
@@ -819,7 +819,7 @@ module Admin
end
end

describe "TranslatePages", :type => :feature do
describe "TranslatePages", :type => :system do
before { Mobility.locale = :en }
refinery_login

@@ -2,7 +2,7 @@
require 'spec_helper'

module Refinery
describe 'page frontend', :type => :feature do
describe 'page frontend', :type => :system do
let(:home_page) { Page.create :title => 'Home', :link_url => '/' }
let(:about_page) { Page.create :title => 'About' }
let(:draft_page) { Page.create :title => 'Draft', :draft => true }
@@ -343,7 +343,7 @@ def standard_page_menu_items_exist?
describe 'for vistor' do
it 'redirect to the 404 error page' do
allow_any_instance_of(PagesController).to receive(:current_refinery_user_can_access?).and_return(false)

visit refinery.page_path(draft_page)

expect(page).to have_http_status(404)
@@ -447,4 +447,4 @@ def standard_page_menu_items_exist?
end
end
end
end
end
@@ -4,7 +4,7 @@

module Refinery
module Admin
describe 'Resources', type: :feature do
describe 'Resources', type: :system do
refinery_login

context 'when no files' do
@@ -16,6 +16,7 @@

require 'rspec/rails'
require 'capybara/rspec'
require 'webdrivers/chromedriver'

if ENV['RETRY_COUNT']
require 'rspec/retry'
@@ -39,7 +40,9 @@
config.include ActionView::TestCase::Behavior, :file_path => %r{spec/presenters}
config.infer_spec_type_from_file_location!

config.when_first_matching_example_defined(type: :feature) do
config.use_transactional_fixtures = true

config.when_first_matching_example_defined(type: :system) do
config.before :suite do
# Preload assets
# This should avoid capybara timeouts, and avoid counting asset compilation
@@ -52,6 +55,10 @@
::I18n.default_locale = I18n.locale = Mobility.locale = :en
end

config.before(:each, type: :system, js: true) do
driven_by :selenium_chrome_headless
end

unless ENV['FULL_BACKTRACE']
config.backtrace_exclusion_patterns = %w(
rails actionpack railties capybara activesupport rack warden rspec actionview
@@ -70,16 +77,3 @@
}.flatten.sort.each do |support_file|
require support_file
end

require "selenium/webdriver"

Capybara.register_driver :selenium_chrome_headless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--no-sandbox'
browser_options.args << '--disable-gpu'
browser_options.args << '--window-size=1440,1080'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
s.add_dependency 'rspec-rails', '~> 4.0.0.beta2'
s.add_dependency 'capybara', '>= 2.18'
s.add_dependency 'rails-controller-testing', '>= 0.1.1'
s.add_dependency 'webdrivers', '~> 4.0'

s.required_ruby_version = Refinery::Version.required_ruby_version

0 comments on commit e954f3d

Please sign in to comment.
You can’t perform that action at this time.