test/tc_shorturl.rb in shorturl-0.2.1 vs test/tc_shorturl.rb in shorturl-0.3.0
- old
+ new
@@ -6,85 +6,26 @@
$:.unshift($test_lib_dir)
require "test/unit"
require "shorturl"
-# Make +get_short_url+ public so we can test it
-class ShortURLModified < ShortURL
- public_class_method :get_short_url
-end
-
-
class TestShortURL < Test::Unit::TestCase
def setup
@url = "http://darkhost.mine.nu:81/~vince/rails/tutorial.html"
end
def test_shorten
assert ShortURL.shorten(@url) == "http://rubyurl.com/Q9ToW"
assert ShortURL.shorten(@url, :rubyurl) == "http://rubyurl.com/Q9ToW"
assert ShortURL.shorten(@url, :tinyurl) == "http://tinyurl.com/9mop8"
-
- # The short URL for shorl is never the same, so I just check to
- # see if the URL begins with their domain name
- assert ShortURL.shorten(@url, :shorl) =~ /^http:\/\/shorl.com\//
+ assert ShortURL.shorten(@url, :shorl) =~ /^http:\/\/shorl.com/ # Never the same URL
assert ShortURL.shorten(@url, :snipurl) == "http://snipurl.com/fbkl"
assert ShortURL.shorten(@url, :metamark) == "http://xrl.us/ga8c"
assert ShortURL.shorten(@url, :makeashorterlink) == "http://makeashorterlink.com/?O1752235A"
assert ShortURL.shorten(@url, :skinnylink) == "http://skinnylink.com?nqvcce"
+ assert ShortURL.shorten(@url, :linktrim) =~ /http:\/\/linktrim/ # Never the same URL
+ assert ShortURL.shorten(@url, :shorterlink) == "http://shorterlink.com/?PQD096"
assert_raise(ArgumentError) { ShortURL.shorten(@url, :foobar) }
end
-
- def test_get_short_url
- post_string = "post('/create.php', 'url=#@url')"
- assert_raise(NoMethodError) { ShortURL.get_short_url(nil, nil, nil) {} }
-
- assert_nothing_raised do
- ShortURLModified.get_short_url("tinyurl.com",
- 200,
- post_string) { |body| }
- end
-
- assert_nil(ShortURLModified.get_short_url("askjldakjsbfk",
- 200,
- "") { |body| } )
-
- assert_nil(ShortURLModified.get_short_url("tinyurl.com",
- 404,
- post_string) { |body| } )
-
- assert_nil(ShortURLModified.get_short_url("tinyurl.com",
- 200,
- "post('/foobar.php', nil)") { |body| } )
- end
-
- def test_rubyurl
- assert_raise(NoMethodError) { ShortURL.rubyurl(@url) }
- end
-
- def test_tinyurl
- assert_raise(NoMethodError) { ShortURL.tinyurl(@url) }
- end
-
- def test_shorl
- assert_raise(NoMethodError) { ShortURL.shorl(@url) }
- end
-
- def test_snipurl
- assert_raise(NoMethodError) { ShortURL.snipurl(@url) }
- end
-
- def test_metamark
- assert_raise(NoMethodError) { ShortURL.metamark(@url) }
- end
-
- def test_makeashorterlink
- assert_raise(NoMethodError) { ShortURL.makeashorterlink(@url) }
- end
-
- def test_skinnylink
- assert_raise(NoMethodError) { ShortURL.skinnylink(@url) }
- end
-
end