Skip to content

Commit

Permalink
wl - Add Rails 6 to test
Browse files Browse the repository at this point in the history
  • Loading branch information
wpliao1989 committed Apr 30, 2020
1 parent 883afbe commit 368ed48
Show file tree
Hide file tree
Showing 87 changed files with 1,548 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ matrix:
include:
- env: RAILS_VERSION=5.0
rvm: *max_ruby

- env: RAILS_VERSION=6.0
rvm: *max_ruby
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ gem 'ae_page_objects'

### Rails

AePageObjects is built to work with Rails (versions 3.X-5.0) out of the box. To use with Rails,
AePageObjects is built to work with Rails out of the box. To use with Rails,
add this line to your test helper:

```ruby
Expand Down
8 changes: 4 additions & 4 deletions development.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ in the gemspec.

### Supported Ruby versions

AePageObjects supports the same minimum Ruby version as Capybara, which is currently 1.9.3. The minimum Ruby version
AePageObjects supports the same minimum Ruby version as Capybara. The minimum Ruby version
is specified in the gemspec.

The test suite tests against the minimum version and a designated maximum version, specified in `.travis.yml`. The test
Expand Down Expand Up @@ -117,11 +117,11 @@ that the stub/mock setup within the tests works across Capybara versions.
Integration tests using page objects written via AePageObjects run against all versions of Capybara as well. These tests run using a Rails
application, using the most recent version of Rails possible that supports the Ruby version that the version of Capybara under test supports.

Today, all Capybara integration tests are run in the Rails 4.2 application using Ruby 2.2.5. To run these tests:
To run these tests:

```
RAILS_VERSION=4.2 rake test:integration:selenium:install
RAILS_VERSION=4.2 rake test:integration:selenium
RAILS_VERSION=6.0 rake test:integration:selenium:install
RAILS_VERSION=6.0 rake test:integration:selenium
```


Expand Down
1 change: 1 addition & 0 deletions test/test_apps/6.0/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
36 changes: 36 additions & 0 deletions test/test_apps/6.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-*

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore uploaded files in development.
/storage/*
!/storage/.keep

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
11 changes: 11 additions & 0 deletions test/test_apps/6.0/Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
case(RUBY_VERSION)

when '2.5.8', '2.6.6', '2.7.1' then
appraise "capybara-3.0-ruby#{RUBY_VERSION}" do
group :test do
gem 'capybara', '~> 3.0'
end
end
else
raise "ruby-#{RUBY_VERSION} is not supported!"
end
56 changes: 56 additions & 0 deletions test/test_apps/6.0/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem 'forum', path: 'engines'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
gem 'ae_page_objects', path: '../../..'
gem 'appraisal', '~> 2.0'
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
24 changes: 24 additions & 0 deletions test/test_apps/6.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
16 changes: 16 additions & 0 deletions test/test_apps/6.0/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require 'rake/testtask.rb'
require_relative 'config/application'

Rails.application.load_tasks

namespace :test do
Rake::TestTask.new(:selenium) do |t|
t.libs << 'test'
t.pattern = 'test/selenium/**/*_test.rb'
t.verbose = true
t.warning = false
end
end
2 changes: 2 additions & 0 deletions test/test_apps/6.0/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
Empty file.
15 changes: 15 additions & 0 deletions test/test_apps/6.0/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
4 changes: 4 additions & 0 deletions test/test_apps/6.0/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
1 change: 1 addition & 0 deletions test/test_apps/6.0/app/controllers
2 changes: 2 additions & 0 deletions test/test_apps/6.0/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
6 changes: 6 additions & 0 deletions test/test_apps/6.0/app/javascript/channels/consumer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.

import { createConsumer } from "@rails/actioncable"

export default createConsumer()
5 changes: 5 additions & 0 deletions test/test_apps/6.0/app/javascript/channels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Load all the channels within this directory and all subdirectories.
// Channel files must be named *_channel.js.

const channels = require.context('.', true, /_channel\.js$/)
channels.keys().forEach(channels)
17 changes: 17 additions & 0 deletions test/test_apps/6.0/app/javascript/packs/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
7 changes: 7 additions & 0 deletions test/test_apps/6.0/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
4 changes: 4 additions & 0 deletions test/test_apps/6.0/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
1 change: 1 addition & 0 deletions test/test_apps/6.0/app/models
1 change: 1 addition & 0 deletions test/test_apps/6.0/app/views
72 changes: 72 additions & 0 deletions test/test_apps/6.0/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')

if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}

return {
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
].filter(Boolean),
plugins: [
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
'@babel/plugin-transform-regenerator',
{
async: false
}
]
].filter(Boolean)
}
}
Loading

0 comments on commit 368ed48

Please sign in to comment.