diff --git a/Gemfile b/Gemfile
index 97734d20dd234114906b5c7ea0abce24f785d7cd..fd570a0d48ea2e59afa670169640b8af5b20ea89 100644
--- a/Gemfile
+++ b/Gemfile
@@ -362,7 +362,7 @@ group :development, :test do
   # Generate Fake data
   gem 'ffaker', '~> 2.10'
 
-  gem 'capybara', '~> 2.18.0'
+  gem 'capybara', '~> 3.22.0'
   gem 'capybara-screenshot', '~> 1.0.22'
   gem 'selenium-webdriver', '~> 3.141'
 
diff --git a/Gemfile.lock b/Gemfile.lock
index 712b1fdc110b2bf38b8ed590216f90c7e971fffd..0adf49524b70dae3d363c704aa1b06537743aae8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -118,13 +118,14 @@ GEM
       bundler (~> 1.2)
       thor (~> 0.18)
     byebug (9.1.0)
-    capybara (2.18.0)
+    capybara (3.22.0)
       addressable
       mini_mime (>= 0.1.3)
-      nokogiri (>= 1.3.3)
-      rack (>= 1.0.0)
-      rack-test (>= 0.5.4)
-      xpath (>= 2.0, < 4.0)
+      nokogiri (~> 1.8)
+      rack (>= 1.6.0)
+      rack-test (>= 0.6.3)
+      regexp_parser (~> 1.5)
+      xpath (~> 3.2)
     capybara-screenshot (1.0.22)
       capybara (>= 1.0, < 4)
       launchy
@@ -689,7 +690,7 @@ GEM
       pry (~> 0.10)
     pry-rails (0.3.6)
       pry (>= 0.10.4)
-    public_suffix (3.0.3)
+    public_suffix (3.1.0)
     puma (3.12.0)
     puma_worker_killer (0.1.0)
       get_process_mem (~> 0.2)
@@ -781,7 +782,7 @@ GEM
       redis-store (>= 1.2, < 2)
     redis-store (1.6.0)
       redis (>= 2.2, < 5)
-    regexp_parser (1.4.0)
+    regexp_parser (1.5.1)
     regexp_property_values (0.3.4)
     representable (3.0.4)
       declarative (< 0.1.0)
@@ -1074,7 +1075,7 @@ DEPENDENCIES
   browser (~> 2.5)
   bullet (~> 5.5.0)
   bundler-audit (~> 0.5.0)
-  capybara (~> 2.18.0)
+  capybara (~> 3.22.0)
   capybara-screenshot (~> 1.0.22)
   carrierwave (~> 1.3)
   charlock_holmes (~> 0.7.5)
diff --git a/ee/spec/features/groups/group_settings_spec.rb b/ee/spec/features/groups/group_settings_spec.rb
index d14c58598f8a9c7d3da136a79e90fed46319bbbb..1ea5c6ab2c4dfba2342f09d0840abd32f211461a 100644
--- a/ee/spec/features/groups/group_settings_spec.rb
+++ b/ee/spec/features/groups/group_settings_spec.rb
@@ -174,7 +174,7 @@
             results = find_all('.select2-result')
 
             expect(results.count).to eq(1)
-            expect(results.last.text).to eq "#{nested_group.full_name} #{nested_group.full_path}"
+            expect(results.last.text).to eq "#{nested_group.full_name}\n#{nested_group.full_path}"
           end
         end
       end
diff --git a/ee/spec/features/projects/environments_pod_logs_spec.rb b/ee/spec/features/projects/environments_pod_logs_spec.rb
index dc07e2e6e0fd024566c4f9dba421e5a9bc448552..4b7a22209106700f3d40220bcdc98485afbb947f 100644
--- a/ee/spec/features/projects/environments_pod_logs_spec.rb
+++ b/ee/spec/features/projects/environments_pod_logs_spec.rb
@@ -38,7 +38,7 @@
           expect(item.text).to eq(pod_names[i])
         end
       end
-      expect(page).to have_content("Log 1\nLog 2\nLog 3")
+      expect(page).to have_content("Log 1 Log 2 Log 3")
     end
   end
 
diff --git a/ee/spec/features/projects/new_project_spec.rb b/ee/spec/features/projects/new_project_spec.rb
index 9c956dd0f9d9ba387b64b63ed1dabe0d1e539ee7..a3d6131b0b1c47a1288b5bc7bdd8d0e3d2f50d50 100644
--- a/ee/spec/features/projects/new_project_spec.rb
+++ b/ee/spec/features/projects/new_project_spec.rb
@@ -216,7 +216,7 @@ def visit_create_from_group_template_tab
         it 'the tab shows the list of templates available' do
           page.within('#custom-group-project-templates') do
             # Show templates in case they're collapsed
-            page.all(:xpath, "//div[@class='js-template-group-options template-group-options']").each(&:click)
+            page.all(:xpath, "//div[@class='js-template-group-options template-group-options']", wait: false).each(&:click)
 
             expect(page).to have_selector('.template-option', count: template_number)
           end
diff --git a/ee/spec/features/projects/services/prometheus_custom_metrics_spec.rb b/ee/spec/features/projects/services/prometheus_custom_metrics_spec.rb
index 1ea4ba2537debb2b603afcb792d1e67c3944bca7..97ac2e8b8cc239146cce45410911485c0f0554ed 100644
--- a/ee/spec/features/projects/services/prometheus_custom_metrics_spec.rb
+++ b/ee/spec/features/projects/services/prometheus_custom_metrics_spec.rb
@@ -1,10 +1,16 @@
 require 'spec_helper'
 
 describe 'Prometheus custom metrics', :js do
+  include PrometheusHelpers
+
   let(:project) { create(:project) }
   let(:user) { create(:user) }
   let!(:prometheus_metric) { create(:prometheus_metric, project: project) }
 
+  around do |example|
+    Timecop.freeze { example.run }
+  end
+
   before do
     project.add_maintainer(user)
     sign_in(user)
@@ -15,6 +21,8 @@
 
     click_link('Prometheus')
 
+    stub_request(:get, prometheus_query_with_time_url('avg(metric)', Time.now.utc))
+
     fill_in_prometheus_integration
 
     click_link('Prometheus')
@@ -22,7 +30,7 @@
 
   def fill_in_prometheus_integration
     check('Active')
-    fill_in('API URL', with: 'http://prometheus.example.com')
+    fill_in('API URL', with: 'https://prometheus.example.com')
     click_button('Save changes')
   end
 
diff --git a/ee/spec/features/projects/services/user_activates_github_spec.rb b/ee/spec/features/projects/services/user_activates_github_spec.rb
index 40c58a63efc1dc96aa0baaa7951a7a23ae8522f7..f35a23d12db0be377832076342698a8bb2553581 100644
--- a/ee/spec/features/projects/services/user_activates_github_spec.rb
+++ b/ee/spec/features/projects/services/user_activates_github_spec.rb
@@ -50,6 +50,11 @@ def fill_in_details
       let(:project) { create(:project, ci_pipelines: [pipeline])}
 
       it 'tests service before save' do
+        stub_request(:post, "https://api.github.com/repos/h5bp/html5-boilerplate/statuses/#{pipeline.sha}").to_return(
+          body: { context: {} }.to_json,
+          headers: { 'Content-Type' => 'application/json' }
+        )
+
         click_button 'Test settings and save changes'
         wait_for_requests
 
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 2adeb37c98a0776c85b8061fe6208c4d4b9aa8df..e6f44aa7d204d6bfea542b402ef77d26e619d699 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -82,7 +82,7 @@
 
           it 'shows pipeline`s data' do
             expect(page).to have_content pipeline.sha[0..7]
-            expect(page).to have_content pipeline.git_commit_message
+            expect(page).to have_content pipeline.git_commit_message.gsub!(/\s+/, ' ')
             expect(page).to have_content pipeline.user.name
           end
         end
@@ -125,7 +125,7 @@
 
         it 'Renders header', :js do
           expect(page).to have_content pipeline.sha[0..7]
-          expect(page).to have_content pipeline.git_commit_message
+          expect(page).to have_content pipeline.git_commit_message.gsub!(/\s+/, ' ')
           expect(page).to have_content pipeline.user.name
           expect(page).not_to have_link('Cancel running')
           expect(page).not_to have_link('Retry')
@@ -147,7 +147,7 @@
 
         it do
           expect(page).to have_content pipeline.sha[0..7]
-          expect(page).to have_content pipeline.git_commit_message
+          expect(page).to have_content pipeline.git_commit_message.gsub!(/\s+/, ' ')
           expect(page).to have_content pipeline.user.name
 
           expect(page).not_to have_link('Cancel running')
diff --git a/spec/features/ics/dashboard_issues_spec.rb b/spec/features/ics/dashboard_issues_spec.rb
index debae0ea930abc563d436f0cfa48dc2b63410f06..b74bbf848acdeb34147fad8135ffed45c4463765 100644
--- a/spec/features/ics/dashboard_issues_spec.rb
+++ b/spec/features/ics/dashboard_issues_spec.rb
@@ -91,7 +91,7 @@
 
         expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
         # line length for ics is 75 chars
-        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
+        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, ' ')
         expect(body).to have_text(expected_description)
         expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
         expect(body).to have_text("URL:#{issue_url(issue)}")
diff --git a/spec/features/ics/group_issues_spec.rb b/spec/features/ics/group_issues_spec.rb
index 4177c7f8704c1ced8f49d71cbdae30228abfdd06..86da720c8be87e3d9af91282dfd518b60015608c 100644
--- a/spec/features/ics/group_issues_spec.rb
+++ b/spec/features/ics/group_issues_spec.rb
@@ -66,7 +66,7 @@
 
         expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
         # line length for ics is 75 chars
-        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
+        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, ' ')
         expect(body).to have_text(expected_description)
         expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
         expect(body).to have_text("URL:#{issue_url(issue)}")
diff --git a/spec/features/ics/project_issues_spec.rb b/spec/features/ics/project_issues_spec.rb
index 0d9844be09990324e765bff84af1ed027ae29eb9..37b90c666bc1ad9bd0bb201aa546a4979db42a3f 100644
--- a/spec/features/ics/project_issues_spec.rb
+++ b/spec/features/ics/project_issues_spec.rb
@@ -65,7 +65,7 @@
 
         expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
         # line length for ics is 75 chars
-        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
+        expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, ' ')
         expect(body).to have_text(expected_description)
         expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
         expect(body).to have_text("URL:#{issue_url(issue)}")
diff --git a/spec/features/merge_request/user_accepts_merge_request_spec.rb b/spec/features/merge_request/user_accepts_merge_request_spec.rb
index 5fa23dbb99844b229ee7bb7e24ce7155db046cf9..3d029ccec1aaa9b87a3c8e3229d30dee8b0ddafa 100644
--- a/spec/features/merge_request/user_accepts_merge_request_spec.rb
+++ b/spec/features/merge_request/user_accepts_merge_request_spec.rb
@@ -15,8 +15,7 @@
 
     click_button('Merge')
 
-    expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with \
-                                 #{merge_request.short_merge_commit_sha}")
+    expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with #{merge_request.short_merge_commit_sha}")
   end
 
   context 'with removing the source branch' do
diff --git a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
index 5db54f42264c23ecdee1ad0e277ed2b40dcb8cfc..3a9a06a6bc3021e7b5490558843985c048a7420f 100644
--- a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
@@ -313,7 +313,7 @@ def drag_and_drop_by(element, right_by, down_by)
 
   def create_image_diff_note
     expand_text = 'Click to expand it.'
-    page.all('a', text: expand_text).each do |element|
+    page.all('a', text: expand_text, wait: false).each do |element|
       element.click
     end
 
diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb
index 04b075259194b49308d2ba8c72991f34e3ed3601..8dc5912b8be2615b3b054d2401c915e52eb6e7bc 100644
--- a/spec/features/merge_request/user_sees_diff_spec.rb
+++ b/spec/features/merge_request/user_sees_diff_spec.rb
@@ -43,8 +43,7 @@
       visit diffs_project_merge_request_path(project, merge_request)
 
       page.within('.alert') do
-        expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve
-          performance only 3 of 3+ files are displayed.")
+        expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve performance only 3 of 3+ files are displayed.")
       end
     end
   end
diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index 0066e985fbb097ba4d81cd12f102e10b4a8bfe10..393077a916f342098498ba8c50b9e29926cbfd3a 100644
--- a/spec/features/merge_request/user_sees_merge_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -565,7 +565,7 @@ def compared_data
                 click_button 'subtractTest'
 
                 expect(page).to have_content('6.66')
-                expect(page).to have_content(sample_java_failed_message)
+                expect(page).to have_content(sample_java_failed_message.gsub!(/\s+/, ' ').strip)
               end
             end
           end
@@ -610,7 +610,7 @@ def compared_data
                 click_button 'Test#sum when a is 2 and b is 2 returns summary'
 
                 expect(page).to have_content('2.22')
-                expect(page).to have_content(sample_rspec_failed_message)
+                expect(page).to have_content(sample_rspec_failed_message.gsub!(/\s+/, ' ').strip)
               end
             end
           end
diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
index 04c7f4b6c768be750089efa851a2af134393980c..780de76d2c5ad506da796f312b03e7d43ca20be1 100644
--- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
+++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
@@ -7,8 +7,8 @@
   include RepoHelpers
 
   def expect_suggestion_has_content(element, expected_changing_content, expected_suggested_content)
-    changing_content = element.all(:css, '.line_holder.old').map(&:text)
-    suggested_content = element.all(:css, '.line_holder.new').map(&:text)
+    changing_content = element.all(:css, '.line_holder.old').map { |el| el.text(normalize_ws: true) }
+    suggested_content = element.all(:css, '.line_holder.new').map { |el| el.text(normalize_ws: true) }
 
     expect(changing_content).to eq(expected_changing_content)
     expect(suggested_content).to eq(expected_suggested_content)
diff --git a/spec/features/projects/commits/user_browses_commits_spec.rb b/spec/features/projects/commits/user_browses_commits_spec.rb
index 953517cdff91afe833465692c3965ecff1205880..a84fee34669aca00d1e57c1877118385538e6134 100644
--- a/spec/features/projects/commits/user_browses_commits_spec.rb
+++ b/spec/features/projects/commits/user_browses_commits_spec.rb
@@ -13,7 +13,7 @@
   it 'renders commit' do
     visit project_commit_path(project, sample_commit.id)
 
-    expect(page).to have_content(sample_commit.message)
+    expect(page).to have_content(sample_commit.message.gsub!(/\s+/, ' '))
       .and have_content("Showing #{sample_commit.files_changed_count} changed files")
       .and have_content('Side-by-side')
   end
diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb
index ab16fdee88350eaaa1cae9dbe25f436c925dd919..254e885ce4622bdeb8b36d8107d22f2c39c172c2 100644
--- a/spec/features/projects/features_visibility_spec.rb
+++ b/spec/features/projects/features_visibility_spec.rb
@@ -68,7 +68,8 @@
       end
 
       it "hides builds when disabled" do
-        allow(Ability).to receive(:allowed?).with(member, :read_builds, project).and_return(false)
+        allow(Ability).to receive(:allowed?).and_return(true)
+        allow(Ability).to receive(:allowed?).with(member, :read_build, project).and_return(false)
 
         visit project_pipelines_path(project)
 
diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb
index fa785ed10effbf096c7b68e60f3e5b70849a0ece..9161814539167928202f73a6c1af2e95955be202 100644
--- a/spec/features/projects/files/undo_template_spec.rb
+++ b/spec/features/projects/files/undo_template_spec.rb
@@ -50,7 +50,7 @@ def check_undo_button_display
 def check_content_reverted(template_content)
   find('.template-selectors-undo-menu .btn-info').click
   expect(page).not_to have_content(template_content)
-  expect(find('.template-type-selector .dropdown-toggle-text')).to have_content
+  expect(page).to have_css('.template-type-selector .dropdown-toggle-text')
 end
 
 def select_file_template(template_selector_selector, template_name)
diff --git a/spec/features/projects/files/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb
index 69f8bd4d3197216c05b03dda043b7cdb5cd09cd3..264b288ab38fbb2cec7f9cd1bbfffe825e554cc1 100644
--- a/spec/features/projects/files/user_creates_files_spec.rb
+++ b/spec/features/projects/files/user_creates_files_spec.rb
@@ -174,7 +174,6 @@ def submit_new_file(options)
 
       it 'creates and commit new file in forked project', :js do
         expect(page).to have_selector('.file-editor')
-        expect(page).to have_content
 
         find('#editor')
         execute_script("ace.edit('editor').setValue('*.rbca')")
diff --git a/spec/features/projects/labels/user_removes_labels_spec.rb b/spec/features/projects/labels/user_removes_labels_spec.rb
index c231e54decd0aa86836bfb5c9badac194974113f..7f49ddf560f89a6190968a96862083eba223fbe8 100644
--- a/spec/features/projects/labels/user_removes_labels_spec.rb
+++ b/spec/features/projects/labels/user_removes_labels_spec.rb
@@ -41,7 +41,7 @@
 
     it "removes all labels" do
       loop do
-        li = page.first(".label-list-item")
+        li = page.first(".label-list-item", minimum: 0)
         break unless li
 
         li.find('.js-label-options-dropdown').click
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index 1de153db41c3c97bec2ac4c245ac8360650d4c24..77f0f237d0a61031325831accb8f907fb6f02ae0 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -91,7 +91,7 @@
 
       within '.pipeline-info' do
         expect(page).to have_content("#{pipeline.statuses.count} jobs " \
-                                      "for #{pipeline.ref} ")
+                                      "for #{pipeline.ref}")
         expect(page).to have_link(pipeline.ref,
           href: project_commits_path(pipeline.project, pipeline.ref))
       end
diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb
index 32959969f54fd1d427d7c4f46be27f2ba21287f7..016ccf63f5884bb571640e3542ae8ac873929065 100644
--- a/spec/features/projects/settings/integration_settings_spec.rb
+++ b/spec/features/projects/settings/integration_settings_spec.rb
@@ -41,7 +41,7 @@
         expect(page).to have_content('Issues events')
         expect(page).to have_content('Confidential issues events')
         expect(page).to have_content('Note events')
-        expect(page).to have_content('Merge requests  events')
+        expect(page).to have_content('Merge requests events')
         expect(page).to have_content('Pipeline events')
         expect(page).to have_content('Wiki page events')
       end
diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb
index dcf7d314f8ed4d7a39f873dc620a5cfad3e41157..e5dd2f40fdf49493702ed676093af4c08f4c820e 100644
--- a/spec/features/projects/tree/upload_file_spec.rb
+++ b/spec/features/projects/tree/upload_file_spec.rb
@@ -29,6 +29,6 @@
     attach_file('file-upload', txt_file)
 
     expect(page).to have_selector('.multi-file-tab', text: 'doc_sample.txt')
-    expect(find('.blob-editor-container .lines-content')['innerText']).to have_content(File.open(txt_file, &:readline))
+    expect(find('.blob-editor-container .lines-content')['innerText']).to have_content(File.open(txt_file, &:readline).gsub!(/\s+/, ' '))
   end
 end
diff --git a/spec/features/search/user_searches_for_commits_spec.rb b/spec/features/search/user_searches_for_commits_spec.rb
index 28cae444588ef81bcd5d6ab91fd9af920c3a9da6..998f85213843751764abd37a3cc2ce76301a8a09 100644
--- a/spec/features/search/user_searches_for_commits_spec.rb
+++ b/spec/features/search/user_searches_for_commits_spec.rb
@@ -35,7 +35,7 @@
       fill_in('search', with: 'deadbeef')
       click_button('Search')
 
-      expect(page).to have_current_path('/search', only_path: true)
+      expect(page).to have_current_path('/search', ignore_query: true)
     end
 
     it 'finds multiple commits' do
diff --git a/spec/features/tags/master_creates_tag_spec.rb b/spec/features/tags/master_creates_tag_spec.rb
index db2970f33401e66955802f463de2eed0653bbdc1..f80ddd050d78b4c28cbf8fdc011917be92c98311 100644
--- a/spec/features/tags/master_creates_tag_spec.rb
+++ b/spec/features/tags/master_creates_tag_spec.rb
@@ -39,7 +39,7 @@
         project_tag_path(project, 'v3.0'))
       expect(page).to have_content 'v3.0'
       page.within 'pre.wrap' do
-        expect(page).to have_content "Awesome tag message\n\n- hello\n- world"
+        expect(page).to have_content "Awesome tag message - hello - world"
       end
     end
 
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index 14ce3c32e779e588a5ba01ad6f5eec4f0a2b91bd..56ac208a025ed23b5d345921d8fb5a4511bb51f1 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -53,9 +53,11 @@
   )
 end
 
+Capybara.server = :webrick
 Capybara.javascript_driver = :chrome
 Capybara.default_max_wait_time = timeout
 Capybara.ignore_hidden_elements = true
+Capybara.default_normalize_ws = true
 
 # Keep only the screenshots generated from the last failing test suite
 Capybara::Screenshot.prune_strategy = :keep_last_run
diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb
index 542f533d59046fd49453ff6ac9df883091dad2de..0f8af2c5d6df438625ab935b998334f76efe6123 100644
--- a/spec/support/features/discussion_comments_shared_example.rb
+++ b/spec/support/features/discussion_comments_shared_example.rb
@@ -84,7 +84,7 @@
       #
       # if dropdown menu is not toggled (and also not present),
       # it's "issue-type" dropdown
-      if first(menu_selector).nil?
+      if first(menu_selector, minimum: 0).nil?
         expect(find(dropdown_selector)).to have_content 'Comment'
 
         find(toggle_selector).click
diff --git a/spec/support/shared_examples/quick_actions/issuable/shrug_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issuable/shrug_quick_action_shared_examples.rb
index 0a5268085853f6e2c37aaf3536f6a88b13d44baa..b592cf16f67101fbe82c74f32e7c7cae189c89ba 100644
--- a/spec/support/shared_examples/quick_actions/issuable/shrug_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issuable/shrug_quick_action_shared_examples.rb
@@ -27,7 +27,7 @@
 
       expect(issuable.description).to eq "bug description\noops ¯\\_(ツ)_/¯"
       expect(page).to have_content 'bug 345'
-      expect(page).to have_content "bug description\noops ¯\\_(ツ)_/¯"
+      expect(page).to have_content "bug description oops ¯\\_(ツ)_/¯"
     end
   end
 
diff --git a/spec/support/shared_examples/quick_actions/issuable/tableflip_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issuable/tableflip_quick_action_shared_examples.rb
index ef831e39872e8e96a46f187b8d99303b084ce9b2..c174127c4ffbd47644d4052da8a344a618fbd821 100644
--- a/spec/support/shared_examples/quick_actions/issuable/tableflip_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issuable/tableflip_quick_action_shared_examples.rb
@@ -27,7 +27,7 @@
 
       expect(issuable.description).to eq "bug description\noops (╯°□°)╯︵ ┻━┻"
       expect(page).to have_content 'bug 345'
-      expect(page).to have_content "bug description\noops (╯°□°)╯︵ ┻━┻"
+      expect(page).to have_content "bug description oops (╯°□°)╯︵ ┻━┻"
     end
   end
 
diff --git a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
index d9d73f789c5c1c24f0530c9838be315de8150bd8..d04affc7df1e37f548fa1a545f8c6cea2517683e 100644
--- a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
@@ -28,7 +28,7 @@
 
       expect(rendered).to have_content "Your pipeline has failed"
       expect(rendered).to have_content pipeline.project.name
-      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
+      expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub!(/\s+/, ' ')
       expect(rendered).to have_content pipeline.commit.author_name
       expect(rendered).to have_content "##{pipeline.id}"
       expect(rendered).to have_content pipeline.user.name
@@ -45,7 +45,7 @@
 
       expect(rendered).to have_content "Your pipeline has failed"
       expect(rendered).to have_content pipeline.project.name
-      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
+      expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub!(/\s+/, ' ')
       expect(rendered).to have_content pipeline.commit.author_name
       expect(rendered).to have_content "##{pipeline.id}"
       expect(rendered).to have_content "by API"
diff --git a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
index a7d3dc09fd47f2517007e643a0fcf08864fc1b78..079fb865d7b66759b4b6e54a61a2ff1b3a5eedf3 100644
--- a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
@@ -30,7 +30,7 @@
 
     expect(rendered).to have_content('Your pipeline has failed')
     expect(rendered).to have_content(pipeline.project.name)
-    expect(rendered).to have_content(pipeline.git_commit_message.truncate(50))
+    expect(rendered).to have_content(pipeline.git_commit_message.truncate(50).gsub!(/\s+/, ' '))
     expect(rendered).to have_content(pipeline.commit.author_name)
     expect(rendered).to have_content("##{pipeline.id}")
     expect(rendered).to have_content(pipeline.user.name)
diff --git a/spec/views/notify/pipeline_success_email.html.haml_spec.rb b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
index a793b37e41223542b05bc3c2296ce126ee086c2a..8ee7f954d701d250ee5fce65ed37d6684c453391 100644
--- a/spec/views/notify/pipeline_success_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
@@ -28,7 +28,7 @@
 
       expect(rendered).to have_content "Your pipeline has passed"
       expect(rendered).to have_content pipeline.project.name
-      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
+      expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub!(/\s+/, ' ')
       expect(rendered).to have_content pipeline.commit.author_name
       expect(rendered).to have_content "##{pipeline.id}"
       expect(rendered).to have_content pipeline.user.name
@@ -45,7 +45,7 @@
 
       expect(rendered).to have_content "Your pipeline has passed"
       expect(rendered).to have_content pipeline.project.name
-      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
+      expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub!(/\s+/, ' ')
       expect(rendered).to have_content pipeline.commit.author_name
       expect(rendered).to have_content "##{pipeline.id}"
       expect(rendered).to have_content "by API"
diff --git a/spec/views/profiles/show.html.haml_spec.rb b/spec/views/profiles/show.html.haml_spec.rb
index e89a8cb962659e23e4f0841e943626835e2ade4a..9e7ac0b84fa6755bd78554f32b1fc81380597081 100644
--- a/spec/views/profiles/show.html.haml_spec.rb
+++ b/spec/views/profiles/show.html.haml_spec.rb
@@ -12,8 +12,8 @@
     it 'displays the correct elements' do
       render
 
-      expect(rendered).to have_field('user_name', user.name)
-      expect(rendered).to have_field('user_id', user.id)
+      expect(rendered).to have_field('user_name', with: user.name)
+      expect(rendered).to have_field('user_id', with: user.id)
     end
   end
 end