diff --git a/features/project/commits/comments.feature b/features/project/commits/comments.feature index c41075d7ad43fad991f2bbca8606017923299d33..320f008abb63a42ce47289b5dfbdaee9c0740ed7 100644 --- a/features/project/commits/comments.feature +++ b/features/project/commits/comments.feature @@ -39,6 +39,7 @@ Feature: Project Commits Comments @javascript Scenario: I can delete a comment Given I leave a comment like "XML attached" + Then I should see a comment saying "XML attached" And I delete a comment Then I should not see a comment saying "XML attached" diff --git a/features/project/wiki.feature b/features/project/wiki.feature index 7a70f3487541619925f17c3a1c00d183c03f2f87..2ebfa3c16600940d6e791e476468d282e4b35df7 100644 --- a/features/project/wiki.feature +++ b/features/project/wiki.feature @@ -69,7 +69,7 @@ Feature: Project Wiki And I click on the "Pages" button Then I should see non-escaped link in the pages list - @javascript @focus + @javascript Scenario: Creating an invalid new page Given I create a New page with an invalid name Then I should see an error message diff --git a/features/steps/admin/broadcast_messages.rb b/features/steps/admin/broadcast_messages.rb index 2ecb6f0191a7bb20dd75852ffd10f1e24ff3fc4c..f6daf8529775238a8d76c80fa797be26dbf689d4 100644 --- a/features/steps/admin/broadcast_messages.rb +++ b/features/steps/admin/broadcast_messages.rb @@ -36,6 +36,6 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps step 'I should see a customized broadcast message' do expect(page).to have_content 'Application update from 4:00 CST to 5:00 CST' - expect(page).to have_selector %(div[style="background-color:#f2dede;color:#b94a48"]) + expect(page).to have_selector %(div[style="background-color: #f2dede; color: #b94a48"]) end end diff --git a/features/steps/admin/settings.rb b/features/steps/admin/settings.rb index 1c0b7a4b712ea42db7f7ee8861b204eef1148365..147a4bd7486a93cf6a85df2057fc1bdde2ca0962 100644 --- a/features/steps/admin/settings.rb +++ b/features/steps/admin/settings.rb @@ -11,9 +11,9 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps end step 'I should see application settings saved' do - expect(current_application_settings.gravatar_enabled).to be_false - expect(current_application_settings.home_page_url).to eq 'https://about.gitlab.com/' - expect(page).to have_content 'Application settings saved successfully' + expect(current_application_settings.gravatar_enabled).to be_falsey + expect(current_application_settings.home_page_url).to eq "https://about.gitlab.com/" + expect(page).to have_content "Application settings saved successfully" end step 'I click on "Service Templates"' do diff --git a/features/steps/dashboard/new_project.rb b/features/steps/dashboard/new_project.rb index b4ade65ee534d0008a1f3e0dbe57894a244d9425..d4440c1fb4d088c46a35f74843f8718dee07a570 100644 --- a/features/steps/dashboard/new_project.rb +++ b/features/steps/dashboard/new_project.rb @@ -10,7 +10,7 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps end step 'I see "New project" page' do - expect(page).to have_content("Project path") + expect(page).to have_content('Project path') end step 'I click on "Import project from GitHub"' do diff --git a/features/steps/groups.rb b/features/steps/groups.rb index c6c855a7c2215608b6c949d6ee2ee294fb305227..6221163ac544699bcdbb67a7a0a42556bb1e2c81 100644 --- a/features/steps/groups.rb +++ b/features/steps/groups.rb @@ -154,7 +154,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps end step 'I should not see group "Owned" avatar' do - expect(Group.find_by(name: "Owned").avatar?).to be_false + expect(Group.find_by(name: "Owned").avatar?).to eq false end step 'I should not see the "Remove avatar" button' do diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index 10bd307320edd753e5f9ce5f489990bc7f795351..3f19bed8a0b2485473ac9f505303eb89acafd224 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -53,7 +53,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps end step 'I should see my gravatar' do - expect(@user.avatar?).to be_false + expect(@user.avatar?).to eq false end step 'I should not see the "Remove avatar" button' do @@ -87,11 +87,15 @@ class Spinach::Features::Profile < Spinach::FeatureSteps end step "I should see a missing password error message" do - expect(page).to have_content "You must provide a valid current password" + page.within ".flash-container" do + expect(page).to have_content "You must provide a valid current password" + end end step "I should see a password error message" do - expect(page).to have_content "Password confirmation doesn't match" + page.within '.alert' do + expect(page).to have_content "Password confirmation doesn't match" + end end step 'I reset my token' do @@ -120,7 +124,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps step "I am not an ldap user" do current_user.identities.delete - expect(current_user.ldap_user?).to be_false + expect(current_user.ldap_user?).to eq false end step 'I redirected to expired password page' do diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb index 62c64e60f6d0cfe1e5742df89b81f017c84f7551..b072fef235e43db897418cdb88f0a47646a272b2 100644 --- a/features/steps/project/merge_requests.rb +++ b/features/steps/project/merge_requests.rb @@ -31,8 +31,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps step 'I should see closed merge request "Bug NS-04"' do merge_request = MergeRequest.find_by!(title: "Bug NS-04") - expect(merge_request.closed?).to be_true - expect(page).to have_content "Rejected by" + expect(merge_request).to be_closed + expect(page).to have_content 'Rejected by' end step 'I should see merge request "Bug NS-04"' do @@ -125,7 +125,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps expect(buttons.count).to eq(2) buttons.each do |b| - expect(expect(b['href'])).not_to have_content('json') + expect(b['href']).not_to have_content('json') end end @@ -164,20 +164,26 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps end step 'I should see a discussion has started on diff' do - expect(page).to have_content "#{current_user.name} started a discussion" - expect(page).to have_content sample_commit.line_code_path - expect(page).to have_content "Line is wrong" + page.within(".notes .discussion") do + page.should have_content "#{current_user.name} started a discussion" + page.should have_content sample_commit.line_code_path + page.should have_content "Line is wrong" + end end step 'I should see a discussion has started on commit diff' do - expect(page).to have_content "#{current_user.name} started a discussion on commit" - expect(page).to have_content sample_commit.line_code_path - expect(page).to have_content "Line is wrong" + page.within(".notes .discussion") do + page.should have_content "#{current_user.name} started a discussion on commit" + page.should have_content sample_commit.line_code_path + page.should have_content "Line is wrong" + end end step 'I should see a discussion has started on commit' do - expect(page).to have_content "#{current_user.name} started a discussion on commit" - expect(page).to have_content "One comment to rule them all" + page.within(".notes .discussion") do + page.should have_content "#{current_user.name} started a discussion on commit" + page.should have_content "One comment to rule them all" + end end step 'merge request is mergeable' do @@ -329,12 +335,13 @@ def init_diff_note end def leave_comment(message) - page.within(".js-discussion-note-form") do + page.within(".js-discussion-note-form", visible: true) do fill_in "note_note", with: message click_button "Add Comment" end - - expect(page).to have_content message + page.within(".notes_holder", visible: true) do + expect(page).to have_content message + end end def init_diff_note_first_file diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb index ee4c7cd0f06083e67e2aabb6fa39b59d0a210523..e4465a1c3b7fae8a655955f082ed58a78b915834 100644 --- a/features/steps/project/project.rb +++ b/features/steps/project/project.rb @@ -59,7 +59,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps end step 'I should see the default project avatar' do - expect(@project.avatar?).to be_false + expect(@project.avatar?).to eq false end step 'I should not see the "Remove avatar" button' do diff --git a/features/steps/search.rb b/features/steps/search.rb index fec5d9f0e4e986c507923f63d1c792405e2eab27..87893aa02057b6715325efe463be8e20cedab151 100644 --- a/features/steps/search.rb +++ b/features/steps/search.rb @@ -52,7 +52,9 @@ class Spinach::Features::Search < Spinach::FeatureSteps end step 'I should see code results for project "Shop"' do - expect(page).to have_content 'Update capybara, rspec-rails, poltergeist to recent versions' + page.within('.results') do + page.should have_content 'Update capybara, rspec-rails, poltergeist to recent versions' + end end step 'I search for "Contibuting"' do @@ -71,7 +73,9 @@ class Spinach::Features::Search < Spinach::FeatureSteps end step 'I should see "Foo" link in the search results' do - expect(find(:css, '.search-results')).to have_link 'Foo' + page.within('.results') do + find(:css, '.search-results').should have_link 'Foo' + end end step 'I should not see "Bar" link in the search results' do @@ -79,7 +83,9 @@ class Spinach::Features::Search < Spinach::FeatureSteps end step 'I should see "test_wiki" link in the search results' do - expect(find(:css, '.search-results')).to have_link 'test_wiki.md' + page.within('.results') do + find(:css, '.search-results').should have_link 'test_wiki.md' + end end step 'project has Wiki content' do diff --git a/features/steps/shared/diff_note.rb b/features/steps/shared/diff_note.rb index c4f89ca31c9a7092d9021c4ac2eb41f5dd86fc18..27a95aeb19ac8d69f80b230f33a7b58c649d291d 100644 --- a/features/steps/shared/diff_note.rb +++ b/features/steps/shared/diff_note.rb @@ -20,11 +20,14 @@ module SharedDiffNote end step 'I leave a diff comment like "Typo, please fix"' do - click_diff_line(sample_commit.line_code) - page.within("#{diff_file_selector} form[rel$='#{sample_commit.line_code}']") do - fill_in "note[note]", with: "Typo, please fix" - find(".js-comment-button").trigger("click") - sleep 0.05 + page.within(diff_file_selector) do + click_diff_line(sample_commit.line_code) + + page.within("form[rel$='#{sample_commit.line_code}']") do + fill_in "note[note]", with: "Typo, please fix" + find(".js-comment-button").trigger("click") + sleep 0.05 + end end end @@ -45,28 +48,37 @@ module SharedDiffNote end step 'I preview a diff comment text like "Should fix it :smile:"' do - click_diff_line(sample_commit.line_code) - page.within("#{diff_file_selector} form[rel$='#{sample_commit.line_code}']") do - fill_in "note[note]", with: "Should fix it :smile:" - find('.js-md-preview-button').click + page.within(diff_file_selector) do + click_diff_line(sample_commit.line_code) + + page.within("form[rel$='#{sample_commit.line_code}']") do + fill_in "note[note]", with: "Should fix it :smile:" + find('.js-md-preview-button').click + end end end step 'I preview another diff comment text like "DRY this up"' do - click_diff_line(sample_commit.del_line_code) + page.within(diff_file_selector) do + click_diff_line(sample_commit.del_line_code) - page.within("#{diff_file_selector} form[rel$='#{sample_commit.del_line_code}']") do - fill_in "note[note]", with: "DRY this up" - find('.js-md-preview-button').click + page.within("form[rel$='#{sample_commit.del_line_code}']") do + fill_in "note[note]", with: "DRY this up" + find('.js-md-preview-button').click + end end end step 'I open a diff comment form' do - click_diff_line(sample_commit.line_code) + page.within(diff_file_selector) do + click_diff_line(sample_commit.line_code) + end end step 'I open another diff comment form' do - click_diff_line(sample_commit.del_line_code) + page.within(diff_file_selector) do + click_diff_line(sample_commit.del_line_code) + end end step 'I write a diff comment like ":-1: I don\'t like this"' do @@ -194,7 +206,7 @@ module SharedDiffNote end def diff_file_selector - ".diff-file:nth-of-type(1)" + '.diff-file:nth-of-type(1)' end def click_diff_line(code) diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index b2675546a14f70bbd5414c0365da81fa30ab9832..f6aabfefeffb3eab37e11c414feca40785192e1c 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -2,8 +2,10 @@ module SharedNote include Spinach::DSL step 'I delete a comment' do - find('.note').hover - find(".js-note-delete").click + page.within('.notes') do + find('.note').hover + find(".js-note-delete").click + end end step 'I haven\'t written any comment text' do @@ -16,7 +18,6 @@ module SharedNote page.within(".js-main-target-form") do fill_in "note[note]", with: "XML attached" click_button "Add Comment" - sleep 0.05 end end @@ -123,13 +124,14 @@ module SharedNote end step 'I edit the last comment with a +1' do - find(".note").hover - find('.js-note-edit').click + page.within(".notes") do + find(".note").hover + find('.js-note-edit').click + end page.within(".current-note-edit-form") do fill_in 'note[note]', with: '+1 Awesome!' click_button 'Save Comment' - sleep 0.05 end end diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb index 69d15f41706227b90da8cd64eed4256a749f58a0..03e78c533db2785d246c086276f07ab7cc268774 100644 --- a/spec/features/profiles/preferences_spec.rb +++ b/spec/features/profiles/preferences_spec.rb @@ -75,7 +75,7 @@ end def expect_preferences_saved_message - within('.flash-container') do + page.within('.flash-container') do expect(page).to have_content('Preferences saved.') end end