Sha256: 1f2ad1a6b8633bde659d14e9935bceb55712bfb2810c2c84de63407e56a16f15

Contents?: true

Size: 1.39 KB

Versions: 18

Compression:

Stored size: 1.39 KB

Contents

require "spec_helper"

describe Brightbox::BBConfig do
  describe "#account" do
    context "when passed as an option" do
      before do
        @account_name = "acc-kll54"
        @config = Brightbox::BBConfig.new(:account => @account_name)
      end

      it "returns the passed version" do
        expect(@config.account).to eql(@account_name)
      end
    end

    context "when config has no default account" do
      before do
        contents = <<-EOS
        [core]
        default_client = default
        [default]
        key = value
        EOS
        @config = config_from_contents(contents)
      end

      it "returns nil" do
        expect(@config.account).to be_nil
      end
    end

    context "when config has a default account set" do
      before do
        @account_name = "acc-ghj32"
        @client_name = "app-b3n5b"
        contents = <<-EOS
        [core]
        default_client = #{@client_name}
        [#{@client_name}]
        default_account = #{@account_name}
        EOS
        @config = config_from_contents(contents)

        # Never hit the API
        expect(Brightbox::Account).to_not receive(:all)
      end

      it "returns the configured default" do
        expect(@config.account).to eql(@account_name)
      end

      it "does not dirty the config" do
        expect do
          @config.account
        end.to_not change(@config, :dirty?)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-5.0.0.rc2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-5.0.0.rc1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-5.0.0.alpha spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.8.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.7.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.6.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.5.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.5.0.rc1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.4.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.3.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.3.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.3.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.2.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.2.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.1.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.0.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-4.0.0.rc2 spec/unit/brightbox/bb_config/account_spec.rb