Sha256: a26db6bfe18b42a337c0a335d8287782cd951e5e233abfa25baca58cae54cd22

Contents?: true

Size: 1.82 KB

Versions: 20

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'
require 'berkshelf/api/rest_gateway'

describe Berkshelf::API::Mixin::Services do
  let(:includer) do
    Class.new { include Berkshelf::API::Mixin::Services }.new
  end

  describe "#cache_builder" do
    subject { includer.cache_builder }

    context "when the CacheBuilder is running" do
      before { Berkshelf::API::CacheBuilder.start }

      it "returns the running instance of CacheBuilder" do
        expect(subject).to be_a(Berkshelf::API::CacheBuilder)
      end
    end

    context "when the CacheBuilder is not running" do
      before { Berkshelf::API::CacheBuilder.stop }

      it "raises a NotStartedError" do
        expect { subject }.to raise_error(Berkshelf::API::NotStartedError)
      end
    end
  end

  describe "#cache_manager" do
    subject { includer.cache_manager }

    context "when the CacheManager is running" do
      before { Berkshelf::API::CacheManager.start }

      it "returns the running instance of CacheManager" do
        expect(subject).to be_a(Berkshelf::API::CacheManager)
      end
    end

    context "when the CacheManager is not running" do
      before { Berkshelf::API::CacheManager.stop }

      it "raises a NotStartedError" do
        expect { subject }.to raise_error(Berkshelf::API::NotStartedError)
      end
    end
  end

  describe "#rest_gateway" do
    subject { includer.rest_gateway }

    context "when the RESTGateway is running" do
      before { Berkshelf::API::RESTGateway.start }

      it "returns the running instance of RESTGateway" do
        expect(subject).to be_a(Berkshelf::API::RESTGateway)
      end
    end

    context "when the RESTGateway is not running" do
      before { Berkshelf::API::RESTGateway.stop }

      it "raises a NotStartedError" do
        expect { subject }.to raise_error(Berkshelf::API::NotStartedError)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
berkshelf-api-3.0.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.2.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.1.3 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.1.2 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.1.1 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.1.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-2.0.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.4.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.3.1 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.3.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.2.2 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.2.1 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.2.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.2.0.rc2 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.2.0.rc1 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.1.1 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.1.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-1.0.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-0.2.0 spec/unit/berkshelf/api/mixin/services_spec.rb
berkshelf-api-0.1.0 spec/unit/berkshelf/api/mixin/services_spec.rb