Sha256: b380657655409ef8d790f0d4004585b60329aa7d1b2464ba79a67e2297651092

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8
require 'spec_helper'

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

  context '#run' do
    it 'runs the action' do
      action = Actions::CreateRepository.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::CreateRepository.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::CreateRepository.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

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

      silence(:stderr) do
        action.run
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
local_pac-0.3.0 spec/actions/create_repository_spec.rb
local_pac-0.2.3 spec/actions/create_repository_spec.rb
local_pac-0.2.2 spec/actions/create_repository_spec.rb
local_pac-0.2.1 spec/actions/create_repository_spec.rb
local_pac-0.2.0 spec/actions/create_repository_spec.rb