Sha256: 4bbf22d92db22b6e6c7b8049ea5098ef73fdc1b59cb7b4f103a0772cd284074c

Contents?: true

Size: 1.82 KB

Versions: 40

Compression:

Stored size: 1.82 KB

Contents

require "spec_helper"

describe Brightbox::Config::ApiClient do
  let(:client_name) { "cli-12345" }
  let(:config) { config_from_contents(contents) }
  let(:config_section) { config[client_name] }

  subject(:section) { Brightbox::Config::ApiClient.new(config_section, client_name) }

  describe "#valid?" do
    context "when config is valid" do
      let(:contents) do
        <<-EOS
        [#{client_name}]
        api_url = http://api.brightbox.dev
        client_id = #{client_name}
        secret = #{random_token}
        EOS
      end

      it "is valid" do
        expect(section).to be_valid
      end
    end

    context "when config has additional values" do
      let(:contents) do
        <<-EOS
        [#{client_name}]
        api_url = http://api.brightbox.dev
        client_id = #{client_name}
        secret = #{random_token}
        theme = blue
        EOS
      end

      it "is valid" do
        expect(section).to be_valid
      end
    end

    context "when config is missing api_url" do
      let(:contents) do
        <<-EOS
        [#{client_name}]
        client_id = #{client_name}
        secret = #{random_token}
        EOS
      end

      it "is invalid" do
        expect(section).to_not be_valid
      end
    end

    context "when config is missing client_id" do
      let(:contents) do
        <<-EOS
        [#{client_name}]
        api_url = http://api.brightbox.dev
        secret = #{random_token}
        EOS
      end

      it "is invalid" do
        expect(section).to_not be_valid
      end
    end

    context "when config is missing secret" do
      let(:contents) do
        <<-EOS
        [#{client_name}]
        api_url = http://api.brightbox.dev
        client_id = #{client_name}
        EOS
      end

      it "is invalid" do
        expect(section).to_not be_valid
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

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