Sha256: d785e8ce619bf69796df204f71d29acff4eebb614988d71776fa4b914fc51b2a

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8

require File.expand_path('../../spec_helper.rb', __FILE__)
require 'frank/publish/scp'

describe Frank::Publish::SCP do

  let(:publisher) do
    Frank::Publish::SCP.new(Frank.publish) do |scp|
      scp.username = 'my_username'
      scp.password = 'my_password'
      scp.hostname = 'scp.example.com'
      scp.local_path = '/local/path'
      scp.remote_path = '/remote/path'
    end
  end

  before(:all) do
    Frank.bootstrap(File.join(File.dirname(__FILE__), 'template'))
  end

  describe '#initialize' do
    it 'should set the correct values' do
      publisher.username.should == 'my_username'
      publisher.password.should == 'my_password'
      publisher.hostname.should == 'scp.example.com'
      publisher.port.should == 22
      publisher.local_path.should == '/local/path'
      publisher.remote_path.should == '/remote/path'

    end

  end # describe '#initialize'

  describe '#connection' do
    let(:connection) { mock }

    it 'should yield a connection to the remote server' do
      Net::SCP.expects(:start).with('scp.example.com', 'my_username', :password => 'my_password').yields(connection)

      publisher.send(:connection) do |scp|
        scp.should be(connection)
      end
    end

  end # describe '#connection'

  describe '#transfer!' do
    let(:connection) { mock }

    before do
      publisher.stubs(:connection).yields(connection)
    end

    it 'should transfer the local_path to remote_path using upload!' do
      connection.expects(:upload!).with('/local/path', '/remote/path')

      publisher.send(:transfer!)
    end
  end # describe '#transfer!'

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frank-1.0.12 spec/publish/scp_spec.rb
frank-1.0.11 spec/publish/scp_spec.rb
frank-1.0.10 spec/publish/scp_spec.rb