Sha256: f780f448084b2787453fef91b50880f7b48b721e7802e760347d3432b78df825

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

require "spec_helper"

describe Brightbox::BBConfig do
  describe "#delete_section" do
    let(:client_name) { "removable" }

    context "when section is exists" do
      let(:contents) do
        <<-EOS
        [core]
        default_client = removable
        [removable]
        alias = removable
        key = value
        EOS
      end

      before do
        @config = config_from_contents(contents)
      end

      it "removes it from the config" do
        expect(config_file_contents).to include("[#{client_name}]")
        @config.delete_section(client_name)
        expect(config_file_contents).to_not include("[#{client_name}]")
      end

      it "removes the default" do
        expect(@config.default_client).to eql(client_name)
        @config.delete_section(client_name)
        expect(@config.default_client).to eql(nil)
      end
    end

    context "when section does not exist" do
      let(:contents) { "" }

      before do
        @config = config_from_contents(contents)
      end

      it "does not change the config" do
        original_contents = config_file_contents
        @config.delete_section(client_name)
        expect(config_file_contents).to eql(original_contents)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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