Sha256: 8c2db90d55decdafe6c47c8e1877e01c0db33fceef4867c37ed933acccd3158c

Contents?: true

Size: 917 Bytes

Versions: 6

Compression:

Stored size: 917 Bytes

Contents

describe 'Base64' do

  describe 'NSData' do
    it 'should encode data' do
      str = 'testing'
      str_data = str.nsdata
      str_data.to_base64.should == 'dGVzdGluZw=='
    end

    it 'should decode data' do
      str_data = NSData.from_base64('dGVzdGluZw==')
      str = NSString.alloc.initWithData(str_data, encoding:NSUTF8StringEncoding)
      str.should == 'testing'
    end
  end

  describe 'NSString' do
    it 'should encode data' do
      'testing'.to_base64.should == 'dGVzdGluZw=='
    end
    it 'should encode data with encoding' do
      'testing'.to_base64(NSUnicodeStringEncoding).should == '//50AGUAcwB0AGkAbgBnAA=='
    end

    it 'should decode data' do
      NSString.from_base64('dGVzdGluZw==').should == 'testing'
    end
    it 'should decode data with encoding' do
      NSString.from_base64('//50AGUAcwB0AGkAbgBnAA==', NSUnicodeStringEncoding).should == 'testing'
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sugarcube-4.0.0 spec/cocoa/base64_spec.rb
sugarcube-3.5.0 spec/cocoa/base64_spec.rb
sugarcube-3.4.2 spec/cocoa/base64_spec.rb
sugarcube-3.4.1 spec/cocoa/base64_spec.rb
sugarcube-3.4.0 spec/cocoa/base64_spec.rb
sugarcube-3.3.7 spec/cocoa/base64_spec.rb