Skip to content

Instantly share code, notes, and snippets.

@jbaylor-rpx
Created May 14, 2012 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbaylor-rpx/2691627 to your computer and use it in GitHub Desktop.
Save jbaylor-rpx/2691627 to your computer and use it in GitHub Desktop.
Specs for salesforce_id.rb (https://gist.github.com/2691624)
#
# Specs for salesforce_id.rb (https://gist.github.com/2691624)
#
require 'spec_helper'
describe SalesforceId do
describe 'convert' do
before do
@sf15 = 'a0D30000001n7Pi'
@sf18 = 'a0D30000001n7PiEAC'
end
it 'should convert a 15-char case-sensitive ID to an 18-char case-insensitive ID' do
SalesforceId.convert(@sf15).should == @sf18
end
it 'should convert an 18-char case-insensitive ID to a 15-char case-sensitive ID' do
SalesforceId.convert(@sf18).should == @sf15
end
it 'should convert a downcased 18-char ID to a 15-char case-sensitive ID' do
SalesforceId.convert(@sf18.downcase).should == @sf15
end
it 'should convert an upcased 18-char ID to a 15-char case-sensitive ID' do
SalesforceId.convert(@sf18.upcase).should == @sf15
end
end
describe 'decimaltobase32' do
it 'should do the strange salesforce conversion for 0' do
SalesforceId.decimaltobase32(0).should == 'A'
end
it 'should do the strange salesforce conversion for 25' do
SalesforceId.decimaltobase32(25).should == 'Z'
end
it 'should do the strange salesforce conversion for 26' do
SalesforceId.decimaltobase32(26).should == '0'
end
it 'should do the strange salesforce conversion for 31' do
SalesforceId.decimaltobase32(31).should == '5'
end
it 'should return nil for values outside of 0 to 31' do
SalesforceId.decimaltobase32(nil).should == nil
SalesforceId.decimaltobase32(-1).should == nil
SalesforceId.decimaltobase32(32).should == nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment