Sha256: 4b9ff915c5688000b60461d44c735fd0cdf4d92cc554c1ef6d350cd6163760f5

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 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
        [#{@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

12 entries across 12 versions & 1 rubygems

Version Path
brightbox-cli-2.2.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.1.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.1.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.1.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.0.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.6.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.5.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.4.3 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.4.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.4.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.4.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-1.3.0 spec/unit/brightbox/bb_config/account_spec.rb