Upgrade to Capybara 3
Fix whitespace in specs because normalize_ws is slightly different from Capybara 2 behavior
This commit is contained in:
parent
06e89d786c
commit
96ed5a8bd7
29 changed files with 45 additions and 44 deletions
2
Gemfile
2
Gemfile
|
@ -347,7 +347,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'
|
||||
|
||||
|
|
17
Gemfile.lock
17
Gemfile.lock
|
@ -110,13 +110,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
|
||||
|
@ -658,7 +659,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)
|
||||
|
@ -750,7 +751,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)
|
||||
|
@ -1040,7 +1041,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)
|
||||
|
|
|
@ -82,7 +82,7 @@ describe 'Commits' do
|
|||
|
||||
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 @@ describe 'Commits' do
|
|||
|
||||
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 @@ describe 'Commits' do
|
|||
|
||||
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')
|
||||
|
|
|
@ -91,7 +91,7 @@ describe 'Dashboard Issues Calendar Feed' do
|
|||
|
||||
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)}")
|
||||
|
|
|
@ -66,7 +66,7 @@ describe 'Group Issues Calendar Feed' do
|
|||
|
||||
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)}")
|
||||
|
|
|
@ -65,7 +65,7 @@ describe 'Project Issues Calendar Feed' do
|
|||
|
||||
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)}")
|
||||
|
|
|
@ -15,8 +15,7 @@ describe 'User accepts a merge request', :js do
|
|||
|
||||
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
|
||||
|
|
|
@ -313,7 +313,7 @@ describe 'Merge request > User creates image diff notes', :js do
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ describe 'Merge request > User sees diff', :js do
|
|||
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
|
||||
|
|
|
@ -565,7 +565,7 @@ describe 'Merge request > User sees merge widget', :js do
|
|||
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 @@ describe 'Merge request > User sees merge widget', :js do
|
|||
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
|
||||
|
|
|
@ -7,8 +7,8 @@ describe 'User comments on a diff', :js do
|
|||
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)
|
||||
|
|
|
@ -13,7 +13,7 @@ describe 'User browses commits' do
|
|||
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
|
||||
|
|
|
@ -68,7 +68,8 @@ describe 'Edit Project Settings' do
|
|||
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)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ end
|
|||
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)
|
||||
|
|
|
@ -174,7 +174,6 @@ describe 'Projects > Files > User creates files' do
|
|||
|
||||
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')")
|
||||
|
|
|
@ -41,7 +41,7 @@ describe "User removes labels" do
|
|||
|
||||
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
|
||||
|
|
|
@ -91,7 +91,7 @@ describe 'Pipeline', :js do
|
|||
|
||||
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
|
||||
|
|
|
@ -41,7 +41,7 @@ describe 'Projects > Settings > Integration settings' do
|
|||
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
|
||||
|
|
|
@ -29,6 +29,6 @@ describe 'Multi-file editor upload file', :js do
|
|||
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
|
||||
|
|
|
@ -35,7 +35,7 @@ describe 'User searches for commits' do
|
|||
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
|
||||
|
|
|
@ -39,7 +39,7 @@ describe 'Maintainer creates tag' do
|
|||
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
|
||||
|
||||
|
|
|
@ -53,9 +53,11 @@ Capybara.register_driver :chrome do |app|
|
|||
)
|
||||
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
|
||||
|
|
|
@ -84,7 +84,7 @@ shared_examples 'discussion comments' do |resource_name|
|
|||
#
|
||||
# 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
|
||||
|
|
|
@ -27,7 +27,7 @@ shared_examples 'shrug quick action' do |issuable_type|
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ shared_examples 'tableflip quick action' do |issuable_type|
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -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 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 @@ describe 'notify/pipeline_failed_email.html.haml' do
|
|||
|
||||
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"
|
||||
|
|
|
@ -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(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)
|
||||
|
|
|
@ -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 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 @@ describe 'notify/pipeline_success_email.html.haml' do
|
|||
|
||||
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"
|
||||
|
|
|
@ -12,8 +12,8 @@ describe 'profiles/show' do
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue