Merge pull request #1940 from andyklimczak/fix-non-visible-error
Fix non-visible text error message
This commit is contained in:
commit
53a8f5717e
|
@ -70,7 +70,7 @@ module Capybara
|
|||
invisible_text = text(@node, :all)
|
||||
invisible_count = invisible_text.scan(@search_regexp).size
|
||||
if invisible_count != @count
|
||||
details_message << ". it was found #{invisible_count} #{Capybara::Helpers.declension("time", "times", invisible_count)} including non-visible text"
|
||||
details_message << "it was found #{invisible_count} #{Capybara::Helpers.declension("time", "times", invisible_count)} including non-visible text"
|
||||
end
|
||||
rescue
|
||||
# An error getting the non-visible text (if element goes out of scope) should not affect the response
|
||||
|
|
|
@ -52,6 +52,14 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search/)
|
||||
end
|
||||
|
||||
it "should raise error with helpful message if requested text is present but invisible and with incorrect case", requires: [:js] do
|
||||
@session.visit('/with_html')
|
||||
el = @session.find(:css, '#uppercase')
|
||||
expect do
|
||||
el.assert_text('text here')
|
||||
end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search and it was found 1 time including non-visible text/)
|
||||
end
|
||||
|
||||
it "should raise the correct error if requested text is missing but contains regex special characters" do
|
||||
@session.visit('/with_html')
|
||||
expect do
|
||||
|
|
|
@ -122,6 +122,10 @@ banana</textarea>
|
|||
<a id="link_blank_href" href="">Blank href</a>
|
||||
</div>
|
||||
|
||||
<div id="uppercase" style="text-transform: uppercase;">
|
||||
text here
|
||||
</div>
|
||||
|
||||
<div id="ancestor3">
|
||||
Ancestor
|
||||
<div id="ancestor2">
|
||||
|
|
Loading…
Reference in New Issue