From a80c9641214c2936cf592b162af5087d18ee6184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 6 Sep 2021 23:49:23 +0200 Subject: [PATCH 1/2] Add folders for custom tests We were offering ways to easily add custom Ruby code, but didn't offer ways to easily add tests for this custom code. --- spec/components/custom/.keep | 0 spec/controllers/custom/.keep | 0 spec/routing/custom/.keep | 0 spec/system/custom/.keep | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 spec/components/custom/.keep create mode 100644 spec/controllers/custom/.keep create mode 100644 spec/routing/custom/.keep create mode 100644 spec/system/custom/.keep diff --git a/spec/components/custom/.keep b/spec/components/custom/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/spec/controllers/custom/.keep b/spec/controllers/custom/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/spec/routing/custom/.keep b/spec/routing/custom/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/spec/system/custom/.keep b/spec/system/custom/.keep new file mode 100644 index 000000000..e69de29bb From fed82b0024b8547492f1ae8dd587e1bdf326c1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 6 Sep 2021 23:52:38 +0200 Subject: [PATCH 2/2] Add a way to mark tests as consul/consul exclusive Until now, when institutions made custom changes which made certain tests obsolete, they didn't have a clear way to deal with the failing tests. They would either: 1. Stop running the test suite 2. Run the test suite and get test failures 100% of the time 3. Comment the failing tests 4. Modify the failing tests in order to keep them in sync with the code Solution 1 would be suicide from a maintenance perspective, although it could work if only a couple of small custom changes were done. Solution 2 would make it really hard to differenciate between "false failures" and "real failures" when running the test suite. Solution 3 would cause many conflicts when updating to a newer version of Consul. Solution 4 could make sense sometimes (big tests where only one line needs to be changed), but it would also cause conflicts when updating Consul. So now, we're giving an alternative to solution 3 by making it easier to exclude a test. For tests that still need to be changed, when to use this solution combined with a custom test and when to use solution 4 will have to be decided on a per-case basis. --- spec/custom_spec_helper.rb | 9 +++++++++ spec/rails_helper.rb | 1 + 2 files changed, 10 insertions(+) create mode 100644 spec/custom_spec_helper.rb diff --git a/spec/custom_spec_helper.rb b/spec/custom_spec_helper.rb new file mode 100644 index 000000000..b6ddad332 --- /dev/null +++ b/spec/custom_spec_helper.rb @@ -0,0 +1,9 @@ +RSpec.configure do |config| + # Add the :consul tag to tests which make sense in the original + # version of CONSUL but don't make sense in your application due to + # the custom changes you've implemented. + # + # Using this tag will help maintaining the test suite when doing + # custom changes and when upgrading to a newer version of CONSUL + config.filter_run_excluding consul: true +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6714ebdb4..5d8e11d91 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -8,6 +8,7 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ require "rspec/rails" require "spec_helper" +require "custom_spec_helper" require "capybara/rails" require "capybara/rspec" require "selenium/webdriver"