1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Use Capybara::Helpers to_regexp and update history

This commit is contained in:
Thomas Walpole 2016-08-18 10:05:10 -07:00
parent 325876ce96
commit b212d8fa2a
3 changed files with 13 additions and 3 deletions

View file

@ -1,3 +1,9 @@
#Version 2.8.1
Release data: unreleased
###Fixed
* Fixed error message from have_text when text is not found but contains regex special characters [Ryunosuke Sato]
# Version 2.8.0
Release date: 2016-08-16

View file

@ -48,7 +48,7 @@ module Capybara
details_message = []
if @node and !@expected_text.is_a? Regexp
insensitive_regexp = Regexp.new(Regexp.escape(@expected_text), Regexp::IGNORECASE)
insensitive_regexp = Capybara::Helpers.to_regexp(@expected_text, Regexp::IGNORECASE)
insensitive_count = @actual_text.scan(insensitive_regexp).size
if insensitive_count != @count
details_message << "it was found #{insensitive_count} #{Capybara::Helpers.declension("time", "times", insensitive_count)} using a case insensitive search"

View file

@ -50,9 +50,13 @@ Capybara::SpecHelper.spec '#assert_text' do
expect do
@session.assert_text('Text With Whitespace')
end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search/)
end
it "should raise the correct error if requested text is missing but contains regex special characters" do
@session.visit('/with_html')
expect do
@session.assert_text('[]')
end.to raise_error(Capybara::ExpectationNotMet, /expected to find text "\[\]"/)
@session.assert_text('[]*.')
end.to raise_error(Capybara::ExpectationNotMet, /expected to find text "\[\]\*\."/)
end
it "should be true if the text in the page matches given regexp" do