Sha256: 9272d86ad6b8fd3fb72285e432a6afbcc432c197d5d4bd25659e8d960d33529f

Contents?: true

Size: 819 Bytes

Versions: 6

Compression:

Stored size: 819 Bytes

Contents

require 'spec_helper'

describe HTTP::AuthorizationHeader::BasicAuth do
  describe '.new' do
    it 'fails when options is not a Hash' do
      expect { described_class.new '[FOOBAR]' }.to raise_error
    end

    it 'fails when :pass is not given' do
      expect { described_class.new :user => '[USER]' }.to raise_error
    end

    it 'fails when :user is not given' do
      expect { described_class.new :pass => '[PASS]' }.to raise_error
    end
  end

  describe '#to_s' do
    let(:user)        { 'foo' }
    let(:pass)        { 'bar' * 100 }
    let(:user_n_pass) { user + ':' + pass }
    let(:builder)     { described_class.new :user => user, :pass => pass }

    subject { builder.to_s }

    it { should eq "Basic #{Base64.strict_encode64 user_n_pass}" }
    it { should match(/^Basic [^\s]+$/) }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
http-0.6.4 spec/http/authorization_header/basic_auth_spec.rb
http-0.6.3 spec/http/authorization_header/basic_auth_spec.rb
http-0.6.2 spec/http/authorization_header/basic_auth_spec.rb
http-0.6.1 spec/http/authorization_header/basic_auth_spec.rb
http-0.6.0 spec/http/authorization_header/basic_auth_spec.rb
http-0.6.0.pre spec/http/authorization_header/basic_auth_spec.rb