From a3595172883ad41f336a37472306b0f15981bb36 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 6 Feb 2018 01:00:40 +0100 Subject: [PATCH 1/4] Regenerate bin stubs These are the new binstubs available in the our current `spring` version, which make specs run much faster :relieved: --- bin/rails | 5 +++++ bin/rake | 5 +++++ bin/rspec | 5 +++++ bin/spring | 26 +++++++++++++------------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/bin/rails b/bin/rails index 5191e6927..0138d79b7 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', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 17240489f..d87d5f578 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 index d738b23c0..b207dde29 100755 --- a/bin/rspec +++ b/bin/rspec @@ -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 # frozen_string_literal: true # # This file was generated by Bundler. diff --git a/bin/spring b/bin/spring index 43731fe82..fb2ec2ebb 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,17 @@ #!/usr/bin/env ruby -# frozen_string_literal: true -# -# This file was generated by Bundler. -# -# The application 'spring' 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) +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. -require "rubygems" -require "bundler/setup" +unless defined?(Spring) + require 'rubygems' + require 'bundler' -load Gem.bin_path("spring", "spring") + 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 From 6f4d23fdef2c4b5947e8df11567cc04c446fbcce Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 6 Feb 2018 01:03:49 +0100 Subject: [PATCH 2/4] Remove circular argument reference warning We were seeing this warning when running specs `spec/features/admin/budgets_spec.rb:322: warning: circular argument reference - phase_kind` This commit should fix the warning --- spec/features/admin/budgets_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index e032daf29..b7efd1d7f 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -319,6 +319,6 @@ feature 'Admin budgets' do end end -def translated_phase_name(phase_kind: phase_kind) +def translated_phase_name(phase_kind: kind) I18n.t("budgets.phase.#{phase_kind}") end From 7b7a426f6aaf26565448877d3b432d8a517393c9 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 6 Feb 2018 01:09:09 +0100 Subject: [PATCH 3/4] Run Coveralls only in Travis CI We were seeing a log message when running specs locally ``` [Coveralls] Set up the SimpleCov formatter. [Coveralls] Using SimpleCov's 'rails' settings. ``` As Coveralls is mainly used in Travis CI, we do not need to load it in every spec run --- spec/rails_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 74af9d331..9331e8a70 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,8 @@ -require 'coveralls' -Coveralls.wear!('rails') ENV['RAILS_ENV'] ||= 'test' +if ENV['TRAVIS'] + require 'coveralls' + Coveralls.wear!('rails') +end require File.expand_path('../../config/environment', __FILE__) abort("The Rails environment is running in production mode!") if Rails.env.production? From 3a182629ca97fd70e5d44059b4fee7023d010f33 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 6 Feb 2018 01:16:02 +0100 Subject: [PATCH 4/4] Remove default profiling This makes tests run a tiny bit faster and cleans up the logs when running specs locally We can still configure rspec to run the profiler when we go into improving spec performance --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f083cc970..762a5444e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -92,7 +92,7 @@ RSpec.configure do |config| # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. - config.profile_examples = 10 + # config.profile_examples = 10 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing