Sha256: a8191e3a2da9fcf557558361bc8edea16b1e68e556cd4d757225e86e4c0d4e2f

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe WhippedCream::Deployer do
  subject { deployer }
  let(:deployer) { described_class.new(plugin_filename, pi_address) }

  let(:plugin_filename) { 'demo.rb' }
  let(:pi_address) { '192.168.0.123' }

  let(:net_ssh_double) {
    double(Net::SSH, exec!: nil, open_channel: double(wait: nil))
  }

  before do
    deployer.stub :scp_copy
    deployer.stub :ssh_exec
  end

  its(:plugin_filename) { should eq(plugin_filename) }
  its(:pi_address) { should eq(pi_address) }

  context "with a port" do
    let(:pi_address) { "192.168.0.123:2222" }

    it "adds a port to the connection arguments" do
      expect(deployer.connection_arguments.last[:port]).to eq("2222")
    end
  end

  describe "#scp" do
    it "tries to connect with pi:raspberry" do
      expect(Net::SCP).to receive(:start).with(
        pi_address, 'pi', password: 'raspberry'
      )

      deployer.scp
    end
  end

  describe "#ssh" do
    it "tries to connect with pi:raspberry" do
      expect(Net::SSH).to receive(:start).with(
        pi_address, 'pi', password: 'raspberry'
      )

      deployer.ssh
    end
  end

  describe "#deploy" do
    subject(:deploy) { deployer.deploy }

    it "bootstraps the Pi" do
      expect(deployer).to receive(:bootstrap)
      expect(deployer).to receive(:copy_plugin)
      expect(deployer).to receive(:kill_all_plugins)
      expect(deployer).to receive(:run_plugin)

      deploy
    end

    # xit "prompts the user for a password on failure"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
whipped-cream-0.2.0.beta1 spec/lib/whipped-cream/deployer_spec.rb
whipped-cream-0.1.1 spec/lib/whipped-cream/deployer_spec.rb
whipped-cream-0.1.0 spec/lib/whipped-cream/deployer_spec.rb