aboutsummaryrefslogtreecommitdiffstats
path: root/spec/libs/format_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/libs/format_spec.rb')
-rw-r--r--spec/libs/format_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/libs/format_spec.rb b/spec/libs/format_spec.rb
new file mode 100644
index 000000000..f483605a4
--- /dev/null
+++ b/spec/libs/format_spec.rb
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "when making clickable" do
+
+ it "should make URLs into links" do
+ text = "Hello http://www.flourish.org goodbye"
+ text = CGI.escapeHTML(text)
+ formatted = MySociety::Format.make_clickable(text)
+ formatted.should == "Hello <a href='http://www.flourish.org'>http://www.flourish.org</a> goodbye"
+ end
+
+ it "should make wrapped URLs in angle brackets clickable" do
+ text = """<http://www.flourish.org/bl
+og>"""
+ text = CGI.escapeHTML(text)
+
+ formatted = MySociety::Format.make_clickable(text)
+
+ formatted.should == "&lt;<a href='http://www.flourish.org/blog'>http://www.flourish.org/blog</a>&gt;"
+ end
+
+end