Sha256: 80041f2ff6bf98981f39888a7a2973d9184b22658562ff616a628edd96cf0dc2

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "test_helper"
require "azure/core/service"

describe Azure::Core::Service do
  let :signer do
    double()
  end

  let :request do
    req = MiniTest::Mock.new
    req.stub(:request!, response)
    req
  end

  let :response do
    double()
  end

  let :request_factory do
    rf = MiniTest::Mock.new
    rf.stub(:new, request)
    rf
  end

  let :authorizer do
    auth = MiniTest::Mock.new
    auth.stub(:sign)
    auth
  end

  subject do
    Azure::Core::Service.new(signer, authorizer)
  end

  it "instantiates a new request and signs it" do
    request_factory.expect(:new, request, [:get, "/", nil])
    authorizer.expect(:sign, request, [request, signer])

    subject.call(:get, "/", nil, request_factory)

    request_factory.verify
    authorizer.verify
  end

  it "returns the response" do
    resp = subject.call(:get, "/", nil, request_factory)
    resp.must_equal response
  end

  it "yields the request before signing it" do
    subject.call(:get, "/", nil, request_factory) do |req|
      authorizer.expect(:sign, req, [req, signer])
    end

    authorizer.verify
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/unit/core/service_test.rb
azure-0.1.0 test/unit/core/service_test.rb