Skip to content

Rails 5.2 compatability #1959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ matrix:
env: RAILS_VERSION=5-0-stable
- rvm: 2.4.2
env: RAILS_VERSION=5.1.0
- rvm: 2.4.2
env: RAILS_VERSION=5.2.0.rc1
exclude:
# 3.0.x is not supported on MRI 2.0+
- rvm: 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end

# Capybara versions that support RSpec 3 only support RUBY_VERSION >= 1.9.3
if RUBY_VERSION >= '1.9.3'
if /5(\.|-)1/ === RAILS_VERSION || "master" == RAILS_VERSION
if /5(\.|-)[1-9]\d*/ === RAILS_VERSION || "master" == RAILS_VERSION
gem 'capybara', '~> 2.13', :require => false
else
gem 'capybara', '~> 2.2.0', :require => false
Expand Down
3 changes: 3 additions & 0 deletions example_app_generator/config/initializers/sqlite3_fix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if Rails.application.config.respond_to?(:active_record)
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
end
5 changes: 5 additions & 0 deletions example_app_generator/generate_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'travis_retry_bundle_install.sh'
)
function_script_file = File.join(rspec_rails_repo_path, 'script/functions.sh')
sqlite_initializer = File.join(rspec_rails_repo_path, "example_app_generator/config/initializers/sqlite3_fix.rb")

in_root do
prepend_to_file "Rakefile", "require 'active_support/all'"
Expand All @@ -27,6 +28,10 @@
append_to_file('Gemfile', "gem 'rails-controller-testing', :git => 'https://github.com/rails/rails-controller-testing'\n")
end

if Rails::VERSION::STRING >= '5.2.0'
copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb'
end

# Nokogiri version is pinned in rspec-rails' Gemfile since it tend to cause installation problems
# on Travis CI, so we pin nokogiri in this example app also.
append_to_file 'Gemfile', "gem 'nokogiri', '#{Nokogiri::VERSION}'\n"
Expand Down
Empty file.
6 changes: 6 additions & 0 deletions example_app_generator/spec/support/default_preview_path
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ def require_file_stub(name)
end

ENV['RAILS_ENV'] ||= 'development'
# Pick the frameworks you want:
begin
require "active_storage"
require "active_storage/engine"
rescue LoadError
end

require_file_stub 'config/environment' do
# Load the Rails application.
Expand Down
3 changes: 2 additions & 1 deletion lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def app
require 'capybara'
require 'action_dispatch/system_test_case'
# rubocop:disable Lint/HandleExceptions
rescue LoadError
rescue LoadError => e
p e
# rubocop:enable Lint/HandleExceptions
abort """
System test integration requires Rails >= 5.1 and has a hard
Expand Down