2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
require 'base64'
|
|
|
|
|
|
|
|
describe "Base64#urlsafe_encode64" do
|
|
|
|
it "uses '_' instead of '/'" do
|
|
|
|
encoded = Base64.urlsafe_encode64('Where am I? Who am I? Am I? I?')
|
|
|
|
encoded.should == "V2hlcmUgYW0gST8gV2hvIGFtIEk_IEFtIEk_IEk_"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses '-' instead of '+'" do
|
|
|
|
encoded = Base64.urlsafe_encode64('"Being disintegrated makes me ve-ry an-gry!" <huff, huff>')
|
|
|
|
encoded.should == 'IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-'
|
|
|
|
end
|
|
|
|
|
2018-04-28 15:50:06 -04:00
|
|
|
it "makes padding optional" do
|
|
|
|
Base64.urlsafe_encode64("1", padding: false).should == "MQ"
|
|
|
|
Base64.urlsafe_encode64("1").should == "MQ=="
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|