robbyrussell / shorturl

A Ruby gem that connects to various URL shortening services like RubyURL, moourl, etc.

This URL has Read+Write access

shorturl / test / tc_shorturl.rb
100644 36 lines (28 sloc) 0.796 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# tc_shortcut.rb
#
# Created by Vincent Foley on 2005-06-01
 
$test_lib_dir = File.join(File.dirname(__FILE__), "..", "lib")
$:.unshift($test_lib_dir)
 
require "test/unit"
require "shorturl"
 
class String
  def url?
    self[0..6].downcase == "http://"
  end
end
 
class TestShortURL < Test::Unit::TestCase
  def setup
    @url = "http://groups.google.com/group/comp.lang.ruby/"
  end
  
  def test_shorten
    # Default service (RubyURL)
    assert ShortURL.shorten(@url).url?
 
    # All the services (I can't test exact URLs since they seem to
    # # change semi regularly)
    # ShortURL.valid_services.each do |service|
    # assert ShortURL.shorten(@url, service).url?
    # end
    
    # An invalid service
    assert_raise(InvalidService) { ShortURL.shorten(@url, :foobar) }
  end
end