Sha256: c8f54658b71b325e7338a02f1f7e3021309c3da1a8a34ccb984784f8f414ced2

Contents?: true

Size: 1.69 KB

Versions: 12

Compression:

Stored size: 1.69 KB

Contents

require "spec_helper"
require "conjur/conjurize/script"

describe Conjur::Conjurize::Script do
  describe ".latest_conjur_cookbook_release" do
    let(:releases_json) do
      %([
        {
          "name": "v0.4.0",
          "assets": [{
            "name": "conjur-v0.4.0.tar.gz",
            "browser_download_url": "http://example.com/conjur-v0.4.0.tar.gz"
          }]
        },
        {
          "name": "v0.3.0",
          "assets": [{
            "name": "conjur-v0.3.0.tar.gz",
            "browser_download_url": "http://example.com/conjur-v0.3.0.tar.gz"
          }]
        }
      ])
    end

    before do
      allow(Conjur::Conjurize::Script).to receive(:open)\
        .with("https://api.github.com/repos/conjur-cookbooks/conjur/releases")\
        .and_return double(read: releases_json)
    end

    it "looks up the latest release download url" do
      expect(Conjur::Conjurize::Script.latest_conjur_cookbook_release).to \
        eq "http://example.com/conjur-v0.4.0.tar.gz"
    end

    context "with latest release is without any tarballs" do
      let(:releases_json) do
        %([
          {
            "name": "v0.4.0",
            "assets": []
          },
          {
            "name": "v0.3.0",
            "assets": [{
              "name": "conjur-v0.3.0.tar.gz",
              "browser_download_url": "http://example.com/conjur-v0.3.0.tar.gz"
            }]
          }
        ])
      end

      it "returns the previous one and warns" do
        err = $stderr.grab do
          expect(Conjur::Conjurize::Script.latest_conjur_cookbook_release).to \
            eq "http://example.com/conjur-v0.3.0.tar.gz"
        end
        expect(err).to include "WARNING"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
conjur-cli-5.6.6 spec/conjurize/script_spec.rb
conjur-cli-5.6.5 spec/conjurize/script_spec.rb
conjur-cli-5.6.4 spec/conjurize/script_spec.rb
conjur-cli-5.6.3 spec/conjurize/script_spec.rb
conjur-cli-5.5.0 spec/conjurize/script_spec.rb
conjur-cli-5.4.0 spec/conjurize/script_spec.rb
conjur-cli-5.3.0 spec/conjurize/script_spec.rb
conjur-cli-5.2.5 spec/conjurize/script_spec.rb
conjur-cli-5.2.4 spec/conjurize/script_spec.rb
conjur-cli-5.2.3 spec/conjurize/script_spec.rb
conjur-cli-5.2.1 spec/conjurize/script_spec.rb
conjur-cli-5.2.0 spec/conjurize/script_spec.rb