Sha256: b2ab0cc9ac7973479c1c9f9dd857c48b9e65953928d5ed9f17d71217b4e30c74

Contents?: true

Size: 1.7 KB

Versions: 22

Compression:

Stored size: 1.7 KB

Contents

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

describe Sprinkle::Installers::PushText do

  before do
    @package = mock(Sprinkle::Package, :name => 'package')
    @options = {:sudo => true}
  end

  def create_text(text, path, options={}, &block)
    Sprinkle::Installers::PushText.new(@package, text, path, options, &block)
  end

  describe 'when created' do

    it 'should accept a single package to install' do
      @installer = create_text 'crazy-configuration-methods', '/etc/doomed/file.conf'
      @installer.text.should == 'crazy-configuration-methods'
      @installer.path.should == '/etc/doomed/file.conf'
    end

  end

  describe 'during installation' do

    before do
      @installer = create_text 'another-hair-brained-idea', '/dev/mind/late-night' do
        pre :install, 'op1'
        post :install, 'op2'
      end
      @install_commands = @installer.send :install_commands
    end

    it 'should invoke the push text installer for all specified packages' do
      @install_commands.should =~ /echo 'another-hair-brained-idea' | tee -a \/dev\/mind\/late-night/
    end

    it 'should automatically insert pre/post commands for the specified package' do
      @installer.send(:install_sequence).should == [ 'op1', "echo 'another-hair-brained-idea' | tee -a /dev/mind/late-night", 'op2' ]
    end

  end
  
  describe 'running with sudo' do
    before do
      @installer = create_text "I'm a special user", "/dev/mind/the-day-after", :sudo => true
      @install_commands = @installer.send :install_commands
    end
    
    it "should invoke the push installer with sudo" do
      @install_commands.should =~ /echo 'I\'m a special user' | sudo tee -a \/dev\/mind\/the-day-after/
    end
  end

end

Version data entries

22 entries across 22 versions & 7 rubygems

Version Path
crafterm-sprinkle-0.2.1 spec/sprinkle/installers/push_text_spec.rb
crafterm-sprinkle-0.2.2 spec/sprinkle/installers/push_text_spec.rb
jemmyw-sprinkle-0.2.3 spec/sprinkle/installers/push_text_spec.rb
jemmyw-sprinkle-0.2.4 spec/sprinkle/installers/push_text_spec.rb
justsee-sprinkle-0.2.4 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.1 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.10 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.11 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.13 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.14 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.2 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.3 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.4 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.5 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.6 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.7 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.8 spec/sprinkle/installers/push_text_spec.rb
lachlan-sprinkle-0.0.9 spec/sprinkle/installers/push_text_spec.rb
mdwan-sprinkle-0.2.2 spec/sprinkle/installers/push_text_spec.rb
mdwan-sprinkle-0.2.3 spec/sprinkle/installers/push_text_spec.rb