diff --git a/lib/spring/test/acceptance_test.rb b/lib/spring/test/acceptance_test.rb index ee42e712..36551286 100644 --- a/lib/spring/test/acceptance_test.rb +++ b/lib/spring/test/acceptance_test.rb @@ -4,6 +4,7 @@ require "timeout" require "spring/sid" require "spring/client" +require "active_support/core_ext/string/strip" module Spring module Test @@ -111,13 +112,13 @@ def assert_speedup(ratio = DEFAULT_SPEEDUP) test "app gets reloaded when preloaded files change" do assert_success app.spring_test_command - File.write(app.application_config, app.application_config.read + <<-CODE) + File.write(app.application_config, app.application_config.read + <<-RUBY.strip_heredoc) class Foo def self.omg raise "omg" end end - CODE + RUBY File.write(app.test, app.test.read.sub("get :index", "Foo.omg")) app.await_reload @@ -160,7 +161,7 @@ def self.omg # Start spring before setting up the command, to test that it gracefully upgrades itself assert_success "bin/rails runner ''" - File.write(app.spring_config, <<-CODE) + File.write(app.spring_config, <<-RUBY.strip_heredoc) class CustomCommand def call puts "omg" @@ -172,7 +173,7 @@ def exec_name end Spring.register_command "custom", CustomCommand.new - CODE + RUBY assert_success "bin/spring custom", stdout: "omg" @@ -200,46 +201,48 @@ def exec_name end test "binstub upgrade" do - File.write(app.path("bin/rake"), < :environment do puts Rails.env end task :print_env do - ENV.each { |k, v| puts "#{k}=#{v}" } + ENV.each { |k, v| puts "\#{k}=\#{v}" } end task(:default).clear.enhance [:print_rails_env] - CODE + RUBY assert_success "bin/rake RAILS_ENV=test print_rails_env", stdout: "test" assert_success "bin/rake FOO=bar print_env", stdout: "FOO=bar" @@ -305,7 +308,7 @@ def exec_name end test "changing the Gemfile works when spring calls into itself" do - File.write(app.path("script.rb"), <<-CODE) + File.write(app.path("script.rb"), <<-RUBY.strip_heredoc) gemfile = Rails.root.join("Gemfile") File.write(gemfile, "\#{gemfile.read}gem 'devise'\\n") Bundler.with_clean_env do @@ -313,7 +316,7 @@ def exec_name end output = `\#{Rails.root.join('bin/rails')} runner 'require "devise"; puts "done";'` exit output == "done\n" - CODE + RUBY assert_success [%(bin/rails runner 'load Rails.root.join("script.rb")'), timeout: 60] end