From 3fd2909217c261b9da93637ff6e9a054da94cbb6 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Fri, 11 Jan 2019 10:34:27 +0100 Subject: [PATCH] add spring to decrease test startup time --- Gemfile | 5 ++++- Gemfile.lock | 8 +++++++- bin/rails | 5 +++++ bin/rake | 5 +++++ bin/rspec | 34 ++++++++++++++++++++++++++++++++++ bin/spring | 17 +++++++++++++++++ 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100755 bin/rspec create mode 100755 bin/spring diff --git a/Gemfile b/Gemfile index 3749ecdeae6..2f4a3552531 100644 --- a/Gemfile +++ b/Gemfile @@ -239,10 +239,13 @@ group :ldap do end group :development do - gem 'letter_opener' gem 'faker' + gem 'letter_opener' gem 'livingstyleguide', '~> 2.0.1' + gem 'spring' + gem 'spring-commands-rspec' + gem 'rubocop' end diff --git a/Gemfile.lock b/Gemfile.lock index 2ad68b9cbd7..3a8fbbd0b98 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -749,6 +749,10 @@ GEM simplecov-html (0.10.2) spreadsheet (0.8.9) ruby-ole (>= 1.0) + spring (2.0.2) + activesupport (>= 4.2) + spring-commands-rspec (1.0.4) + spring (>= 0.9.1) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -956,6 +960,8 @@ DEPENDENCIES shoulda-context (~> 1.2) shoulda-matchers (~> 3.1) simplecov (~> 0.16.0) + spring + spring-commands-rspec sprockets (~> 3.7.0) sqlite3 stackprof @@ -979,4 +985,4 @@ RUBY VERSION ruby 2.5.1p57 BUNDLED WITH - 1.17.1 + 1.17.3 diff --git a/bin/rails b/bin/rails index 07396602377..5badb2fde0c 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 17240489f64..d87d5f57810 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000000..2f121560cda --- /dev/null +++ b/bin/rspec @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/bin/spring b/bin/spring new file mode 100755 index 00000000000..fb2ec2ebb48 --- /dev/null +++ b/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end