Skip to content

Commit

Permalink
Drop support for Rails 4.0 and 4.1
Browse files Browse the repository at this point in the history
* Bump version to 2.0.0 because this will be a kind of "breaking change"
* Add 'runtime' dependency on activesupport >= 4.2 to gemfile so that
  Spring 2.0.0 won't be installed by bundler in a Rails 4.0 or 4.1
  application (the dependency isn't actually used at runtime)
  • Loading branch information
jonleighton committed Oct 1, 2016
1 parent 56e3f98 commit 9c03668
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ rvm:
- 2.2.0
- 2.3.0
env:
- RAILS_VERSION="~> 4.0.0"
- RAILS_VERSION="~> 4.1.0"
- RAILS_VERSION="~> 4.2.0"
before_script:
- "[ $TRAVIS_RUBY_VERSION = \"1.9.3\" ] && travis_retry gem install mime-types --version \"~> 2\" || true"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0 (unreleased)

* Drop Rails 4.0 and 4.1 support

## 1.7.2

* Use `Spring.failsafe_thread` to prevent threads from aborting process due to `Thread.abort_on_exception` when set to `true`
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in spring.gemspec
gemspec

if ENV["RAILS_VERSION"]
gem "activesupport", ENV["RAILS_VERSION"]
end
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ boot it every time you run a test, rake task or migration.
## Compatibility

* Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2
* Rails versions: 4.0+ (in Rails 4.1 and up Spring is included by default)
* Rails versions: 4.2 (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
provide a speed up on platforms which don't support forking (Windows, JRuby).
Expand Down
20 changes: 20 additions & 0 deletions lib/spring/binstub.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
command = File.basename($0)
bin_path = File.expand_path("../../../bin/spring", __FILE__)

# When we run a command which does not go through Spring (e.g. DISABLE_SPRING
# is used, or we just call 'rails' or something) then we get this warning from
# Rubygems:
#
# WARN: Unresolved specs during Gem::Specification.reset: activesupport (<= 5.1, >= 4.2)
# WARN: Clearing out unresolved specs.
# Please report a bug if this causes problems.
#
# This happens due to our dependency on activesupport, when Bundler.setup gets
# called. We don't actually *use* the dependency; it is purely there to
# restrict the Rails version that we're compatible with.
#
# When the warning is shown, Rubygems just does the below.
# Therefore, by doing it ourselves here, we can avoid the warning.
if Gem::Specification.respond_to?(:unresolved_deps)
Gem::Specification.unresolved_deps.clear
else
Gem.unresolved_deps.clear
end

if command == "spring"
load bin_path
else
Expand Down
5 changes: 5 additions & 0 deletions lib/spring/test/acceptance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,11 @@ def exec_name

assert_failure "bin/rails runner ''", stderr: "timed out"
end

test "no warnings are shown for unsprung commands" do
app.env["DISABLE_SPRING"] = "1"
refute_output_includes "bin/rails runner ''", stderr: "WARN"
end
end
end
end
4 changes: 2 additions & 2 deletions lib/spring/test/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def rails_version
end

def spring_test_command
"#{rails_version.test_command} #{test}"
"bin/rake test #{test}"
end

def stop_spring
Expand All @@ -74,7 +74,7 @@ def stop_spring
end

def test
path "test/#{rails_version.controller_tests_dir}/posts_controller_test.rb"
path "test/controllers/posts_controller_test.rb"
end

def controller
Expand Down
11 changes: 1 addition & 10 deletions lib/spring/test/application_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def generate_files

@version = RailsVersion.new(`ruby -e 'puts Gem::Specification.find_by_name("rails", "#{version_constraint}").version'`.chomp)

skips = %w(--skip-bundle --skip-javascript --skip-sprockets)
skips << "--skip-spring" if version.bundles_spring?
skips = %w(--skip-bundle --skip-javascript --skip-sprockets --skip-spring)

system("rails _#{version}_ new #{application.root} #{skips.join(' ')}")
raise "application generation failed" unless application.exists?
Expand All @@ -60,14 +59,6 @@ def generate_files

append_to_file(application.gemfile, "gem 'spring', '#{Spring::VERSION}'")

if version.needs_testunit?
append_to_file(application.gemfile, "gem 'spring-commands-testunit'")
end

if RUBY_VERSION == "1.9.3" && version.to_s.start_with?("4.0")
append_to_file(application.gemfile, "gem 'mime-types', '~> 2'")
end

rewrite_file(application.gemfile) do |c|
c.sub!("https://rubygems.org", "http://rubygems.org")
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")
Expand Down
17 changes: 0 additions & 17 deletions lib/spring/test/rails_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ def initialize(string)
@version = Gem::Version.new(string)
end

def rails_3?
version < Gem::Version.new("4.0.0")
end
alias needs_testunit? rails_3?

def test_command
needs_testunit? ? 'bin/testunit' : 'bin/rake test'
end

def controller_tests_dir
rails_3? ? 'functional' : 'controllers'
end

def bundles_spring?
version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
end

def major
version.segments[0]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/spring/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Spring
VERSION = "1.7.2"
VERSION = "2.0.0"
end
6 changes: 5 additions & 1 deletion spring.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ 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.add_development_dependency 'activesupport', '~> 4.2.0'
# We don't directly use Active Support (Spring needs to be able to run
# without gem dependencies), but this will ensure that this version of
# Spring can't be installed alongside an incompatible Rails version.
gem.add_dependency 'activesupport', '>= 4.2'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'bump'
end

0 comments on commit 9c03668

Please sign in to comment.