From 8405c6cfb053ef3ba9f11b3b3094678be3667f4d Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 25 Jul 2008 19:26:59 -0400 Subject: [PATCH] Support  's as spaces in matching link text (Patch from Luke Melia) --- lib/webrat/core/link.rb | 3 ++- spec/api/clicks_link_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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