From ba8bd06ac0ff001a630481a68d42d69617533a6b Mon Sep 17 00:00:00 2001 From: Simon Bang Terkildsen Date: Sat, 4 Jun 2016 23:34:00 +0200 Subject: [PATCH] Create seven_zip unpack command when strip_components is 0 --- libraries/sevenzip_command_builder.rb | 3 +-- spec/libraries/sevenzip_command_builder_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libraries/sevenzip_command_builder.rb b/libraries/sevenzip_command_builder.rb index 3f2fea11..841dfc0d 100644 --- a/libraries/sevenzip_command_builder.rb +++ b/libraries/sevenzip_command_builder.rb @@ -22,8 +22,7 @@ def initialize(resource) def sevenzip_command if resource.strip_components <= 0 - sevenzip_command_builder(resource.path, 'x') - return + return sevenzip_command_builder(resource.path, 'x') end tmpdir = make_temp_directory diff --git a/spec/libraries/sevenzip_command_builder_spec.rb b/spec/libraries/sevenzip_command_builder_spec.rb index d8fa5b2e..b426c131 100644 --- a/spec/libraries/sevenzip_command_builder_spec.rb +++ b/spec/libraries/sevenzip_command_builder_spec.rb @@ -40,4 +40,14 @@ expect(subject.cherry_pick).to eq(expected_command) end end + + context 'strip_components == 0' do + describe '#unpack' do + it 'generates the correct command' do + allow(resource).to receive(:strip_components).and_return(0) + expected_command = '"C:\\Program Files\\7-zip\\7z.exe" x "release_file" -so | "C:\\Program Files\\7-zip\\7z.exe" x -aoa -si -ttar -o"path" -uy' + expect(subject.unpack).to eq(expected_command) + end + end + end end