Skip to content

Commit e6cde4d

Browse files
committed
Explicitly support Rails 5
1 parent 9c03668 commit e6cde4d

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

.travis.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ sudo: false
44
rvm:
55
- 1.9.3 # when removed, get rid of the before_script hack and also the one in application_generator.rb
66
- 2.0.0
7-
- 2.1.5
8-
- 2.2.0
9-
- 2.3.0
7+
- 2.1.9
8+
- 2.2.5
9+
- 2.3.1
1010
env:
1111
- RAILS_VERSION="~> 4.2.0"
12+
- RAILS_VERSION="~> 5.0.0"
13+
matrix:
14+
exclude: # Rails 5 is incompatible with Ruby < 2.2.2
15+
- rvm: 1.9.3
16+
env: RAILS_VERSION="~> 5.0.0"
17+
- rvm: 2.0.0
18+
env: RAILS_VERSION="~> 5.0.0"
19+
- rvm: 2.1.9
20+
env: RAILS_VERSION="~> 5.0.0"
1221
before_script:
1322
- "[ $TRAVIS_RUBY_VERSION = \"1.9.3\" ] && travis_retry gem install mime-types --version \"~> 2\" || true"
1423
- travis_retry gem install rails --version "$RAILS_VERSION"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +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.2 (Spring is installed by default when you do `rails
21-
new` to generate your application)
20+
* Rails versions: 4.2, 5.0 (Spring is installed by default when you do
21+
`rails new` to generate your application)
2222

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

lib/spring/test/acceptance_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AcceptanceTest < ActiveSupport::TestCase
1212
DEFAULT_SPEEDUP = 0.8
1313

1414
def rails_version
15-
ENV['RAILS_VERSION'] || '~> 4.2.0'
15+
ENV['RAILS_VERSION'] || '~> 5.0.0'
1616
end
1717

1818
# Extension point for spring-watchers-listen
@@ -121,7 +121,7 @@ def without_gem(name)
121121
assert_speedup do
122122
assert_success app.spring_test_command, stdout: "0 failures"
123123

124-
File.write(app.test, app.test.read.sub("get :index", "raise 'omg'"))
124+
app.insert_into_test "raise 'omg'"
125125
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
126126
end
127127
end
@@ -156,7 +156,7 @@ def self.omg
156156
end
157157
end
158158
RUBY
159-
File.write(app.test, app.test.read.sub("get :index", "Foo.omg"))
159+
app.insert_into_test "Foo.omg"
160160

161161
app.await_reload
162162
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"

lib/spring/test/application.rb

+4
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ def bundle
209209
run! "bundle check || bundle update --retry=2", timeout: nil
210210
end
211211

212+
def insert_into_test(code)
213+
File.write(test, test.read.sub(/^\s*get .+$/, code))
214+
end
215+
212216
private
213217

214218
def process_alive?(pid)

lib/spring/test/application_generator.rb

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def generate_if_missing
8686
def install_spring
8787
return if @installed
8888

89+
if RUBY_VERSION < "2.2.2"
90+
application.run! "gem install activesupport --version '#{version}'"
91+
end
92+
8993
build_and_install_gems
9094

9195
application.bundle

0 commit comments

Comments
 (0)