From e60311f07d69e3acab0c1db23d0efd1b6d42ec13 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Mon, 3 Aug 2015 09:26:39 -0700 Subject: [PATCH] move gem instead of uninstalling and reinstalling to make test go from 20s->6s --- lib/spring/test/acceptance_test.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/spring/test/acceptance_test.rb b/lib/spring/test/acceptance_test.rb index 8e123a04..cfb0d5da 100644 --- a/lib/spring/test/acceptance_test.rb +++ b/lib/spring/test/acceptance_test.rb @@ -58,6 +58,14 @@ def assert_speedup(ratio = DEFAULT_SPEEDUP) end end + def without_gem(name) + gem_home = app.gem_home.join('gems') + FileUtils.mv(gem_home.join(name), app.root) + yield + ensure + FileUtils.mv(app.root.join(name), gem_home) + end + setup do generator.generate_if_missing generator.install_spring @@ -193,12 +201,9 @@ def exec_name end test "binstub when spring is uninstalled" do - begin - app.run! "gem uninstall --ignore-dependencies spring" + without_gem "spring-#{Spring::VERSION}" do File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, "")) assert_success "bin/rake -T", stdout: "rake db:migrate" - ensure - generator.build_and_install_gems end end