Sha256: 930876671095b170c6c8f5781e1edba3d62a3fe09a3f59c1e474edfd18cb68cc

Contents?: true

Size: 1.39 KB

Versions: 28

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

28 entries across 28 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-3.2.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-3.1.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-3.0.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-3.0.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.12.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.11.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.11.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.11.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.10.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.9.3 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.9.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.9.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.9.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.8.2 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.8.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.8.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.7.1 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.7.0 spec/unit/brightbox/bb_config/account_spec.rb
brightbox-cli-2.6.0 spec/unit/brightbox/bb_config/account_spec.rb