From 60be1d6deff0751a2cd2a6a3051b21cffa4da65c Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Mon, 22 Feb 2021 11:20:16 -0500 Subject: [PATCH] Add flaky tags & retry in specs (#12750) --- spec/rails_helper.rb | 4 ++++ spec/services/articles/suggest_spec.rb | 2 +- spec/system/articles/user_creates_an_article_spec.rb | 2 +- spec/system/podcasts/user_visits_podcast_episode_spec.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a9373b2a6..fc4a6aba0 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -115,6 +115,10 @@ RSpec.configure do |config| allow(Search::Client).to receive(:index).and_return({ "_source" => {} }) end + config.around(:each, :flaky) do |ex| + ex.run_with_retry retry: 3 + end + config.around(:each, elasticsearch_reset: true) do |example| Search::Cluster.recreate_indexes example.run diff --git a/spec/services/articles/suggest_spec.rb b/spec/services/articles/suggest_spec.rb index 95fd93dbf..0a6b72c5f 100644 --- a/spec/services/articles/suggest_spec.rb +++ b/spec/services/articles/suggest_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Articles::Suggest, type: :service do expect(described_class.call(article).size).to eq(4) end - it "returns proper number of articles with post with different tags" do + it "returns proper number of articles with post with different tags", :flaky do create_list(:article, 2, featured: true, tags: ["discuss"], score: 10) create_list(:article, 2, featured: true, tags: ["javascript"]) article = create(:article, featured: true, tags: ["discuss"]) diff --git a/spec/system/articles/user_creates_an_article_spec.rb b/spec/system/articles/user_creates_an_article_spec.rb index 2f8e9a8fb..2d52f852c 100644 --- a/spec/system/articles/user_creates_an_article_spec.rb +++ b/spec/system/articles/user_creates_an_article_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "Creating an article with the editor", type: :system do sign_in user end - it "creates a new article", js: true, retry: 3 do + it "creates a new article", :flaky, js: true do visit new_path fill_in "article_body_markdown", with: template click_button "Save changes" diff --git a/spec/system/podcasts/user_visits_podcast_episode_spec.rb b/spec/system/podcasts/user_visits_podcast_episode_spec.rb index 83a3d572e..001a8cefc 100644 --- a/spec/system/podcasts/user_visits_podcast_episode_spec.rb +++ b/spec/system/podcasts/user_visits_podcast_episode_spec.rb @@ -14,7 +14,7 @@ RSpec.describe "User visits podcast show page", type: :system, js: true do expect(result).to be false end - it "they see the content of the hero", js: true, retry: 3 do + it "they see the content of the hero", :flaky, js: true do visit podcast_episode.path.to_s expect(page).to have_text(podcast_episode.title)