Sha256: 2a3566d4f41b2a0f4f305f364f8e7fde86ccbec93900fa4b5134480ed6e9cbf3

Contents?: true

Size: 1020 Bytes

Versions: 14

Compression:

Stored size: 1020 Bytes

Contents

require "spec_helper"
require "tmpdir"

describe Brightbox::BBConfig do
  describe "#config_directory_exists?" do
    let(:config) { Brightbox::BBConfig.new(:directory => @dir) }

    context "when directory exists" do
      it "returns true" do
        Dir.mktmpdir do |dir|
          @dir = dir
          expect(config.config_directory_exists?).to be true
        end
      end
    end

    context "when a file exists with the name" do
      it "returns false" do
        Tempfile.open("config_clash") do |tmp_file|
          @dir = tmp_file.path
          expect(config.config_directory_exists?).to be false
        end
      end
    end

    context "when directory does not exist" do
      it "returns false" do
        # Create a tmpdir and delete it so we are sure it should not exist
        Dir.mktmpdir { |dir| @dir = dir }
        expect(config.config_directory).to eq(@dir)
        Dir.rmdir(@dir) if Dir.exist?(@dir)
        expect(config.config_directory_exists?).to eq(false)
      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/config_directory_exists_spec.rb
brightbox-cli-4.7.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.6.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.5.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.5.0.rc1 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.4.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.3.2 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.3.1 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.3.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.2.1 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.2.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.1.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.0.0 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb
brightbox-cli-4.0.0.rc2 spec/unit/brightbox/bb_config/config_directory_exists_spec.rb