Sha256: 690042c9c6286bda8362abacadd3939f48937f8c62ea3df8eb9bd722dd90619c

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'


describe Bitly::API do
  
  context "shorten" do
    
    before do
      @long = 'http://yahoo.com'
      @hash = Bitly::API.shorten(@long)
      @short = @hash['shortUrl'] 
    end
    
    it "should return a hash" do
      @hash.should be_a(Hash)
    end
  
    it "shortUrl should be string in the format http://bit.ly/xxxxx" do
      @short.scan(/http:\/\/bit\.ly\/\S{3,}/).should_not be_empty
    end  
    
    it "shortUrl should redirect to original url" do
      RestClient.get(@short).include?('Yahoo')
    end
    
    
  end                                               
  
  context "expand" do
    
    before do
      @long = 'http://yahoo.com/'
      @short = 'http://bit.ly/pxr7s'
    end
    
    it "should return full URL as string when given http://bit.ly/xxxxx" do
      @expanded = Bitly::API.expand(@short)
      @expanded.should.eql?(@long)
    end
    
  end                                                           
  
 
  
  

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glasner-bitly-0.1.2 spec/api_spec.rb
glasner-bitly-0.1.3 spec/api_spec.rb