Skip to content

Commit 9c03668

Browse files
committed
Drop support for Rails 4.0 and 4.1
* 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)
1 parent 56e3f98 commit 9c03668

11 files changed

+44
-34
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ rvm:
88
- 2.2.0
99
- 2.3.0
1010
env:
11-
- RAILS_VERSION="~> 4.0.0"
12-
- RAILS_VERSION="~> 4.1.0"
1311
- RAILS_VERSION="~> 4.2.0"
1412
before_script:
1513
- "[ $TRAVIS_RUBY_VERSION = \"1.9.3\" ] && travis_retry gem install mime-types --version \"~> 2\" || true"

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.0 (unreleased)
2+
3+
* Drop Rails 4.0 and 4.1 support
4+
15
## 1.7.2
26

37
* Use `Spring.failsafe_thread` to prevent threads from aborting process due to `Thread.abort_on_exception` when set to `true`

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in spring.gemspec
44
gemspec
5+
6+
if ENV["RAILS_VERSION"]
7+
gem "activesupport", ENV["RAILS_VERSION"]
8+
end

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ boot it every time you run a test, rake task or migration.
1717
## Compatibility
1818

1919
* Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2
20-
* Rails versions: 4.0+ (in Rails 4.1 and up Spring is included by default)
20+
* Rails versions: 4.2 (Spring is installed by default when you do `rails
21+
new` to generate your application)
2122

2223
Spring makes extensive use of `Process.fork`, so won't be able to
2324
provide a speed up on platforms which don't support forking (Windows, JRuby).

lib/spring/binstub.rb

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
command = File.basename($0)
22
bin_path = File.expand_path("../../../bin/spring", __FILE__)
33

4+
# When we run a command which does not go through Spring (e.g. DISABLE_SPRING
5+
# is used, or we just call 'rails' or something) then we get this warning from
6+
# Rubygems:
7+
#
8+
# WARN: Unresolved specs during Gem::Specification.reset: activesupport (<= 5.1, >= 4.2)
9+
# WARN: Clearing out unresolved specs.
10+
# Please report a bug if this causes problems.
11+
#
12+
# This happens due to our dependency on activesupport, when Bundler.setup gets
13+
# called. We don't actually *use* the dependency; it is purely there to
14+
# restrict the Rails version that we're compatible with.
15+
#
16+
# When the warning is shown, Rubygems just does the below.
17+
# Therefore, by doing it ourselves here, we can avoid the warning.
18+
if Gem::Specification.respond_to?(:unresolved_deps)
19+
Gem::Specification.unresolved_deps.clear
20+
else
21+
Gem.unresolved_deps.clear
22+
end
23+
424
if command == "spring"
525
load bin_path
626
else

lib/spring/test/acceptance_test.rb

+5
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ def exec_name
540540

541541
assert_failure "bin/rails runner ''", stderr: "timed out"
542542
end
543+
544+
test "no warnings are shown for unsprung commands" do
545+
app.env["DISABLE_SPRING"] = "1"
546+
refute_output_includes "bin/rails runner ''", stderr: "WARN"
547+
end
543548
end
544549
end
545550
end

lib/spring/test/application.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def rails_version
6565
end
6666

6767
def spring_test_command
68-
"#{rails_version.test_command} #{test}"
68+
"bin/rake test #{test}"
6969
end
7070

7171
def stop_spring
@@ -74,7 +74,7 @@ def stop_spring
7474
end
7575

7676
def test
77-
path "test/#{rails_version.controller_tests_dir}/posts_controller_test.rb"
77+
path "test/controllers/posts_controller_test.rb"
7878
end
7979

8080
def controller

lib/spring/test/application_generator.rb

+1-10
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def generate_files
4848

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

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

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

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

63-
if version.needs_testunit?
64-
append_to_file(application.gemfile, "gem 'spring-commands-testunit'")
65-
end
66-
67-
if RUBY_VERSION == "1.9.3" && version.to_s.start_with?("4.0")
68-
append_to_file(application.gemfile, "gem 'mime-types', '~> 2'")
69-
end
70-
7162
rewrite_file(application.gemfile) do |c|
7263
c.sub!("https://rubygems.org", "http://rubygems.org")
7364
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")

lib/spring/test/rails_version.rb

-17
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@ def initialize(string)
77
@version = Gem::Version.new(string)
88
end
99

10-
def rails_3?
11-
version < Gem::Version.new("4.0.0")
12-
end
13-
alias needs_testunit? rails_3?
14-
15-
def test_command
16-
needs_testunit? ? 'bin/testunit' : 'bin/rake test'
17-
end
18-
19-
def controller_tests_dir
20-
rails_3? ? 'functional' : 'controllers'
21-
end
22-
23-
def bundles_spring?
24-
version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
25-
end
26-
2710
def major
2811
version.segments[0]
2912
end

lib/spring/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Spring
2-
VERSION = "1.7.2"
2+
VERSION = "2.0.0"
33
end

spring.gemspec

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ Gem::Specification.new do |gem|
1313
gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*", "bin/*"]
1414
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1515

16-
gem.add_development_dependency 'activesupport', '~> 4.2.0'
16+
# We don't directly use Active Support (Spring needs to be able to run
17+
# without gem dependencies), but this will ensure that this version of
18+
# Spring can't be installed alongside an incompatible Rails version.
19+
gem.add_dependency 'activesupport', '>= 4.2'
20+
1721
gem.add_development_dependency 'rake'
1822
gem.add_development_dependency 'bump'
1923
end

0 commit comments

Comments
 (0)