spec/unit/omnibus_spec.rb in omnibus-3.2.2 vs spec/unit/omnibus_spec.rb in omnibus-4.0.0.beta.1

- old
+ new

@@ -16,62 +16,67 @@ Omnibus::Config.project_root('/foo/bar') Omnibus::Config.local_software_dirs(['/local', '/other']) Omnibus::Config.software_gems(['omnibus-software', 'custom-omnibus-software']) end - describe '#software_dirs' do - let(:software_dirs) { Omnibus.software_dirs } + describe '#which' do + it 'returns nil when the file does not exist' do + stub_env('PATH', nil) + expect(subject.which('not_a_real_executable')).to be nil + end - it 'includes project_root' do - expect(software_dirs).to include('/foo/bar/config/software') + it 'retusnt the path when the file exists' do + ruby = Bundler.which('ruby') + expect(subject.which(ruby)).to eq(ruby) end + end - it 'includes local_software_dirs dirs' do - expect(software_dirs).to include('/local/config/software') - expect(software_dirs).to include('/other/config/software') + describe '#project_path' do + before do + allow(Omnibus).to receive(:project_map) + .and_return('chef' => '/projects/chef') end - it 'includes software_gems dirs' do - expect(software_dirs).to include('/gem/omnibus-software/config/software') - expect(software_dirs).to include('/gem/custom-omnibus-software/config/software') + it 'accepts a string' do + expect(subject.project_path('chef')).to eq('/projects/chef') end - it 'has the correct precedence order' do - expect(software_dirs).to eq([ - '/foo/bar/config/software', - '/local/config/software', - '/other/config/software', - '/gem/omnibus-software/config/software', - '/gem/custom-omnibus-software/config/software', - ]) + it 'accepts a symbol' do + expect(subject.project_path(:chef)).to eq('/projects/chef') end - end - describe '#software_map' do - let(:software_map) { Omnibus.send(:software_map) } - - it 'returns a hash' do - expect(software_map).to be_a(Hash) + it 'returns nil when the project does not exist' do + expect(subject.project_path('bacon')).to be nil end end - describe '#process_dsl_files' do + describe '#software_path' do before do - Omnibus::Config.project_root(complicated_path) - stub_ohai(platform: 'ubuntu', version: '12.04') + allow(Omnibus).to receive(:software_map) + .and_return('chef' => '/software/chef') end - it 'populates the 5 projects' do - Omnibus.process_dsl_files + it 'accepts a string' do + expect(subject.software_path('chef')).to eq('/software/chef') + end - expect(Omnibus.projects.size).to eq(5) + it 'accepts a symbol' do + expect(subject.software_path(:chef)).to eq('/software/chef') + end - names = Omnibus.projects.map(&:name) - expect(names).to include('angrychef') - expect(names).to include('chef-windows') - expect(names).to include('chef') - expect(names).to include('chefdk-windows') - expect(names).to include('chefdk') + it 'returns nil when the project does not exist' do + expect(subject.software_path('bacon')).to be nil end + end + describe '#possible_paths_for' do + it 'searches all paths' do + expect(subject.possible_paths_for('file')).to eq(%w( + /foo/bar/file + /local/file + /other/file + /gem/omnibus-software/file + /gem/custom-omnibus-software/file + )) + end end end