Skip to content

Commit

Permalink
Merge pull request #617 from deivid-rodriguez/remove_old_rails
Browse files Browse the repository at this point in the history
Remove support for old Rails versions
  • Loading branch information
kaspth authored Feb 9, 2021
2 parents d7b21ff + 728f357 commit 24d9e93
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 46 deletions.
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
language: ruby
cache: bundler
rvm:
- 2.4.6
- 2.5.5
- 2.6.3
- ruby-head
env:
- RAILS_VERSION="~> 4.2.0"
- RAILS_VERSION="~> 5.0.0"
- RAILS_VERSION="~> 5.1.0"
- RAILS_VERSION="~> 5.2.0"
- RAILS_VERSION="~> 6.0.0.rc1"
matrix:
exclude:
- rvm: 2.4.6
env: RAILS_VERSION="~> 6.0.0.rc1"
- rvm: 2.6.3
env: RAILS_VERSION="~> 4.2.0"
allow_failures:
- rvm: ruby-head
fast_finish: true
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ boot it every time you run a test, rake task or migration.

## Compatibility

* Ruby versions: MRI 2.4, MRI 2.5, MRI 2.6
* Rails versions: 4.2, 5.0, 5.1, 5.2, 6.0 (Spring is installed by default when you do
* Ruby versions: MRI 2.5, MRI 2.6
* Rails versions: 5.2, 6.0 (Spring is installed by default when you do
`rails new` to generate your application)

Spring makes extensive use of `Process.fork`, so won't be able to
Expand Down
12 changes: 3 additions & 9 deletions lib/spring/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def preload

require Spring.application_root_path.join("config", "application")

unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('4.2.0')
raise "Spring only supports Rails >= 4.2.0"
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('5.2.0')
raise "Spring only supports Rails >= 5.2.0"
end

# config/environments/test.rb will have config.cache_classes = true. However
Expand Down Expand Up @@ -163,13 +163,7 @@ def serve(client)
setup command

if Rails.application.reloaders.any?(&:updated?)
# Rails 5.1 forward-compat. AD::R is deprecated to AS::R in Rails 5.
if defined? ActiveSupport::Reloader
Rails.application.reloader.reload!
else
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
end
Rails.application.reloader.reload!
end

pid = fork {
Expand Down
2 changes: 1 addition & 1 deletion spring.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*", "bin/*"]
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }

gem.required_ruby_version = ">= 2.4.0"
gem.required_ruby_version = ">= 2.5.0"

gem.add_development_dependency 'rake'
gem.add_development_dependency 'bump'
Expand Down
46 changes: 21 additions & 25 deletions test/support/acceptance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AcceptanceTest < ActiveSupport::TestCase
DEFAULT_SPEEDUP = 0.8

def rails_version
ENV['RAILS_VERSION'] || '~> 5.0.0'
ENV['RAILS_VERSION'] || '~> 6.0.0'
end

# Extension point for spring-watchers-listen
Expand Down Expand Up @@ -503,18 +503,16 @@ def exec_name
assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
end

if RUBY_VERSION >= "2.0.0"
test "changing the gems.rb works" do
FileUtils.mv(app.gemfile, app.gems_rb)
FileUtils.mv(app.gemfile_lock, app.gems_locked)
test "changing the gems.rb works" do
FileUtils.mv(app.gemfile, app.gems_rb)
FileUtils.mv(app.gemfile_lock, app.gems_locked)

assert_success %(bin/rails runner 'require "sqlite3"')
assert_success %(bin/rails runner 'require "sqlite3"')

File.write(app.gems_rb, app.gems_rb.read.sub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
app.await_reload
File.write(app.gems_rb, app.gems_rb.read.sub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
app.await_reload

assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
end
assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
end

test "changing the Gemfile works when Spring calls into itself" do
Expand All @@ -531,23 +529,21 @@ def exec_name
assert_success [%(bin/rails runner 'load Rails.root.join("script.rb")'), timeout: 60]
end

if RUBY_VERSION >= "2.0.0"
test "changing the gems.rb works when spring calls into itself" do
FileUtils.mv(app.gemfile, app.gems_rb)
FileUtils.mv(app.gemfile_lock, app.gems_locked)
test "changing the gems.rb works when spring calls into itself" do
FileUtils.mv(app.gemfile, app.gems_rb)
FileUtils.mv(app.gemfile_lock, app.gems_locked)

File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
gemfile = Rails.root.join("gems.rb")
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
Bundler.with_clean_env do
system(#{app.env.inspect}, "bundle install")
end
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`
exit output.include? "done\n"
RUBY
File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
gemfile = Rails.root.join("gems.rb")
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
Bundler.with_clean_env do
system(#{app.env.inspect}, "bundle install")
end
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`
exit output.include? "done\n"
RUBY

assert_success [%(bin/rails runner 'load Rails.root.join("script.rb")'), timeout: 60]
end
assert_success [%(bin/rails runner 'load Rails.root.join("script.rb")'), timeout: 60]
end

test "changing the environment between runs" do
Expand Down

0 comments on commit 24d9e93

Please sign in to comment.