Sha256: bba0fbc6f5609a88b3b101603eb3adb90eccc656e90d67521bf508a3b29a4adb

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'helpers/request_helpers'

describe Conjur::Variable do
  include RequestHelpers
  let(:url) { "http://example.com/variable" }
  subject(:variable) { Conjur::Variable.new url }

  before { subject.attributes = {'version_count' => 42} }

  describe '#version_count' do
    it "is read from the attributes" do
      expect(variable.version_count).to eq(42)
    end
  end

  describe '#add_value' do
    it "posts the new value" do
      expect_request(
        method: :post,
        url: "#{url}/values",
        payload: { value: 'new-value' },
        headers: {}
      )
      subject.add_value 'new-value'
    end
  end

  describe '#value' do
    it "gets the value" do
      allow_request(
        method: :get,
        url: "#{url}/value",
        headers: {}
      ).and_return(double "response", body: "the-value")
      expect(subject.value).to eq("the-value")
    end

    it "parametrizes the request with a version" do
      allow_request(
        method: :get,
        url: "#{url}/value?version=42",
        headers: {}
      ).and_return(double "response", body: "the-value")
      expect(subject.value(42)).to eq("the-value")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
conjur-api-4.19.1 spec/variable_spec.rb
conjur-api-4.19.0 spec/variable_spec.rb
conjur-api-4.16.0 spec/variable_spec.rb
conjur-api-4.15.0 spec/variable_spec.rb
conjur-api-4.14.0 spec/variable_spec.rb