Support &nbsp's as spaces in matching link text (Patch from Luke Melia)

This commit is contained in:
Bryan Helmkamp 2008-07-25 19:26:59 -04:00
parent 2e20267c90
commit 8405c6cfb0
2 changed files with 12 additions and 1 deletions

View File

@ -20,8 +20,9 @@ module Webrat
end
def matches_text?(link_text)
html = text.gsub(' ',' ')
matcher = /#{Regexp.escape(link_text.to_s)}/i
text =~ matcher || title =~ matcher
html =~ matcher || title =~ matcher
end
def text

View File

@ -29,6 +29,7 @@ describe "clicks_link" do
@session.clicks_delete_link "Link text"
end
it "should click post links" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
@ -181,6 +182,15 @@ describe "clicks_link" do
@session.clicks_link "Link"
end
it "should treat non-breaking spaces as spaces" do
@session.response_body = <<-EOS
<a href="/page1">This&nbsp;is&nbsp;a&nbsp;link</a>
EOS
@session.should_receive(:get).with("/page1", {})
@session.clicks_link "This is a link"
end
it "should click link within a selector" do
@session.response_body = <<-EOS
<a href="/page1">Link</a>