Sha256: d2b0e306d76d32c83aed8c3ce2ab9d54f89060c03319a30dc3c44aff40dff37b

Contents?: true

Size: 955 Bytes

Versions: 4

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe CloudGovConfig, type: :model do
  subject { described_class }

  describe ".dig" do
    context "VCAP_SERVICES is blank" do
      it "returns nil" do
        expect(subject.dig(:s3, :credentials, :bucket)).to be_nil
      end
    end

    context "VCAP_SERVICES is set" do
      let(:bucket_name) { "bucket-name" }
      let(:vcap) {
        {
          s3: [
            {
              credentials: {
                bucket: bucket_name
              }
            }
          ]
        }
      }

      around do |example|
        ClimateControl.modify VCAP_SERVICES: vcap.to_json do
          example.run
        end
      end

      it "can find a path" do
        expect(subject.dig(:s3, :credentials, :bucket)).to eq bucket_name
      end

      it "returns nil for a missing path" do
        expect(subject.dig(:s3, :credentials, :other)).to be_nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_template_18f-0.5.1 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.5.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.4.1 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.4.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb