spec/unit/packagers/base_spec.rb in omnibus-4.0.0 vs spec/unit/packagers/base_spec.rb in omnibus-4.1.0
- old
+ new
@@ -3,21 +3,21 @@
module Omnibus
describe Packager::Base do
let(:project) do
Project.new.tap do |project|
project.name('project')
- project.install_dir('/opt/project')
+ project.install_dir(File.join(tmp_path, 'opt/project'))
project.homepage('https://example.com')
project.build_version('1.2.3')
project.build_iteration('2')
project.maintainer('Chef Software')
end
end
before do
# Force the Dir.mktmpdir call on staging_dir
- allow(Dir).to receive(:mktmpdir).and_return('/tmp/dir')
+ allow(Dir).to receive(:mktmpdir).and_return(File.join(tmp_path, 'tmp/dir'))
Config.package_dir(tmp_path)
end
subject { described_class.new(project) }
@@ -75,11 +75,11 @@
it 'is a DSL method' do
expect(subject).to have_exposed_method(:install_dir)
end
it 'returns the project instances install_dir' do
- expect(subject.install_dir).to eq('/opt/project')
+ expect(subject.install_dir).to eq(project.install_dir)
end
end
describe '#windows_safe_path' do
it 'is a DSL method' do
@@ -115,11 +115,11 @@
describe '#resource_path' do
let(:id) { :base }
before { allow(subject).to receive(:id).and_return(id) }
context 'when a local resource exists' do
- let(:resources_path) { '/resources/path' }
+ let(:resources_path) { File.join(tmp_path, '/resources/path') }
before do
project.resources_path(resources_path)
allow(File).to receive(:exist?)
@@ -128,29 +128,19 @@
end
it 'returns the local path' do
expect(subject.resource_path('foo/bar.erb')).to eq("#{resources_path}/#{id}/foo/bar.erb")
end
+
+ it 'returns the path with the id' do
+ expect(subject.resources_path).to eq("#{resources_path}/#{id}")
+ end
end
context 'when a local resource does not exist' do
it 'returns the remote path' do
expect(subject.resource_path('foo/bar.erb')).to eq("#{Omnibus.source_root.join("resources/#{id}/foo/bar.erb")}")
end
- end
- end
-
- describe '#resoures_path' do
- let(:id) { :base }
- let(:resources_path) { '/resources/path' }
-
- before do
- project.resources_path(resources_path)
- allow(subject).to receive(:id).and_return(id)
- end
-
- it 'returns the path with the id' do
- expect(subject.resources_path).to eq("#{resources_path}/#{id}")
end
end
end
end