Skip to content

Commit

Permalink
Merge pull request #3236 from aldesantis/feature/rails-6
Browse files Browse the repository at this point in the history
Add support for Rails 6
  • Loading branch information
kennyadsl authored Sep 2, 2019
2 parents 06147a1 + 614ecbe commit 466ac8e
Show file tree
Hide file tree
Showing 15 changed files with 355 additions and 286 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ jobs:
- setup
- test

postgres_rails52:
executor: postgres
parallelism: *parallelism
environment:
RAILS_VERSION: '~> 5.2.0'
steps:
- setup
- test

mysql_rails52:
executor: mysql
parallelism: *parallelism
environment:
RAILS_VERSION: '~> 5.2.0'
steps:
- setup
- test

workflows:
build:
jobs:
Expand All @@ -132,6 +150,8 @@ workflows:
- mysql
- postgres_rails51
- mysql_rails51
- postgres_rails52
- mysql_rails52
- stoplight/push:
project: solidus/solidus-api
git_token: $STOPLIGHT_GIT_TOKEN
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source 'https://rubygems.org'
group :backend, :frontend, :core, :api do
gemspec require: false

rails_version = ENV['RAILS_VERSION'] || '~> 5.2.0'
rails_version = ENV['RAILS_VERSION'] || '~> 6.0.0'
gem 'rails', rails_version, require: false

platforms :ruby do
Expand All @@ -28,7 +28,7 @@ group :backend, :frontend, :core, :api do
gem 'database_cleaner', '~> 1.3', require: false
gem 'factory_bot_rails', '~> 4.8', require: false
gem 'rspec-activemodel-mocks', '~> 1.1', require: false
gem 'rspec-rails', '~> 3.7', require: false
gem 'rspec-rails', '~> 4.0.0.beta2', require: false
gem 'simplecov', require: false
gem 'with_model', require: false
gem 'rails-controller-testing', require: false
Expand All @@ -46,8 +46,8 @@ group :frontend do
end

group :backend do
gem 'teaspoon', require: false
gem 'teaspoon-mocha', require: false
gem 'teaspoon', github: 'jejacks0n/teaspoon', require: false
gem 'teaspoon-mocha', github: 'jejacks0n/teaspoon', require: false
end

group :utils do
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Begin by making sure you have
required for Paperclip. (You can install it using [Homebrew](https://brew.sh) if
you're on a Mac.)

To add solidus, begin with a Rails 5 application and a database configured and
To add solidus, begin with a Rails 5/6 application and a database configured and
created. Add the following to your Gemfile.

```ruby
Expand Down
31 changes: 8 additions & 23 deletions backend/spec/teaspoon_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,8 @@

ENV['RAILS_ENV'] = 'test'

# Teaspoon doesn't allow you to pass client driver options to the Selenium WebDriver. This monkey patch
# is a temporary fix until this PR is merged: https://github.com/jejacks0n/teaspoon/pull/519.
require 'teaspoon/driver/selenium'

Teaspoon::Driver::Selenium.class_eval do
def run_specs(runner, url)
driver = ::Selenium::WebDriver.for(driver_options[:client_driver], @options.except(:client_driver) || {})
driver.navigate.to(url)

::Selenium::WebDriver::Wait.new(driver_options).until do
done = driver.execute_script("return window.Teaspoon && window.Teaspoon.finished")
driver.execute_script("return window.Teaspoon && window.Teaspoon.getMessages() || []").each do |line|
runner.process("#{line}\n")
end
done
end
ensure
driver.quit if driver
end
end

# Similar to setup described in
# https://github.com/jejacks0n/teaspoon/wiki/Micro-Applications

Expand All @@ -38,10 +19,14 @@ def run_specs(runner, url)
config.fixture_paths = ["spec/javascripts/fixtures"]

config.driver = :selenium
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu window-size=1920,1440) }
)
config.driver_options = { client_driver: :chrome, desired_capabilities: capabilities }
config.driver_options = {
client_driver: :chrome,
selenium_options: {
options: Selenium::WebDriver::Chrome::Options.new(
args: %w(headless disable-gpu window-size=1920,1440),
),
},
}

config.suite do |suite|
suite.use_framework :mocha, "2.3.3"
Expand Down
2 changes: 1 addition & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ echo "* Testing Solidus Backend *"
echo "***************************"
cd ../backend
bundle exec rspec spec
bundle exec teaspoon
bundle exec teaspoon --require=../backend/spec/teaspoon_env.rb

# Solidus Core
echo "************************"
Expand Down
16 changes: 13 additions & 3 deletions bin/build-ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'
require 'pathname'

class Project
Expand Down Expand Up @@ -159,7 +160,9 @@ class Project
end

def run_teaspoon
run_test_cmd(%w[bundle exec teaspoon] + teaspoon_arguments)
cmd = %w[bundle exec teaspoon] + teaspoon_arguments

run_test_cmd(cmd)
end

def run_test_cmd(args)
Expand All @@ -170,11 +173,18 @@ class Project
end

def teaspoon_arguments
args = []

args << '--require=spec/teaspoon_env.rb'

if report_dir
%W[--format documentation,junit>#{report_dir}/rspec/#{name}_js.xml]
FileUtils.mkdir_p("#{report_dir}/rspec")
args << "--format=documentation,junit>#{report_dir}/rspec/#{name}_js.xml"
else
%w[--format documentation]
args << '--format=documentation'
end

args
end

def rspec_arguments
Expand Down
Loading

0 comments on commit 466ac8e

Please sign in to comment.