Sha256: 12d596c8914e9065845bd682c02e457755742b11d031a3224227ee3af8422659

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Actions::CreateDirectory do
  context '#initialize' do
    it 'requires a path' do
      Actions::CreateDirectory.new(working_directory)
    end
  end

  context '#run' do
    it 'runs the action' do
      action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'))
      silence(:stderr) do
        action.run
      end

      expect(path_exists?('repo')).to be_true
    end

    it 'respects existing path' do
      create_directory('repo')

      action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'))

      result = capture(:stderr) do
        LocalPac.ui_logger.level = :info
        action.run
      end

      expect(result).to include('already')
    end

    it 'does not respect existing path if forced to' do
      create_directory('repo')

      action = Actions::CreateDirectory.new(::File.join(working_directory, 'repo'), force: true)

      result = capture(:stderr) do
        LocalPac.ui_logger.level = :info
        action.run
      end

      expect(result).to include('Creating directory')
    end

    it 'resolves ~' do
      action = with_environment 'HOME' => working_directory do
        Actions::CreateDirectory.new('~/file')
      end

      silence(:stderr) do
        action.run
      end

      expect(path_exists?('file')).to be_true
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
local_pac-0.10.2 spec/actions/create_directory_spec.rb
local_pac-0.10.1 spec/actions/create_directory_spec.rb
local_pac-0.10.0 spec/actions/create_directory_spec.rb
local_pac-0.9.0 spec/actions/create_directory_spec.rb
local_pac-0.7.0 spec/actions/create_directory_spec.rb
local_pac-0.6.3 spec/actions/create_directory_spec.rb
local_pac-0.6.2 spec/actions/create_directory_spec.rb
local_pac-0.6.1 spec/actions/create_directory_spec.rb
local_pac-0.5.0 spec/actions/create_directory_spec.rb
local_pac-0.4.0 spec/actions/create_directory_spec.rb