Sha256: 9c010e46fab3f6eff4c1a7b895a635496496c98db92194e7c9fecc591d6f1613

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Binary do
  include Sprinkle::Deployment

  def create_context
    binary = 'http://www.example.com/archive.tar.gz'

    deployment = deployment do
      delivery :capistrano
      binary "http://www.example.com/archive.tar.gz" do
        prefix   '/prefix/directory'
        archives '/archives/directory'
      end
    end

    installer = create_binary binary do
      prefix   '/prefix/directory'
      archives '/archives/directory'
    end

    installer.defaults(@deployment)
    
    [binary, deployment, installer]
  end

  def create_binary(binary, version = nil, &block)
    @package = mock(Sprinkle::Package, :name => 'package', :version => version)
    Sprinkle::Installers::Binary.new(@package, binary, &block)
  end

  describe "binary#prepare_commands" do
    before do
      @binary, @deployment, @installer = create_context
    end
    
    it "should return mkdir command to create the prefix directory" do
      @installer.send(:prepare_commands)[0].should == 'mkdir -p /prefix/directory'
    end
    it "should return mkdir command to create the archives directory" do
      @installer.send(:prepare_commands)[1].should == 'mkdir -p /archives/directory'
    end
  end
  
  
  describe "binary#install_commands" do
    before do
      @binary, @deployment, @installer = create_context
    end
    
    it "should return a commands to place the binary in the correct archive directory" do
      @installer.send(:install_commands)[0].should =~ /--directory-prefix=\/archives\/directory/
    end
    
    it "should return a command to extract to the correct prefix folder" do
      @installer.send(:install_commands)[1].should =~ /cd \/prefix\/directory/
    end

    it "should return a command to extract the right file in the right directory" do
      @installer.send(:install_commands)[1].should =~ / \/archives\/directory\/archive.tar.gz/
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sprinkle-0.4.2 spec/sprinkle/installers/binary_spec.rb
sprinkle-0.4.1 spec/sprinkle/installers/binary_spec.rb
sprinkle-0.4.0 spec/sprinkle/installers/binary_spec.rb
sprinkle-0.3.6 spec/sprinkle/installers/binary_spec.rb
sprinkle-0.3.5 spec/sprinkle/installers/binary_spec.rb
sprinkle-0.3.4 spec/sprinkle/installers/binary_spec.rb