Sha256: f58a0a69cf7cc67e5264b57c56a1864e99696ccd90af66401d8590ab58c4daf3

Contents?: true

Size: 788 Bytes

Versions: 3

Compression:

Stored size: 788 Bytes

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shorturl-0.7.0 test/tc_shorturl.rb
shorturl-0.8.4 test/tc_shorturl.rb
shorturl-0.8.0 test/tc_shorturl.rb