Sha256: 50b8953568e1ba93d397829e1a3d70f6c253c1356d8a9aefc1bbb6cee35c8469

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

module Beaker
  module Options
    describe '#parse_subcommand_options' do
      let( :parser ) {Beaker::Options::SubcommandOptionsParser.parse_subcommand_options(argv)}
      let( :argv ) {[]}

      it 'returns an empty OptionsHash if not executing a subcommand' do
        expect(parser).to be_kind_of(OptionsHash)
        expect(parser).to be_empty
      end

      describe 'when the subcommand is init' do
        let( :argv ) {['init']}
        it 'returns an empty OptionsHash' do
          expect(parser).to be_kind_of(OptionsHash)
          expect(parser).to be_empty
        end
      end

      describe 'when the subcommand is not init' do
        let( :argv ) {['provision']}
        it 'checks for file existence and loads the YAML file' do
          expect(Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
          allow(YAML).to receive(:load_file).and_return({})
          expect(parser).to be_kind_of(Hash)
          expect(parser).not_to be_kind_of(OptionsHash)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
beaker-3.18.0 spec/beaker/options/subcommand_options_parser_spec.rb
beaker-3.17.0 spec/beaker/options/subcommand_options_parser_spec.rb
beaker-3.16.0 spec/beaker/options/subcommand_options_parser_spec.rb
beaker-3.15.0 spec/beaker/options/subcommand_options_parser_spec.rb
beaker-3.14.0 spec/beaker/options/subcommand_options_parser_spec.rb