Sha256: 4be27a215bded0ef395b0c02923e30fe7d060ad0ce08fb72dcc44d8cfb99e664

Contents?: true

Size: 998 Bytes

Versions: 14

Compression:

Stored size: 998 Bytes

Contents

$test_lib_dir = File.join(File.dirname(__FILE__), "..", "lib")
$:.unshift($test_lib_dir)

require "test/unit"
require "constants"
require "longurl/exceptions"
require "longurl/service"

class TestNoCacheService < Test::Unit::TestCase
  # OPTIMIZE : all these tests are a plain copy from service_test.rb, we can make something better.
  
  def setup
    @service = LongURL::Service.new(:cache => false)
  end
  
  def test_query_should_raise_invalid_url_if_url_is_nil
    assert_raise(LongURL::InvalidURL) { @service.query(nil) }
  end

  def test_query_should_raise_invalid_url_if_url_is_empty
    assert_raise(LongURL::InvalidURL) { @service.query('') }
  end

  def test_query_should_returns_given_url_if_not_shorten_url
    assert_equal "http://www.google.com", @service.query("http://www.google.com")
  end

  def test_query_should_returns_expanded_url_for_supported_services
    ShortToLong.each_value {|service| service.each {|short, long| assert_equal long, @service.query(short)}}
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
chuyeow-longurl-0.1.5 test/service/no_cache_service_test.rb
jakimowicz-longurl-0.1.1 test/service/no_cache_service_test.rb
jakimowicz-longurl-0.1.3 test/service/no_cache_service_test.rb
jakimowicz-longurl-0.1.4 test/service/no_cache_service_test.rb
jakimowicz-longurl-0.1.5 test/service/no_cache_service_test.rb
jakimowicz-longurl-0.1.6 test/service/no_cache_service_test.rb
ivey-longurl-0.1.7 test/service/no_cache_service_test.rb
longurl-0.1.6 test/service/no_cache_service_test.rb
longurl-0.1.5 test/service/no_cache_service_test.rb
longurl-0.1.4 test/service/no_cache_service_test.rb
longurl-0.1.2 test/service/no_cache_service_test.rb
longurl-0.1.1 test/service/no_cache_service_test.rb
longurl-0.1.0 test/service/no_cache_service_test.rb
longurl-0.1.3 test/service/no_cache_service_test.rb