Sha256: 973f45cb0cf686d0aa7b124206dbd112a6ef97b2ea7701dad0f733d1ca360733

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require "spec_helper"

RSpec.describe Brightbox::Image, "#status" do
  subject(:image) { Brightbox::Image.new(fog_model) }

  let(:fog_model) do
    double(
      "Fog::Compute::Brightbox::Image",
      id: "img-12345",
      attributes: {
        "id": "img-12345",
        "status": status,
        "public": is_public
      },
      public: is_public
    )
  end
  let(:is_public) { false }

  context "when the image is pending" do
    let(:status) { "pending" }

    it "returns 'pending'" do
      expect(image.status).to eq("pending")
    end
  end

  context "when the image is available" do
    let(:status) { "available" }

    context "with public visibility" do
      let(:is_public) { true }

      it "returns 'public'" do
        expect(image.status).to eq("public")
      end
    end

    context "without public visibility" do
      let(:is_public) { false }

      it "returns 'private'" do
        expect(image.status).to eq("private")
      end
    end
  end

  context "when the image is deprecated" do
    let(:status) { "deprecated" }

    context "with public visibility" do
      let(:is_public) { true }

      it "returns 'deprecated'" do
        expect(image.status).to eq("deprecated")
      end
    end

    context "without public visibility" do
      let(:is_public) { false }

      it "returns 'private'" do
        expect(image.status).to eq("private")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.rc2 spec/unit/brightbox/image/status_spec.rb
brightbox-cli-5.0.0.rc1 spec/unit/brightbox/image/status_spec.rb