Sha256: e29bb6c9519f61a258d30628af7704908952cf475a236c467d334f9db233797d

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

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, :missing)).to be_nil
      end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rails_template_18f-1.2.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-1.1.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-1.0.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.8.2 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.8.1 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.8.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.7.2 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.7.1 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.7.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.6.0 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.5.3 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
rails_template_18f-0.5.2 lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb