Support  's as spaces in matching link text (Patch from Luke Melia)
This commit is contained in:
parent
2e20267c90
commit
8405c6cfb0
@ -20,8 +20,9 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def matches_text?(link_text)
|
def matches_text?(link_text)
|
||||||
|
html = text.gsub(' ',' ')
|
||||||
matcher = /#{Regexp.escape(link_text.to_s)}/i
|
matcher = /#{Regexp.escape(link_text.to_s)}/i
|
||||||
text =~ matcher || title =~ matcher
|
html =~ matcher || title =~ matcher
|
||||||
end
|
end
|
||||||
|
|
||||||
def text
|
def text
|
||||||
|
@ -29,6 +29,7 @@ describe "clicks_link" do
|
|||||||
@session.clicks_delete_link "Link text"
|
@session.clicks_delete_link "Link text"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "should click post links" do
|
it "should click post links" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page">Link text</a>
|
<a href="/page">Link text</a>
|
||||||
@ -181,6 +182,15 @@ describe "clicks_link" do
|
|||||||
@session.clicks_link "Link"
|
@session.clicks_link "Link"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should treat non-breaking spaces as spaces" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<a href="/page1">This is a 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
|
it "should click link within a selector" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page1">Link</a>
|
<a href="/page1">Link</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user