By default, Capybara only finds visible elements, so adding the `visible: true` option is usually redundant. We were using it sometimes to make it an obvious contrast with another test using `visible: false`. However, from the user's perspective, we don't care whether the element has been removed from the DOM or has been hidden, so we can just test that the visible selector can't be found. Besides, using `visible: false` means the test will also pass if the element is present and visible. However, we want the test to fail if the element is visible. That's why a couple of JavaScript-dependant tests were passing even when JavaScript was disabled.
25 lines
849 B
Ruby
25 lines
849 B
Ruby
module Votes
|
|
def expect_message_you_need_to_sign_in
|
|
expect(page).to have_content "You must sign in or sign up to continue"
|
|
expect(page).to have_selector(".in-favor", obscured: true)
|
|
end
|
|
|
|
def expect_message_you_need_to_sign_in_to_vote_comments
|
|
within(".participation-not-allowed") do
|
|
expect(page).to have_content "You must sign in or sign up to vote"
|
|
end
|
|
|
|
expect(page).not_to have_selector(".participation-allowed")
|
|
end
|
|
|
|
def expect_message_to_many_anonymous_votes
|
|
expect(page).to have_content "Too many anonymous votes to admit vote"
|
|
expect(page).to have_selector(".in-favor a", obscured: true)
|
|
end
|
|
|
|
def expect_message_only_verified_can_vote_proposals
|
|
expect(page).to have_content "Only verified users can vote on proposals"
|
|
expect(page).to have_selector(".in-favor", obscured: true)
|
|
end
|
|
end
|