Sha256: f001dd284d597219351e4e27eaf8b1ff4c3c4717973d39d4f4b60d962ca6eaf5

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe BackupJenkins::CLI do
  let(:aws) { stub }
  let(:backup) { stub }
  let(:config) { stub }

  before do
    BackupJenkins::AWS.stub(:new).and_return(aws)
    BackupJenkins::Backup.stub(:new).and_return(backup)
    BackupJenkins::Config.stub(:new).and_return(config)

    File.stub(:open).and_return(:IO)

    backup.stub(:do_backup)
    backup.stub(:tarball_filename).and_return("tarball_filename")

    aws.stub(:upload_file)
    aws.stub(:remove_old_files)
  end

  describe ".run" do
    after { BackupJenkins::CLI.run }
    it { BackupJenkins::CLI.any_instance.should_receive(:run) }
  end

  describe "#run" do
    after { subject.run }
    it { BackupJenkins::AWS.should_receive(:new).with(config) }
    it { BackupJenkins::Backup.should_receive(:new).with(config) }
    it { BackupJenkins::Config.should_receive(:new) }
    it { backup.should_receive(:do_backup) }
    it { backup.should_receive(:tarball_filename).and_return("tarball_filename") }
    it { aws.should_receive(:upload_file).with("tarball_filename", :IO) }
    it { aws.should_receive(:remove_old_files) }
  end

  describe "#longest_width" do
    before { subject.stub(:options_possible).and_return([%w(1234), %w(1234567890), %w(123)]) }
    it { subject.send(:longest_width).should == 10 }
  end

  describe "#expand_option" do
    it {
      subject.send(:expand_option, ['--this-option', '-t', 0, 'This is my explanation']).should(
        eq "    --this-option, -t  This is my explanation"
      )
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backup_jenkins-0.0.7 spec/lib/backup_jenkins/cli_spec.rb