Skip to content

Commit

Permalink
Explicitly support Rails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Oct 1, 2016
1 parent 9c03668 commit e6cde4d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ sudo: false
rvm:
- 1.9.3 # when removed, get rid of the before_script hack and also the one in application_generator.rb
- 2.0.0
- 2.1.5
- 2.2.0
- 2.3.0
- 2.1.9
- 2.2.5
- 2.3.1
env:
- RAILS_VERSION="~> 4.2.0"
- RAILS_VERSION="~> 5.0.0"
matrix:
exclude: # Rails 5 is incompatible with Ruby < 2.2.2
- rvm: 1.9.3
env: RAILS_VERSION="~> 5.0.0"
- rvm: 2.0.0
env: RAILS_VERSION="~> 5.0.0"
- rvm: 2.1.9
env: RAILS_VERSION="~> 5.0.0"
before_script:
- "[ $TRAVIS_RUBY_VERSION = \"1.9.3\" ] && travis_retry gem install mime-types --version \"~> 2\" || true"
- travis_retry gem install rails --version "$RAILS_VERSION"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +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.2 (Spring is installed by default when you do `rails
new` to generate your application)
* Rails versions: 4.2, 5.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
provide a speed up on platforms which don't support forking (Windows, JRuby).
Expand Down
6 changes: 3 additions & 3 deletions lib/spring/test/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'] || '~> 4.2.0'
ENV['RAILS_VERSION'] || '~> 5.0.0'
end

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

File.write(app.test, app.test.read.sub("get :index", "raise 'omg'"))
app.insert_into_test "raise 'omg'"
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
end
end
Expand Down Expand Up @@ -156,7 +156,7 @@ def self.omg
end
end
RUBY
File.write(app.test, app.test.read.sub("get :index", "Foo.omg"))
app.insert_into_test "Foo.omg"

app.await_reload
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
Expand Down
4 changes: 4 additions & 0 deletions lib/spring/test/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ def bundle
run! "bundle check || bundle update --retry=2", timeout: nil
end

def insert_into_test(code)
File.write(test, test.read.sub(/^\s*get .+$/, code))
end

private

def process_alive?(pid)
Expand Down
4 changes: 4 additions & 0 deletions lib/spring/test/application_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def generate_if_missing
def install_spring
return if @installed

if RUBY_VERSION < "2.2.2"
application.run! "gem install activesupport --version '#{version}'"
end

build_and_install_gems

application.bundle
Expand Down

0 comments on commit e6cde4d

Please sign in to comment.