Sha256: e305e02146d9c1f7654b85c7af5deb68932dccd68600981d2189a69332230d07

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'

describe Restfulness::Requests::Authorization do

  let :app do
    Class.new(Restfulness::Application) do
      routes do
        # empty
      end
    end
  end
  let :request do
    Restfulness::Request.new(app)
  end

  describe "#authorization" do
    it "should be nil if no authorization header resent" do
      auth = request.authorization
      expect(auth).to be_nil
    end

    it "should be nil if authorization header is blank" do
      request.headers[:authorization] = ""
      auth = request.authorization
      expect(auth).to be_nil
    end
 
    it "should build new authorization header when present" do
      request.headers[:authorization] = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
      auth = request.authorization
      expect(auth).to be_a(Restfulness::Requests::AuthorizationHeader)
      expect(auth.schema).to eql("Basic")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restfulness-0.3.6 spec/unit/requests/authorization_spec.rb
restfulness-0.3.5 spec/unit/requests/authorization_spec.rb
restfulness-0.3.4 spec/unit/requests/authorization_spec.rb