Commit 96ed5a8b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Upgrade to Capybara 3

Fix whitespace in specs because normalize_ws is slightly
different from Capybara 2 behavior
parent 06e89d78
...@@ -347,7 +347,7 @@ group :development, :test do ...@@ -347,7 +347,7 @@ group :development, :test do
# Generate Fake data # Generate Fake data
gem 'ffaker', '~> 2.10' gem 'ffaker', '~> 2.10'
gem 'capybara', '~> 2.18.0' gem 'capybara', '~> 3.22.0'
gem 'capybara-screenshot', '~> 1.0.22' gem 'capybara-screenshot', '~> 1.0.22'
gem 'selenium-webdriver', '~> 3.141' gem 'selenium-webdriver', '~> 3.141'
......
...@@ -110,13 +110,14 @@ GEM ...@@ -110,13 +110,14 @@ GEM
bundler (~> 1.2) bundler (~> 1.2)
thor (~> 0.18) thor (~> 0.18)
byebug (9.1.0) byebug (9.1.0)
capybara (2.18.0) capybara (3.22.0)
addressable addressable
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3) nokogiri (~> 1.8)
rack (>= 1.0.0) rack (>= 1.6.0)
rack-test (>= 0.5.4) rack-test (>= 0.6.3)
xpath (>= 2.0, < 4.0) regexp_parser (~> 1.5)
xpath (~> 3.2)
capybara-screenshot (1.0.22) capybara-screenshot (1.0.22)
capybara (>= 1.0, < 4) capybara (>= 1.0, < 4)
launchy launchy
...@@ -658,7 +659,7 @@ GEM ...@@ -658,7 +659,7 @@ GEM
pry (~> 0.10) pry (~> 0.10)
pry-rails (0.3.6) pry-rails (0.3.6)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (3.0.3) public_suffix (3.1.0)
puma (3.12.0) puma (3.12.0)
puma_worker_killer (0.1.0) puma_worker_killer (0.1.0)
get_process_mem (~> 0.2) get_process_mem (~> 0.2)
...@@ -750,7 +751,7 @@ GEM ...@@ -750,7 +751,7 @@ GEM
redis-store (>= 1.2, < 2) redis-store (>= 1.2, < 2)
redis-store (1.6.0) redis-store (1.6.0)
redis (>= 2.2, < 5) redis (>= 2.2, < 5)
regexp_parser (1.4.0) regexp_parser (1.5.1)
regexp_property_values (0.3.4) regexp_property_values (0.3.4)
representable (3.0.4) representable (3.0.4)
declarative (< 0.1.0) declarative (< 0.1.0)
...@@ -1040,7 +1041,7 @@ DEPENDENCIES ...@@ -1040,7 +1041,7 @@ DEPENDENCIES
browser (~> 2.5) browser (~> 2.5)
bullet (~> 5.5.0) bullet (~> 5.5.0)
bundler-audit (~> 0.5.0) bundler-audit (~> 0.5.0)
capybara (~> 2.18.0) capybara (~> 3.22.0)
capybara-screenshot (~> 1.0.22) capybara-screenshot (~> 1.0.22)
carrierwave (~> 1.3) carrierwave (~> 1.3)
charlock_holmes (~> 0.7.5) charlock_holmes (~> 0.7.5)
......
...@@ -82,7 +82,7 @@ describe 'Commits' do ...@@ -82,7 +82,7 @@ describe 'Commits' do
it 'shows pipeline`s data' do it 'shows pipeline`s data' do
expect(page).to have_content pipeline.sha[0..7] 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).to have_content pipeline.user.name
end end
end end
...@@ -125,7 +125,7 @@ describe 'Commits' do ...@@ -125,7 +125,7 @@ describe 'Commits' do
it 'Renders header', :js do it 'Renders header', :js do
expect(page).to have_content pipeline.sha[0..7] 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).to have_content pipeline.user.name
expect(page).not_to have_link('Cancel running') expect(page).not_to have_link('Cancel running')
expect(page).not_to have_link('Retry') expect(page).not_to have_link('Retry')
...@@ -147,7 +147,7 @@ describe 'Commits' do ...@@ -147,7 +147,7 @@ describe 'Commits' do
it do it do
expect(page).to have_content pipeline.sha[0..7] 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).to have_content pipeline.user.name
expect(page).not_to have_link('Cancel running') expect(page).not_to have_link('Cancel running')
......
...@@ -91,7 +91,7 @@ describe 'Dashboard Issues Calendar Feed' do ...@@ -91,7 +91,7 @@ describe 'Dashboard Issues Calendar Feed' do
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})") expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars # 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(expected_description)
expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}") expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
expect(body).to have_text("URL:#{issue_url(issue)}") expect(body).to have_text("URL:#{issue_url(issue)}")
......
...@@ -66,7 +66,7 @@ describe 'Group Issues Calendar Feed' do ...@@ -66,7 +66,7 @@ describe 'Group Issues Calendar Feed' do
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})") expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars # 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(expected_description)
expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}") expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
expect(body).to have_text("URL:#{issue_url(issue)}") expect(body).to have_text("URL:#{issue_url(issue)}")
......
...@@ -65,7 +65,7 @@ describe 'Project Issues Calendar Feed' do ...@@ -65,7 +65,7 @@ describe 'Project Issues Calendar Feed' do
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})") expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars # 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(expected_description)
expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}") expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
expect(body).to have_text("URL:#{issue_url(issue)}") expect(body).to have_text("URL:#{issue_url(issue)}")
......
...@@ -15,8 +15,7 @@ describe 'User accepts a merge request', :js do ...@@ -15,8 +15,7 @@ describe 'User accepts a merge request', :js do
click_button('Merge') click_button('Merge')
expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with \ expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with #{merge_request.short_merge_commit_sha}")
#{merge_request.short_merge_commit_sha}")
end end
context 'with removing the source branch' do context 'with removing the source branch' do
......
...@@ -313,7 +313,7 @@ describe 'Merge request > User creates image diff notes', :js do ...@@ -313,7 +313,7 @@ describe 'Merge request > User creates image diff notes', :js do
def create_image_diff_note def create_image_diff_note
expand_text = 'Click to expand it.' 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 element.click
end end
......
...@@ -43,8 +43,7 @@ describe 'Merge request > User sees diff', :js do ...@@ -43,8 +43,7 @@ describe 'Merge request > User sees diff', :js do
visit diffs_project_merge_request_path(project, merge_request) visit diffs_project_merge_request_path(project, merge_request)
page.within('.alert') do page.within('.alert') do
expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve performance only 3 of 3+ files are displayed.")
performance only 3 of 3+ files are displayed.")
end end
end end
end end
......
...@@ -565,7 +565,7 @@ describe 'Merge request > User sees merge widget', :js do ...@@ -565,7 +565,7 @@ describe 'Merge request > User sees merge widget', :js do
click_button 'subtractTest' click_button 'subtractTest'
expect(page).to have_content('6.66') 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 end
end end
...@@ -610,7 +610,7 @@ describe 'Merge request > User sees merge widget', :js do ...@@ -610,7 +610,7 @@ describe 'Merge request > User sees merge widget', :js do
click_button 'Test#sum when a is 2 and b is 2 returns summary' 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('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 end
end end
......
...@@ -7,8 +7,8 @@ describe 'User comments on a diff', :js do ...@@ -7,8 +7,8 @@ describe 'User comments on a diff', :js do
include RepoHelpers include RepoHelpers
def expect_suggestion_has_content(element, expected_changing_content, expected_suggested_content) def expect_suggestion_has_content(element, expected_changing_content, expected_suggested_content)
changing_content = element.all(:css, '.line_holder.old').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(&:text) suggested_content = element.all(:css, '.line_holder.new').map { |el| el.text(normalize_ws: true) }
expect(changing_content).to eq(expected_changing_content) expect(changing_content).to eq(expected_changing_content)
expect(suggested_content).to eq(expected_suggested_content) expect(suggested_content).to eq(expected_suggested_content)
......
...@@ -13,7 +13,7 @@ describe 'User browses commits' do ...@@ -13,7 +13,7 @@ describe 'User browses commits' do
it 'renders commit' do it 'renders commit' do
visit project_commit_path(project, sample_commit.id) 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("Showing #{sample_commit.files_changed_count} changed files")
.and have_content('Side-by-side') .and have_content('Side-by-side')
end end
......
...@@ -68,7 +68,8 @@ describe 'Edit Project Settings' do ...@@ -68,7 +68,8 @@ describe 'Edit Project Settings' do
end end
it "hides builds when disabled" do 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) visit project_pipelines_path(project)
......
...@@ -50,7 +50,7 @@ end ...@@ -50,7 +50,7 @@ end
def check_content_reverted(template_content) def check_content_reverted(template_content)
find('.template-selectors-undo-menu .btn-info').click find('.template-selectors-undo-menu .btn-info').click
expect(page).not_to have_content(template_content) 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 end
def select_file_template(template_selector_selector, template_name) def select_file_template(template_selector_selector, template_name)
......
...@@ -174,7 +174,6 @@ describe 'Projects > Files > User creates files' do ...@@ -174,7 +174,6 @@ describe 'Projects > Files > User creates files' do
it 'creates and commit new file in forked project', :js do it 'creates and commit new file in forked project', :js do
expect(page).to have_selector('.file-editor') expect(page).to have_selector('.file-editor')
expect(page).to have_content
find('#editor') find('#editor')
execute_script("ace.edit('editor').setValue('*.rbca')") execute_script("ace.edit('editor').setValue('*.rbca')")
......
...@@ -41,7 +41,7 @@ describe "User removes labels" do ...@@ -41,7 +41,7 @@ describe "User removes labels" do
it "removes all labels" do it "removes all labels" do
loop do loop do
li = page.first(".label-list-item") li = page.first(".label-list-item", minimum: 0)
break unless li break unless li
li.find('.js-label-options-dropdown').click li.find('.js-label-options-dropdown').click
......
...@@ -91,7 +91,7 @@ describe 'Pipeline', :js do ...@@ -91,7 +91,7 @@ describe 'Pipeline', :js do
within '.pipeline-info' do within '.pipeline-info' do
expect(page).to have_content("#{pipeline.statuses.count} jobs " \ expect(page).to have_content("#{pipeline.statuses.count} jobs " \
"for #{pipeline.ref} ") "for #{pipeline.ref}")
expect(page).to have_link(pipeline.ref, expect(page).to have_link(pipeline.ref,
href: project_commits_path(pipeline.project, pipeline.ref)) href: project_commits_path(pipeline.project, pipeline.ref))
end end
......
...@@ -29,6 +29,6 @@ describe 'Multi-file editor upload file', :js do ...@@ -29,6 +29,6 @@ describe 'Multi-file editor upload file', :js do
attach_file('file-upload', txt_file) attach_file('file-upload', txt_file)
expect(page).to have_selector('.multi-file-tab', text: 'doc_sample.txt') 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
end end
...@@ -35,7 +35,7 @@ describe 'User searches for commits' do ...@@ -35,7 +35,7 @@ describe 'User searches for commits' do
fill_in('search', with: 'deadbeef') fill_in('search', with: 'deadbeef')
click_button('Search') click_button('Search')
expect(page).to have_current_path('/search', only_path: true) expect(page).to have_current_path('/search', ignore_query: true)
end end
it 'finds multiple commits' do it 'finds multiple commits' do
......
...@@ -39,7 +39,7 @@ describe 'Maintainer creates tag' do ...@@ -39,7 +39,7 @@ describe 'Maintainer creates tag' do
project_tag_path(project, 'v3.0')) project_tag_path(project, 'v3.0'))
expect(page).to have_content 'v3.0' expect(page).to have_content 'v3.0'
page.within 'pre.wrap' do 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
end end
......
...@@ -53,9 +53,11 @@ Capybara.register_driver :chrome do |app| ...@@ -53,9 +53,11 @@ Capybara.register_driver :chrome do |app|
) )
end end
Capybara.server = :webrick
Capybara.javascript_driver = :chrome Capybara.javascript_driver = :chrome
Capybara.default_max_wait_time = timeout Capybara.default_max_wait_time = timeout
Capybara.ignore_hidden_elements = true Capybara.ignore_hidden_elements = true
Capybara.default_normalize_ws = true
# Keep only the screenshots generated from the last failing test suite # Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run Capybara::Screenshot.prune_strategy = :keep_last_run
......
...@@ -84,7 +84,7 @@ shared_examples 'discussion comments' do |resource_name| ...@@ -84,7 +84,7 @@ shared_examples 'discussion comments' do |resource_name|
# #
# if dropdown menu is not toggled (and also not present), # if dropdown menu is not toggled (and also not present),
# it's "issue-type" dropdown # 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' expect(find(dropdown_selector)).to have_content 'Comment'
find(toggle_selector).click find(toggle_selector).click
......
...@@ -27,7 +27,7 @@ shared_examples 'shrug quick action' do |issuable_type| ...@@ -27,7 +27,7 @@ shared_examples 'shrug quick action' do |issuable_type|
expect(issuable.description).to eq "bug description\noops ¯\\_(ツ)_/¯" expect(issuable.description).to eq "bug description\noops ¯\\_(ツ)_/¯"
expect(page).to have_content 'bug 345' 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
end end
......
...@@ -27,7 +27,7 @@ shared_examples 'tableflip quick action' do |issuable_type| ...@@ -27,7 +27,7 @@ shared_examples 'tableflip quick action' do |issuable_type|
expect(issuable.description).to eq "bug description\noops (╯°□°)╯︵ ┻━┻" expect(issuable.description).to eq "bug description\noops (╯°□°)╯︵ ┻━┻"
expect(page).to have_content 'bug 345' 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
end end
......
...@@ -28,7 +28,7 @@ describe 'notify/pipeline_failed_email.html.haml' do ...@@ -28,7 +28,7 @@ describe 'notify/pipeline_failed_email.html.haml' do
expect(rendered).to have_content "Your pipeline has failed" expect(rendered).to have_content "Your pipeline has failed"
expect(rendered).to have_content pipeline.project.name 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.commit.author_name
expect(rendered).to have_content "##{pipeline.id}" expect(rendered).to have_content "##{pipeline.id}"
expect(rendered).to have_content pipeline.user.name expect(rendered).to have_content pipeline.user.name
...@@ -45,7 +45,7 @@ describe 'notify/pipeline_failed_email.html.haml' do ...@@ -45,7 +45,7 @@ describe 'notify/pipeline_failed_email.html.haml' do
expect(rendered).to have_content "Your pipeline has failed" expect(rendered).to have_content "Your pipeline has failed"
expect(rendered).to have_content pipeline.project.name 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.commit.author_name
expect(rendered).to have_content "##{pipeline.id}" expect(rendered).to have_content "##{pipeline.id}"
expect(rendered).to have_content "by API" expect(rendered).to have_content "by API"
......
...@@ -30,7 +30,7 @@ describe 'notify/pipeline_failed_email.text.erb' do ...@@ -30,7 +30,7 @@ describe 'notify/pipeline_failed_email.text.erb' do
expect(rendered).to have_content('Your pipeline has failed') expect(rendered).to have_content('Your pipeline has failed')
expect(rendered).to have_content(pipeline.project.name) 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.commit.author_name)
expect(rendered).to have_content("##{pipeline.id}") expect(rendered).to have_content("##{pipeline.id}")
expect(rendered).to have_content(pipeline.user.name) expect(rendered).to have_content(pipeline.user.name)
......
...@@ -28,7 +28,7 @@ describe 'notify/pipeline_success_email.html.haml' do ...@@ -28,7 +28,7 @@ describe 'notify/pipeline_success_email.html.haml' do
expect(rendered).to have_content "Your pipeline has passed" expect(rendered).to have_content "Your pipeline has passed"
expect(rendered).to have_content pipeline.project.name 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.commit.author_name
expect(rendered).to have_content "##{pipeline.id}" expect(rendered).to have_content "##{pipeline.id}"
expect(rendered).to have_content pipeline.user.name expect(rendered).to have_content pipeline.user.name
...@@ -45,7 +45,7 @@ describe 'notify/pipeline_success_email.html.haml' do ...@@ -45,7 +45,7 @@ describe 'notify/pipeline_success_email.html.haml' do
expect(rendered).to have_content "Your pipeline has passed" expect(rendered).to have_content "Your pipeline has passed"
expect(rendered).to have_content pipeline.project.name 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.commit.author_name
expect(rendered).to have_content "##{pipeline.id}" expect(rendered).to have_content "##{pipeline.id}"
expect(rendered).to have_content "by API" expect(rendered).to have_content "by API"
......
...@@ -12,8 +12,8 @@ describe 'profiles/show' do ...@@ -12,8 +12,8 @@ describe 'profiles/show' do
it 'displays the correct elements' do it 'displays the correct elements' do
render render
expect(rendered).to have_field('user_name', user.name) expect(rendered).to have_field('user_name', with: user.name)
expect(rendered).to have_field('user_id', user.id) expect(rendered).to have_field('user_id', with: user.id)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment