spec/firefly/url_spec.rb in firefly-0.4.0.1 vs spec/firefly/url_spec.rb in firefly-0.4.1
- old
+ new
@@ -1,11 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Url" do
describe "shortening" do
-
it "should generate a code after create" do
url = Firefly::Url.shorten("http://example.com/")
Firefly::Url.first(:url => "http://example.com/").code.should_not be_nil
end
@@ -24,9 +23,40 @@
Firefly::Url.shorten("http://example.com/")
lambda {
Firefly::Url.shorten("http://example.com/")
}.should_not change(Firefly::Url, :count)
end
+
+ it "should normalize urls correctly" do
+ # Note the trailing '/'
+ Firefly::Url.shorten("http://example.com/")
+ lambda {
+ Firefly::Url.shorten("http://example.com")
+ }.should_not change(Firefly::Url, :count)
+ end
+ end
+
+ describe "long url validation" do
+ [ "http://ariejan.net",
+ "https://ariejan.net",
+ "http://ariejan.net/page/1",
+ "http://ariejan.net/page/1?q=x&p=123",
+ "http://ariejan.net:8080/"
+ ].each do |url|
+ it "should accept #{url}" do
+ Firefly::Url.shorten(url).should_not be_nil
+ end
+ end
+
+ [ "ftp://ariejan.net",
+ "irc://freenode.org/rails",
+ "skype:adevroom",
+ "ariejan.net",
+ ].each do |url|
+ it "should not accept #{url}" do
+ Firefly::Url.shorten(url).should be_nil
+ end
+ end
end
describe "clicking" do
before(:each) do
Firefly::Url.create(
\ No newline at end of file