Sha256: 318727a03091b073d2fd3f806b1a7ca7ba8aff7f6c709f7e811724282a80437e

Contents?: true

Size: 1.95 KB

Versions: 12

Compression:

Stored size: 1.95 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Sprinkle::Installers::Gem do

  before do
    @gem = 'rails'
    @version = '2.0.2'
    @options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems' }
  end

  def create_gem(gem, version = nil, options = {}, &block)
    @package = mock(Sprinkle::Package, :name => gem, :version => version, :source => nil, :repository => nil)
    Sprinkle::Installers::Gem.new(@package, gem, options, &block)
  end

  describe 'when created' do

    before do
      @installer = create_gem @gem, @version, @options
    end

    it 'should accept a single package to install' do
      @installer.gem.should == @gem
    end

    it 'should optionally store a version of the gem to install' do
      @installer.version.should == '2.0.2'
    end

    it 'should optionally store a source location of the gem to install' do
      @installer.source.should == 'http://gems.github.com/'
    end

    it 'should optionally store the repository location where gems are to be installed' do
      @installer.repository.should == @options[:repository]
    end

  end

  describe 'during installation' do

    describe 'without a version' do

      before do
        @installer = create_gem @gem do
          pre :install, 'op1'
          post :install, 'op2'
        end
      end

      it 'should invoke the gem installer for the specified package' do
        @installer.send(:install_commands).should == "gem install #{@gem}"
      end

      it 'should automatically insert pre/post commands for the specified package' do
        @installer.send(:install_sequence).should == [ 'op1', "gem install #{@gem}", 'op2' ]
      end

    end

    describe 'with a specific version' do

      before do
        @installer = create_gem @gem, @version
      end

      it 'should install a specific version if defined' do
        @installer.send(:install_commands).should == "gem install #{@gem} --version '#{@version}'"
      end

    end
    
  end

end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
auser-sprinkle-0.1.5 spec/sprinkle/installers/gem_spec.rb
auser-sprinkle-0.1.6 spec/sprinkle/installers/gem_spec.rb
crafterm-sprinkle-0.1.6 spec/sprinkle/installers/gem_spec.rb
crafterm-sprinkle-0.1.7 spec/sprinkle/installers/gem_spec.rb
crafterm-sprinkle-0.1.8 spec/sprinkle/installers/gem_spec.rb
crafterm-sprinkle-0.1.9 spec/sprinkle/installers/gem_spec.rb
mitchellh-sprinkle-0.1.5 spec/sprinkle/installers/gem_spec.rb
mitchellh-sprinkle-0.1.6 spec/sprinkle/installers/gem_spec.rb
sprinkle-0.1.6 spec/sprinkle/installers/gem_spec.rb
sprinkle-0.1.8 spec/sprinkle/installers/gem_spec.rb
sprinkle-0.1.7 spec/sprinkle/installers/gem_spec.rb
sprinkle-0.1.9 spec/sprinkle/installers/gem_spec.rb