Sha256: 448c37b9f61eaf737b2537dede5423da313bf4793a65065395bf9dfc7987fc7e

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'
require 'heirloom/cli'

describe Heirloom do

  before do
    @options = { :name            => 'archive_name',
                 :level           => 'info',
                 :metadata_region => 'us-west-1',
                 :count           => 100 }
    @logger_double = double :debug => true
    @config_double = double_config :logger => @logger_double
    @archive_double = double 'archive'
    Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
                             and_return @logger_double
    Heirloom::CLI::List.any_instance.should_receive(:load_config).
                        with(:logger => @logger_double,
                             :opts   => @options).
                        and_return @config_double
    Heirloom::Archive.should_receive(:new).
                      with(:name => 'archive_name',
                           :config => @config_double).
                      and_return @archive_double
    Heirloom::Archive.should_receive(:new).
                      with(:name   => 'archive_name',
                           :config => @config_double).
                      and_return @archive_double
    @archive_double.should_receive(:domain_exists?).and_return true
    @archive_double.should_receive(:count)
  end

  context "as json" do
    before do
      @options[:json] = true
      Trollop.stub :options => @options
    end

    it "should list ids for given archive" do
      @cli_list = Heirloom::CLI::List.new
      @archive_double.should_receive(:list).with(100).and_return(['1','2'])
      @cli_list.should_receive(:jj).with ['1','2']
      @cli_list.list
    end
  end

  context "as human readable" do
    before do
      @options[:json] = nil
      Trollop.stub :options => @options
    end

    it "should list ids for given archive" do
      @cli_list = Heirloom::CLI::List.new
      @archive_double.should_receive(:list).with(100).and_return(['1','2'])
      @cli_list.should_receive(:puts).with "1\n2"
      @cli_list.list
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heirloom-0.12.3 spec/cli/list_spec.rb
heirloom-0.12.2 spec/cli/list_spec.rb