Created
May 13, 2011 01:03
-
-
Save jbaudanza/969767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.join(File.dirname(__FILE__), "../spec_helper") | |
describe 'encode64url' do | |
describe "with plaintext that normally produces pluses and slashes" do | |
before do | |
@plaintext = "A string that will encode to something with a plus and a slash \xff \xfe" | |
Base64.encode64(@plaintext).should include('+') | |
Base64.encode64(@plaintext).should include('/') | |
end | |
it "should not include a + character" do | |
encode64url(@plaintext).should_not include('+') | |
end | |
it "should not include a / character" do | |
encode64url(@plaintext).should_not include('/') | |
end | |
it "should not include any newlines" do | |
encode64url(@plaintext).should_not include("\n") | |
end | |
it "should decode correctly" do | |
decode64url(encode64url(@plaintext)).should == @plaintext | |
end | |
end | |
describe "with plaintext that normally produces padding" do | |
before do | |
@plaintext = 'A' | |
Base64.encode64(@plaintext).should include('=') | |
end | |
it "should not include a = character" do | |
encode64url(@plaintext).should_not include('=') | |
end | |
it "should decode correctly" do | |
decode64url(encode64url(@plaintext)).should == @plaintext | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment