Sha256: 2a5c3a4e853ab23c978d241afd80ed1426a752ca03c6609ce6f0dee0008cb5a8

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe 'PGit::CurrentProject' do
  it 'instantiates the PGit::Project that exists in the config file and whose path matches the working directory' do
    matching_path = '/some/matching_path'
    matching_project = instance_double('PGit::Project',
                                      path: matching_path)
    projects = [matching_project]
    configuration = instance_double('PGit::Configuration',
                                    projects: projects)
    allow(Dir).to receive(:pwd).and_return(matching_path)
    proj = PGit::CurrentProject.new(configuration)

    expect(proj.path).to eq matching_path
  end

  it 'raises an error if the project does not exist' do
    matching_path = '/some/matching_path'
    matching_project = instance_double('PGit::Project',
                                      path: matching_path)
    projects = [matching_project]
    configuration = instance_double('PGit::Configuration',
                                    projects: projects)
    allow(Dir).to receive(:pwd).and_return('/some/non-matching-path')

    expect{ PGit::CurrentProject.new(configuration) }.to raise_error(PGit::Error::User, "Current Project does not exist. See `pgit proj add -h`")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-1.0.0 spec/pgit/current_project_spec.rb