Skip to content

Instantly share code, notes, and snippets.

@jbaudanza
Created May 13, 2011 01:03
Show Gist options
  • Save jbaudanza/969767 to your computer and use it in GitHub Desktop.
Save jbaudanza/969767 to your computer and use it in GitHub Desktop.
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