Skip to content

Commit c7d06eb

Browse files
committed
Merge pull request #414 from grosser/grosser/speed
speed up tests by not copying bundled directory every time
2 parents 7280284 + 2c316ba commit c7d06eb

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
language: ruby
2+
cache: bundler
3+
sudo: false
24
rvm:
35
- 1.9.3
46
- 2.0.0

lib/spring/test/acceptance_test.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ def exec_name
194194
end
195195

196196
test "binstub when spring is uninstalled" do
197-
app.run! "gem uninstall --ignore-dependencies spring"
198-
File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
199-
assert_success "bin/rake -T", stdout: "rake db:migrate"
197+
begin
198+
app.run! "gem uninstall --ignore-dependencies spring"
199+
File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
200+
assert_success "bin/rake -T", stdout: "rake db:migrate"
201+
ensure
202+
generator.build_and_install_gems
203+
end
200204
end
201205

202206
test "binstub upgrade" do

lib/spring/test/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def gemfile
4848
end
4949

5050
def gem_home
51-
path "vendor/gems/#{RUBY_VERSION}"
51+
path "../gems/#{RUBY_VERSION}"
5252
end
5353

5454
def user_home

lib/spring/test/application_generator.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,32 @@ def generate_files
5252
FileUtils.mkdir_p(application.user_home)
5353
FileUtils.rm_rf(application.path("test/performance"))
5454

55-
File.write(application.gemfile, "#{application.gemfile.read}gem 'spring', '#{Spring::VERSION}'\n")
55+
append_to_file(application.gemfile, "gem 'spring', '#{Spring::VERSION}'")
5656

5757
if version.needs_testunit?
58-
File.write(application.gemfile, "#{application.gemfile.read}gem 'spring-commands-testunit'\n")
58+
append_to_file(application.gemfile, "gem 'spring-commands-testunit'")
59+
end
60+
61+
rewrite_file(application.gemfile) do |c|
62+
c.sub!("https://rubygems.org", "http://rubygems.org")
63+
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")
64+
c
5965
end
6066

61-
File.write(application.gemfile, application.gemfile.read.sub("https://rubygems.org", "http://rubygems.org"))
6267

6368
if application.path("bin").exist?
6469
FileUtils.cp_r(application.path("bin"), application.path("bin_original"))
6570
end
6671
end
6772

73+
def rewrite_file(file)
74+
File.write(file, yield(file.read))
75+
end
76+
77+
def append_to_file(file, add)
78+
rewrite_file(file) { |c| c << "#{add}\n" }
79+
end
80+
6881
def generate_if_missing
6982
generate unless application.exists?
7083
end

0 commit comments

Comments
 (0)