diff --git a/.rubocop.yml b/.rubocop.yml index fe547316a..dda05fc8a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,6 +26,9 @@ Capybara/FeatureMethods: - scenario - xscenario +Capybara/VisibilityMatcher: + Enabled: true + FactoryBot/AttributeDefinedStatically: Enabled: true diff --git a/spec/shared/system/flaggable.rb b/spec/shared/system/flaggable.rb index 68e9301e8..81a1f863c 100644 --- a/spec/shared/system/flaggable.rb +++ b/spec/shared/system/flaggable.rb @@ -30,7 +30,8 @@ shared_examples "flaggable" do |factory_name, admin: false| click_link "Flag as inappropriate" expect(page).to have_css ".flag-active" - expect(page).to have_link "Unflag", visible: false + expect(page).to have_link "Unflag", visible: :hidden + expect(page).not_to have_link "Flag as inappropriate", visible: :all end expect(Flag.flagged?(user, flaggable)).to be @@ -49,7 +50,8 @@ shared_examples "flaggable" do |factory_name, admin: false| click_link "Unflag" expect(page).not_to have_css ".flag-active" - expect(page).to have_link "Flag as inappropriate", visible: false + expect(page).to have_link "Flag as inappropriate", visible: :hidden + expect(page).not_to have_link "Unflag", visible: :all end expect(Flag.flagged?(user, flaggable)).not_to be diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index a347b1436..1c616e167 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -74,7 +74,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na click_link "Add new document" within "#nested-documents" do - document = find(".document input[type=file]", visible: false) + document = find(".document input[type=file]", visible: :hidden) attach_file( document[:id], Rails.root.join("spec/fixtures/files/empty.pdf"), @@ -106,7 +106,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na within "#nested-documents" do input = find("input[name$='[title]']") fill_in input[:id], with: "My Title" - document_input = find("input[type=file]", visible: false) + document_input = find("input[type=file]", visible: :hidden) attach_file( document_input[:id], Rails.root.join("spec/fixtures/files/empty.pdf"), @@ -314,7 +314,7 @@ def documentable_attach_new_file(path, success = true) click_link "Add new document" document = all("#new_document").last - document_input = document.find("input[type=file]", visible: false) + document_input = document.find("input[type=file]", visible: :hidden) attach_file(document_input[:id], path, make_visible: true) within document do @@ -338,7 +338,7 @@ def expect_document_has_cached_attachment(index, extension) document = all(".document")[index] within document do - expect(find("input[name$='[cached_attachment]']", visible: false).value).to end_with(extension) + expect(find("input[name$='[cached_attachment]']", visible: :hidden).value).to end_with(extension) end end diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index fa8e1a546..92a098077 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -34,7 +34,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p visit send(path, arguments) click_link "Add image" - image_input = find(".image").find("input[type=file]", visible: false) + image_input = find(".image").find("input[type=file]", visible: :hidden) attach_file( image_input[:id], Rails.root.join("spec/fixtures/files/clippy.jpg"), @@ -63,7 +63,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p click_link "Add image" input_title = find(".image input[name$='[title]']") fill_in input_title[:id], with: "Title" - image_input = find(".image").find("input[type=file]", visible: false) + image_input = find(".image").find("input[type=file]", visible: :hidden) attach_file( image_input[:id], Rails.root.join("spec/fixtures/files/clippy.jpg"), @@ -261,7 +261,7 @@ def imageable_attach_new_file(_imageable_factory_name, path, success = true) click_link "Add image" within "#nested-image" do image = find(".image") - image_input = image.find("input[type=file]", visible: false) + image_input = image.find("input[type=file]", visible: :hidden) attach_file(image_input[:id], path, make_visible: true) within image do if success @@ -299,7 +299,7 @@ def expect_image_has_cached_attachment(extension) image = find(".image") within image do - expect(find("input[name$='[cached_attachment]']", visible: false).value).to end_with(extension) + expect(find("input[name$='[cached_attachment]']", visible: :hidden).value).to end_with(extension) end end end diff --git a/spec/system/admin/poll/questions_spec.rb b/spec/system/admin/poll/questions_spec.rb index 3863cf676..187549a64 100644 --- a/spec/system/admin/poll/questions_spec.rb +++ b/spec/system/admin/poll/questions_spec.rb @@ -67,7 +67,7 @@ describe "Admin poll questions" do expect(page).to have_content("Create question to poll Movies") expect(page).to have_selector("input[id='poll_question_poll_id'][value='#{poll.id}']", - visible: false) + visible: :hidden) fill_in "Question", with: title click_button "Save" diff --git a/spec/system/admin/settings_spec.rb b/spec/system/admin/settings_spec.rb index 8218c76ca..402d93540 100644 --- a/spec/system/admin/settings_spec.rb +++ b/spec/system/admin/settings_spec.rb @@ -40,7 +40,7 @@ describe "Admin settings" do login_as(admin) visit admin_settings_path - expect(page).not_to have_css("#admin-map.leaflet-container", visible: false) + expect(page).not_to have_css("#admin-map.leaflet-container", visible: :all) end scenario "When `Map settings` tab content is shown map should be initialized" do @@ -101,8 +101,8 @@ describe "Admin settings" do visit admin_settings_path - expect(find("#latitude", visible: false).value).to eq "51.48" - expect(find("#longitude", visible: false).value).to eq "0.0" + expect(find("#latitude", visible: :hidden).value).to eq "51.48" + expect(find("#longitude", visible: :hidden).value).to eq "0.0" end scenario "Should update marker", :js do @@ -117,7 +117,7 @@ describe "Admin settings" do click_on "Update" end - expect(find("#latitude", visible: false).value).not_to eq "51.48" + expect(find("#latitude", visible: :hidden).value).not_to eq "51.48" expect(page).to have_content "Map configuration updated succesfully" end end diff --git a/spec/system/budgets/budgets_spec.rb b/spec/system/budgets/budgets_spec.rb index 4c575e9ef..66f1da827 100644 --- a/spec/system/budgets/budgets_spec.rb +++ b/spec/system/budgets/budgets_spec.rb @@ -285,7 +285,7 @@ describe "Budgets" do visit budgets_path within ".map_location" do - expect(page).to have_css(".map-icon", count: 3, visible: false) + expect(page).to have_css(".map-icon", count: 3, visible: :all) end end @@ -305,7 +305,7 @@ describe "Budgets" do visit budgets_path within ".map_location" do - expect(page).to have_css(".map-icon", count: 4, visible: false) + expect(page).to have_css(".map-icon", count: 4, visible: :all) end end @@ -325,7 +325,7 @@ describe "Budgets" do visit budgets_path within ".map_location" do - expect(page).to have_css(".map-icon", count: 2, visible: false) + expect(page).to have_css(".map-icon", count: 2, visible: :all) end end @@ -354,7 +354,7 @@ describe "Budgets" do visit budgets_path within ".map_location" do - expect(page).to have_css(".map-icon", count: 1, visible: false) + expect(page).to have_css(".map-icon", count: 1, visible: :all) end end end diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 0066dbf76..66a32a1dd 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -1815,7 +1815,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) within ".map_location" do - expect(page).to have_css(".map-icon", count: 6, visible: false) + expect(page).to have_css(".map-icon", count: 6, visible: :all) end end @@ -1829,7 +1829,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) within ".map_location" do - expect(page).to have_css(".map-icon", count: 2, visible: false) + expect(page).to have_css(".map-icon", count: 2, visible: :all) end end @@ -1853,7 +1853,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) within ".map_location" do - expect(page).to have_css(".map-icon", count: 4, visible: false) + expect(page).to have_css(".map-icon", count: 4, visible: :all) end end @@ -1871,7 +1871,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) within ".map_location" do - expect(page).to have_css(".map-icon", count: 0, visible: false) + expect(page).to have_css(".map-icon", count: 0, visible: :all) end end @@ -1889,7 +1889,7 @@ describe "Budget Investments" do end within(".map_location") do - expect(page).to have_css(".map-icon", count: 3, visible: false) + expect(page).to have_css(".map-icon", count: 3, visible: :all) end end diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb index 027c94cba..070737f60 100644 --- a/spec/system/home_spec.rb +++ b/spec/system/home_spec.rb @@ -82,8 +82,8 @@ describe "Home" do visit root_path expect(page).to have_selector("li[data-slide='0']") - expect(page).to have_selector("li[data-slide='1']", visible: false) - expect(page).to have_selector("li[data-slide='2']", visible: false) + expect(page).to have_selector("li[data-slide='1']", visible: :hidden) + expect(page).to have_selector("li[data-slide='2']", visible: :hidden) end scenario "Display recommended show when click on carousel" do diff --git a/spec/system/management/account_spec.rb b/spec/system/management/account_spec.rb index 9c860b544..6d0d2ecdc 100644 --- a/spec/system/management/account_spec.rb +++ b/spec/system/management/account_spec.rb @@ -100,6 +100,6 @@ describe "Account" do expect(page).to have_content "Password reseted successfully" expect(page).to have_css("a[href='javascript:window.print();']", text: "Print password") - expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: false) + expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: :hidden) end end diff --git a/spec/system/notifications_spec.rb b/spec/system/notifications_spec.rb index 43e5a045c..4edb18860 100644 --- a/spec/system/notifications_spec.rb +++ b/spec/system/notifications_spec.rb @@ -175,7 +175,7 @@ describe "Notifications" do visit notifications_path expect(page).to have_content("Notification title") expect(page).to have_content("Notification body") - expect(page).not_to have_link(notification_path(notification), visible: false) + expect(page).not_to have_link(notification_path(notification), visible: :all) end end diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index cb67e8ee3..dd204ec11 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -323,8 +323,8 @@ describe "Proposals" do proposal = create(:proposal) visit proposal_path(proposal) - expect(page).to have_css "meta[name='twitter:title'][content=\'#{proposal.title}\']", visible: false - expect(page).to have_css "meta[property='og:title'][content=\'#{proposal.title}\']", visible: false + expect(page).to have_css "meta[name='twitter:title'][content=\'#{proposal.title}\']", visible: :hidden + expect(page).to have_css "meta[property='og:title'][content=\'#{proposal.title}\']", visible: :hidden end scenario "Create and publish" do