From 5f7592d53805b18fbbc2a117ab8b4d953b13dbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 9 Mar 2017 00:41:02 +0100 Subject: Implement `json_response` as a `let` variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not a good idea to memoize `json_response` using an instance variable because `rspec-retry` doesn't clear instance variables on retries, only `let` variables. This will avoid issues where retries would fail on a different line that the original failure, blurrying what's the real failure. Also, automatically add api: true to specs under /spec/requests/(ci/)?api/, and include JsonHelpers in controller, request and API specs. Signed-off-by: Rémy Coutable --- spec/spec_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5fda7c63cdb..068984aee84 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -43,8 +43,14 @@ RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers config.include StubGitlabCalls config.include StubGitlabData + config.include ApiHelpers, :api config.infer_spec_type_from_file_location! + + config.define_derived_metadata(file_path: %r{/spec/requests/(ci/)?api/}) do |metadata| + metadata[:api] = true + end + config.raise_errors_for_deprecations! config.before(:suite) do -- cgit v1.2.1 From 1761da5152e460549e0e827990ea4f36d097db33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 9 Mar 2017 13:12:28 +0100 Subject: Retry only on feature specs that use JS, on CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/spec_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 068984aee84..ceb3209331f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,6 +57,13 @@ RSpec.configure do |config| TestEnv.init end + if ENV['CI'] + # Retry only on feature specs that use JS + config.around :each, :js do |ex| + ex.run_with_retry retry: 3 + end + end + config.around(:each, :caching) do |example| caching_store = Rails.cache Rails.cache = ActiveSupport::Cache::MemoryStore.new if example.metadata[:caching] -- cgit v1.2.1