# 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 end end