Sha256: 37851c05553dca5ef599691e2b03d06aefcc558268fe7f47181749ffd2542c3b

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 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 = ::Logger::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 = ::Logger::INFO
        action.run
      end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
local_pac-0.1.9 spec/actions/create_directory_spec.rb
local_pac-0.1.8 spec/actions/create_directory_spec.rb
local_pac-0.1.7 spec/actions/create_directory_spec.rb
local_pac-0.1.6 spec/actions/create_directory_spec.rb
local_pac-0.1.5 spec/actions/create_directory_spec.rb
local_pac-0.1.4 spec/actions/create_directory_spec.rb
local_pac-0.1.3 spec/actions/create_directory_spec.rb
local_pac-0.1.2 spec/actions/create_directory_spec.rb
local_pac-0.1.1 spec/actions/create_directory_spec.rb
local_pac-0.1.0 spec/actions/create_directory_spec.rb