Use Capybara methods to find/click/check links
We applied the Capybara/SpecificMatcher in commit f52a86b46. However,
this rule doesn't convert methods finding <a> tags to methods finding
links because <a> tags only count as links when they've got the `href`
attribute. For instance, in the `xss_spec.rb` file we check what happens
when clicking on an anchor tag because we're testing that the `href`
attribute has been removed and so we can't use `click_link`.
So, basically, we can't enable a rule to automatically detect when we're
using `have_css` instead of `have_link`, but we should still do it
because `have_link` adds an extra check which affects accessibility
since it makes sure the tag has the `href` attribute and so it's
recognizable as a link by screen readers.
This commit is contained in:
@@ -25,7 +25,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
do_login_for user_to_login, management: management
|
||||
visit send(path, arguments)
|
||||
|
||||
expect(page).to have_css "#new_document_link"
|
||||
expect(page).to have_link id: "new_document_link"
|
||||
end
|
||||
|
||||
scenario "Should not show new document link when
|
||||
@@ -219,7 +219,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
|
||||
# Review
|
||||
# Doble check why the file is stored with a name different to empty.pdf
|
||||
expect(page).to have_css("a[href$='.pdf']")
|
||||
expect(page).to have_link href: /.pdf\Z/
|
||||
end
|
||||
|
||||
scenario "Should show resource with new document after successful creation with
|
||||
@@ -269,7 +269,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
click_on "Remove document"
|
||||
end
|
||||
|
||||
expect(page).to have_css "#new_document_link"
|
||||
expect(page).to have_link id: "new_document_link"
|
||||
end
|
||||
|
||||
scenario "Should remove nested field after remove document" do
|
||||
|
||||
@@ -228,7 +228,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
click_link "Remove image"
|
||||
|
||||
expect(page).not_to have_css ".image"
|
||||
expect(page).to have_css "a#new_image_link"
|
||||
expect(page).to have_link id: "new_image_link"
|
||||
end
|
||||
|
||||
scenario "don't duplicate fields after removing and adding an image" do
|
||||
|
||||
Reference in New Issue
Block a user