Sha256: 3c57957f67d9eca50f9abec8ba6aff7ebfe76720799fb4f12f6f34b2a2e88e8f

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

require 'heirloom/cli/shared'

describe Heirloom do
  before do 
    @logger_mock = mock 'logger'
  end

  it "should return false if a required array is emtpy" do
    @logger_mock.should_receive(:error)
    Heirloom::CLI::Shared.valid_options?(:provided => { :array  => [],
                                                        :string => 'present' },
                                         :required => [:array, :string],
                                         :logger   => @logger_mock).
                          should be_false
  end

  it "should return false if a required string is nil" do
    @logger_mock.should_receive(:error)
    Heirloom::CLI::Shared.valid_options?(:provided => { :array  => ['present'],
                                                        :string => nil },
                                         :required => [:array, :string],
                                         :logger   => @logger_mock).
                          should be_false
  end

  it "shoudl return false if a require string is nil & array is empty" do
    @logger_mock.should_receive(:error).exactly(2).times
    Heirloom::CLI::Shared.valid_options?(:provided => { :array  => [],
                                                        :string => nil },
                                         :required => [:array, :string],
                                         :logger   => @logger_mock).
                          should be_false
  end

  it "shoudl return true if all options are present" do
    @logger_mock.should_receive(:error).exactly(0).times
    Heirloom::CLI::Shared.valid_options?(:provided => { :array  => ['present'],
                                                        :string => 'present' },
                                         :required => [:array, :string],
                                         :logger   => @logger_mock).
                          should be_true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.3.1 spec/cli/shared_spec.rb
heirloom-0.3.0 spec/cli/shared_spec.rb
heirloom-0.3.0.rc1 spec/cli/shared_spec.rb