<commit_before>require File.dirname(__FILE__) + '/../../spec_helper'

describe Sprinkle::Installers::Transfer do
  include Sprinkle::Deployment

  before do
    @package = mock(Sprinkle::Package, :name => 'package')
    @empty = Proc.new { }
    @delivery = mock(Sprinkle::Deployment, :process => true)
		@source = 'source'
		@destination = 'destination'
    @installer = create_transfer(@source, @destination)
    @roles = []
    @deployment = deployment do
      delivery :capistrano
      installer do; prefix '/usr/bin'; end
    end
  end
  
  def create_transfer(source, dest, options={}, &block)
    i = Sprinkle::Installers::Transfer.new(@package, source, dest, options, &block)
    i.delivery = @delivery
		i
  end
  
  describe 'when created' do
    it 'should accept a single package to install' do
      @installer.source.should == @source
      @installer.destination.should == @destination
    end
  end
  
  describe 'during installation' do
    before do
      @installer = create_transfer @source, @destination do
        pre :install, 'op1'
        post :install, 'op2'
      end
    end

		it "should call the pre and post install commands around the file transfer" do
			delivery = @installer.delivery
			
			delivery.should_receive(:process).with(@package.name, 'op1', @roles).once.ordered.and_return
      delivery.should_receive(:transfer).with(@package.name, @source, @destination, @roles).ordered.and_return
			delivery.should_receive(:process).with(@package.name, 'op2', @roles).once.ordered.and_return
		end		
  
		after do
      @installer.process @roles
    end
  end
end<commit_msg>Still need to write tests for ERB mode<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'

describe Sprinkle::Installers::Transfer do
  include Sprinkle::Deployment

  before do
    @package = mock(Sprinkle::Package, :name => 'package')
    @empty = Proc.new { }
    @delivery = mock(Sprinkle::Deployment, :process => true)
		@source = 'source'
		@destination = 'destination'
    @installer = create_transfer(@source, @destination)
    @roles = []
    @deployment = deployment do
      delivery :capistrano
      installer do; prefix '/usr/bin'; end
    end
  end
  
  def create_transfer(source, dest, options={}, &block)
    i = Sprinkle::Installers::Transfer.new(@package, source, dest, options, &block)
    i.delivery = @delivery
		i
  end
  
  describe 'when created' do
    it 'should accept a source and destination to install' do
      @installer.source.should == @source
      @installer.destination.should == @destination
    end
  end
  
  describe 'during installation' do
    before do
      @installer = create_transfer @source, @destination do
        pre :install, 'op1'
        post :install, 'op2'
      end
    end

		it "should call the pre and post install commands around the file transfer" do
			delivery = @installer.delivery
			
			delivery.should_receive(:process).with(@package.name, 'op1', @roles).once.ordered.and_return
      delivery.should_receive(:transfer).with(@package.name, @source, @destination, @roles).ordered.and_return
			delivery.should_receive(:process).with(@package.name, 'op2', @roles).once.ordered.and_return
		end		
  
		after do
      @installer.process @roles
    end
  end

	describe "if the :render flag is true" do
		it "should render the source file as a template to a tempfile"
		it "should call transfer with recursive set to false"
	end
	
	describe "if the :recursive flag is explicitly set to false" do
		it "should call transfer with recursive set to false"
	end
end
{'fraction_non_alphanumeric': 0.11201801294680552, 'fraction_numerical': 0.002251618350689558, 'mean_word_length': 3.4592220828105393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6528460', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1062, 'n_words': 312}