From 7b07ce1d65427e1b8b5821a116c7d396e9733ff9 Mon Sep 17 00:00:00 2001 From: "Andrew W. Lee" Date: Wed, 25 Mar 2020 09:43:01 -0700 Subject: [PATCH 1/5] Move coverage code into a conditional --- spec/spec_helper.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f4d49b1c0..804d58264 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,16 +1,18 @@ -require 'coveralls' -require 'codeclimate-test-reporter' -require 'simplecov' +if ENV['COVERAGE'] + require 'coveralls' + require 'codeclimate-test-reporter' + require 'simplecov' -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( - [ - Coveralls::SimpleCov::Formatter, - SimpleCov::Formatter::HTMLFormatter, - CodeClimate::TestReporter::Formatter - ] -) + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( + [ + Coveralls::SimpleCov::Formatter, + SimpleCov::Formatter::HTMLFormatter, + CodeClimate::TestReporter::Formatter + ] + ) -SimpleCov.start + SimpleCov.start +end require 'rubygems' require 'bundler' From eddb4732b5a87387738ae09db521a184ce4c2d1d Mon Sep 17 00:00:00 2001 From: "Andrew W. Lee" Date: Sun, 29 Mar 2020 17:14:34 -0700 Subject: [PATCH 2/5] Use environment variable to run integration tests --- spec/integration/integration_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/integration/integration_helper.rb b/spec/integration/integration_helper.rb index b0c2094ee..79ce49a50 100644 --- a/spec/integration/integration_helper.rb +++ b/spec/integration/integration_helper.rb @@ -5,6 +5,8 @@ class IntegrationHelper }.freeze def self.able_to_run?(file_path, ruby_version) + return false unless ENV['INTEGRATION_TESTS'] + file_name = File.basename(file_path) rails_app = File.basename(file_name, '_spec.rb') ruby_dependency = MIN_RUBY_VERSIONS[rails_app] From 23797f78feaae090c960df5a188141da70b72ed7 Mon Sep 17 00:00:00 2001 From: "Andrew W. Lee" Date: Sun, 29 Mar 2020 17:48:26 -0700 Subject: [PATCH 3/5] Change tests in annotate_models_spec to not use wrong gem --- spec/lib/annotate/annotate_models_spec.rb | 35 ++++++----------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/spec/lib/annotate/annotate_models_spec.rb b/spec/lib/annotate/annotate_models_spec.rb index c3d0069e9..43f3dad69 100644 --- a/spec/lib/annotate/annotate_models_spec.rb +++ b/spec/lib/annotate/annotate_models_spec.rb @@ -4,6 +4,7 @@ require 'annotate/active_record_patch' require 'active_support/core_ext/string' require 'files' +require 'tmpdir' describe AnnotateModels do MAGIC_COMMENTS = [ @@ -1781,7 +1782,6 @@ def mock_column(name, type, options = {}) describe '.get_model_class' do before :all do - require 'tmpdir' AnnotateModels.model_dir = Dir.mktmpdir('annotate_models') end @@ -2137,7 +2137,6 @@ class Foo end let :tmpdir do - require 'tmpdir' Dir.mktmpdir('annotate_models') end @@ -2659,21 +2658,13 @@ class User < ActiveRecord::Base end it 'displays just the error message with trace disabled (default)' do - error_output = capturing(:stderr) do - AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true - end - - expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops") - expect(error_output).not_to include('/spec/annotate/annotate_models_spec.rb:') + expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true }.to output(a_string_including("Unable to annotate #{@model_dir}/user.rb: oops")).to_stderr + expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true }.not_to output(a_string_including('/spec/annotate/annotate_models_spec.rb:')).to_stderr end it 'displays the error message and stacktrace with trace enabled' do - error_output = capturing(:stderr) do - AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true - end - - expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops") - expect(error_output).to include('/spec/lib/annotate/annotate_models_spec.rb:') + expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("Unable to annotate #{@model_dir}/user.rb: oops")).to_stderr + expect { AnnotateModels.do_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including('/spec/lib/annotate/annotate_models_spec.rb:')).to_stderr end end @@ -2689,21 +2680,13 @@ class User < ActiveRecord::Base end it 'displays just the error message with trace disabled (default)' do - error_output = capturing(:stderr) do - AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true - end - - expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops") - expect(error_output).not_to include("/user.rb:2:in `'") + expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true }.to output(a_string_including("Unable to deannotate #{@model_dir}/user.rb: oops")).to_stderr + expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true }.not_to output(a_string_including("/user.rb:2:in `'")).to_stderr end it 'displays the error message and stacktrace with trace enabled' do - error_output = capturing(:stderr) do - AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true - end - - expect(error_output).to include("Unable to deannotate #{@model_dir}/user.rb: oops") - expect(error_output).to include("/user.rb:2:in `'") + expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("Unable to deannotate #{@model_dir}/user.rb: oops")).to_stderr + expect { AnnotateModels.remove_annotations model_dir: @model_dir, is_rake: true, trace: true }.to output(a_string_including("/user.rb:2:in `'")).to_stderr end end From 29ae298d0c621b33cd09b7af5730e5a1db75f9e8 Mon Sep 17 00:00:00 2001 From: "Andrew W. Lee" Date: Sun, 29 Mar 2020 17:49:31 -0700 Subject: [PATCH 4/5] Remove `wrong` gem from project --- Gemfile | 1 - spec/spec_helper.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 8e5150059..184fe0ba4 100644 --- a/Gemfile +++ b/Gemfile @@ -38,5 +38,4 @@ end group :test do gem 'files', require: false gem 'git', require: false - gem 'wrong', require: false end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 804d58264..5b68b3636 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,7 +20,6 @@ require 'rake' require 'rspec' -require 'wrong/adapters/rspec' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) From 2764565afb2ac26cfe8a8c97d4d20827c2d04904 Mon Sep 17 00:00:00 2001 From: "Andrew W. Lee" Date: Sun, 29 Mar 2020 17:52:45 -0700 Subject: [PATCH 5/5] Remove ruby-head from TravisCI build versions --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c6366248..17feb47ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ rvm: - 2.4.9 - 2.5.7 - 2.6.5 - - ruby-head env: - RAILS_ENV=development RACK_ENV=development