Sha256: 56604473c16ff9edbd3815363f2017f3a10dbe91bca49f1cd76e45443d36c2cf
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' require 'nokogiri' describe OpenConferenceWare::DisplayLinkToHelper do def elem_for(*args) return Nokogiri::HTML::DocumentFragment.parse(helper.display_link_to(*args)).children.first end describe "when creating link" do it "should create link" do url = "http://foo.bar/" elem = elem_for(url) elem['href'].should == url elem.inner_html.should == url end it "should escape characters" do url = "<evil>&</evil>" elem = elem_for(url) elem.to_html.should =~ %r{<a href=\"<evil>&</evil>\"} elem.inner_html.should_not == url elem.inner_html.should == "<evil>&</evil>" end it "should truncate long URL" do url = "http://foo.bar/abcdefghijklmnopqrstuvwxyz" maxlength = 16 elem = elem_for(url, maxlength: maxlength) elem['href'].should == url elem.inner_html.should_not == url elem.inner_html.should == "http://foo.ba..." elem.inner_html.size.should == maxlength end it "should add norelfollow" do url = "http://foo.bar/" elem = elem_for(url) elem['rel'].should == "nofollow" end it "should not add norelfollow optionally" do url = "http://foo.bar/" elem = elem_for(url, nofollow: false) elem['rel'].should be_blank end end end
Version data entries
4 entries across 4 versions & 1 rubygems