Skip to content

Commit

Permalink
Add Ruby 1.8.7 #strict_encode64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Feb 18, 2014
1 parent 301c10d commit 322a5ad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/http.rb
Expand Up @@ -9,7 +9,7 @@
require 'http/response'
require 'http/response/body'
require 'http/response/parser'
require 'http/uri_backport' if RUBY_VERSION < '1.9.0'
require 'http/backports' if RUBY_VERSION < '1.9.0'

# HTTP should be easy
module HTTP
Expand Down
2 changes: 2 additions & 0 deletions lib/http/backports.rb
@@ -0,0 +1,2 @@
require 'http/backports/uri'
require 'http/backports/base64'
6 changes: 6 additions & 0 deletions lib/http/backports/base64.rb
@@ -0,0 +1,6 @@
module Base64
# :nodoc:
def self.strict_encode64(data)
encode64(data).gsub(/\n/, '')
end
end
File renamed without changes.
13 changes: 13 additions & 0 deletions spec/http/backports/base64_spec.rb
@@ -0,0 +1,13 @@
require 'spec_helper'

describe Base64 do
specify { expect(Base64).to respond_to :strict_encode64 }

describe '.strict_encode64' do
let(:long_string) { (0...256).map { ('a'..'z').to_a[rand(26)] }.join }

it 'returns a String without whitespaces' do
expect(Base64.strict_encode64 long_string).to_not match(/\s/)
end
end
end

0 comments on commit 322a5ad

Please sign in to comment.