Sha256: 764c5aa7e59d4bf47237dface19e937f3a0b39323282069ea46136ebe05fe082

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

require "spec_helper"

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

  subject(:section) { Brightbox::Config::UserApplication.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.localhost
        username = user@example.com
        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.localhost
        client_id = #{client_name}
        secret = #{random_token}
        username = user@example.com
        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}
        username = user@example.com
        EOS
      end

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

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-4.8.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.7.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.6.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.5.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.5.0.rc1 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.4.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.3.2 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.3.1 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.3.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.2.1 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.2.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.1.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.0.0 spec/unit/brightbox/config/user_application/valid_spec.rb
brightbox-cli-4.0.0.rc2 spec/unit/brightbox/config/user_application/valid_spec.rb