diff --git a/lib/webrat/core/link.rb b/lib/webrat/core/link.rb index 5572032..24b849d 100644 --- a/lib/webrat/core/link.rb +++ b/lib/webrat/core/link.rb @@ -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 diff --git a/spec/api/clicks_link_spec.rb b/spec/api/clicks_link_spec.rb index e40a863..a29e1c9 100644 --- a/spec/api/clicks_link_spec.rb +++ b/spec/api/clicks_link_spec.rb @@ -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 Link text @@ -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 + This is a link + 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 Link