Sha256: 61d90f0fb63660eb4bf8b4534148d004bd187a32411e682841f1459d16649652

Contents?: true

Size: 1.19 KB

Versions: 32

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'puppet/module_tool/applications'
require 'puppet_spec/modules'

describe Puppet::ModuleTool::Applications::Unpacker do
  include PuppetSpec::Files

  let(:target)      { tmpdir("unpacker") }
  let(:module_name) { 'myusername-mytarball' }
  let(:filename)    { tmpdir("module") + "/#{module_name}-1.0.0.tar.gz" }
  let(:working_dir) { tmpdir("working_dir") }
  let(:unpacker) do
    Puppet::ModuleTool::Applications::Unpacker.new(filename, :target_dir => target)
  end

  before :each do
    Puppet.settings[:module_working_dir] = working_dir
  end

  it "should raise ArgumentError when filename is invalid" do
    expect { Puppet::ModuleTool::Applications::Unpacker.new("invalid.tar.gz", :target_dir => target) }.to raise_error(ArgumentError)
  end

  it "should attempt to untar file to temporary location" do
    untarrer = mock('untarrer')
    Puppet::ModuleTool::Tar.expects(:instance).with(module_name).returns(untarrer)
    untarrer.expects(:unpack).with(filename, regexp_matches(/^#{Regexp.escape(working_dir)}/)) do |src, dest|
      FileUtils.mkdir(File.join(dest, 'extractedmodule'))
    end

    unpacker.run
    File.should be_directory(File.join(target, 'mytarball'))
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
puppet-3.5.1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.1-x86-mingw32 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.1.rc1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.1.rc1-x86-mingw32 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc3 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc3-x86-mingw32 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc2 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc2-x86-mingw32 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.5.0.rc1-x86-mingw32 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.3 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.2 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.0 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.0.rc2 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.4.0.rc1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.3.2 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.3.1 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.3.1.rc3 spec/unit/module_tool/applications/unpacker_spec.rb
puppet-3.3.1.rc2 spec/unit/module_tool/applications/unpacker_spec.rb