0
@@ -5,6 +5,7 @@ describe Webrat::Link do
0
@session = mock(Webrat::TestSession)
0
+ @link_text_with_nbsp = 'Link' + [0xA0].pack("U") + 'Text'
0
it "should pass through relative urls" do
0
@@ -22,42 +23,62 @@ describe Webrat::Link do
0
it "should matches_text? on regexp" do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return(
"Link Text")
0
+ link.should_receive(:text).and_return(
@link_text_with_nbsp)
0
link.matches_text?(/link/i).should == 0
0
it "should matches_text? on link_text" do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return(
"Link Text")
0
+ link.should_receive(:text).and_return(
@link_text_with_nbsp)
0
link.matches_text?("Link Text").should == 0
0
it "should matches_text? on substring" do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return(
"Link Text")
0
+ link.should_receive(:text).and_return(
@link_text_with_nbsp)
0
link.matches_text?("nk Te").should_not be_nil
0
it "should not matches_text? on link_text case insensitive" do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return("Link Text")
0
+ link.should_receive(:text).and_return(@link_text_with_nbsp)
0
+ link.should_receive(:inner_html).and_return('Link Text')
0
link.should_receive(:title).and_return(nil)
0
link.matches_text?("link_text").should == false
0
- it "should match text
including " do
0
+ it "should match text
not include " do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return("Link Text")
0
- link.matches_text?("Link Text").should == 0
0
+ link.should_receive(:text).and_return('LinkText')
0
+ link.matches_text?("LinkText").should == 0
0
it "should not matches_text? on wrong text" do
0
link = Webrat::Link.new(@session, nil)
0
- link.should_receive(:text).and_return("Some Other Link")
0
+ nbsp = [0xA0].pack("U")
0
+ link.should_receive(:text).and_return("Some"+nbsp+"Other"+nbsp+"Link")
0
+ link.should_receive(:inner_html).and_return("Some Other Link")
0
link.should_receive(:title).and_return(nil)
0
link.matches_text?("Link Text").should == false
0
+ it "should match text including character reference" do
0
+ no_ko_gi_ri = [0x30CE,0x30B3,0x30AE,0x30EA]
0
+ nokogiri_ja_kana = no_ko_gi_ri.pack("U*")
0
+ nokogiri_char_ref = no_ko_gi_ri.map{|c| "&#x%X;" % c }.join("")
0
+ link = Webrat::Link.new(@session, nil)
0
+ link.should_receive(:text).and_return(nokogiri_ja_kana)
0
+ link.matches_text?(nokogiri_ja_kana).should == 0
0
+ it "should match img link" do
0
+ link = Webrat::Link.new(@session, nil)
0
+ link.should_receive(:text).and_return('')
0
+ link.should_receive(:inner_html).and_return('<img src="logo.png" />')
0
+ link.matches_text?('logo.png').should == 10
0
it "should matches_id? on exact matching id" do
0
link = Webrat::Link.new(@session, nil)
0
link.should_receive(:id).and_return("some_id")
0
@@ -76,4 +97,4 @@ describe Webrat::Link do
0
link.matches_id?(/some/).should == true
0
\ No newline at end of file