Accept non-string parameters to has_text, notably nil and numbers
This is mostly for compatibility with Capybara 1.1.2.
This commit is contained in:
parent
5c7515ce44
commit
0aeee9f8f0
|
@ -472,7 +472,7 @@ module Capybara
|
|||
# @return [String] Normalized text
|
||||
#
|
||||
def normalize_whitespace(text)
|
||||
text.is_a?(Regexp) ? text : text.gsub(/\s+/, ' ').strip
|
||||
text.is_a?(Regexp) ? text : text.to_s.gsub(/\s+/, ' ').strip
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -83,6 +83,17 @@ shared_examples_for 'has_text' do
|
|||
@session.visit('/with_html')
|
||||
@session.should_not have_text('.orem')
|
||||
end
|
||||
|
||||
it "should accept non-string parameters" do
|
||||
@session.visit('/with_html')
|
||||
@session.should have_text(42)
|
||||
end
|
||||
|
||||
it "should be true when passed nil" do
|
||||
# Historical behavior; no particular reason other than compatibility.
|
||||
@session.visit('/with_html')
|
||||
@session.should have_text(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_no_text?' do
|
||||
|
|
|
@ -72,6 +72,10 @@ banana</textarea>
|
|||
<a id="visible" class="visibility">visible link</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Number 42
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<li id="john_monkey">Monkey John</li>
|
||||
<li id="paul_monkey">Monkey Paul</li>
|
||||
|
|
Loading…
Reference in New Issue