Sha256: 1a210e91042f8b30c762f7f17cfe5b7afc8b682a85ca0367009880c07873a20d

Contents?: true

Size: 1.13 KB

Versions: 46

Compression:

Stored size: 1.13 KB

Contents

require_relative '../../test_helper'

describe HammerCLI::Options::Sources::CommandLine do

  before do
    @cmd = mock

    @defined_options = [
      stub(:read_method => :option_organization_id, :attribute_name => :organization_id),
      stub(:read_method => :option_location_id, :attribute_name => :location_id)
    ]

    @source = HammerCLI::Options::Sources::CommandLine.new(@cmd)
  end

  describe '#get_options' do
    it 'reads options from the command' do
      @cmd.expects(:option_organization_id).returns(2)
      @cmd.expects(:option_location_id).returns(3)

      current_result = { :help => true }
      expected_result = { :help => true, :organization_id => 2, :location_id => 3 }

      assert_equal(expected_result, @source.get_options(@defined_options, current_result))
    end

    it 'keeps options that are already set' do
      @cmd.expects(:option_location_id).returns(3)

      current_result = { :help => true, :organization_id => 1 }
      expected_result = { :help => true, :organization_id => 1, :location_id => 3 }

      assert_equal(expected_result, @source.get_options(@defined_options, current_result))
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
hammer_cli-3.13.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.12.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.10.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.9.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.8.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.7.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.5.1 test/unit/options/sources/command_line_test.rb
hammer_cli-3.6.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.5.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.4.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.3.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.2.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.1.1 test/unit/options/sources/command_line_test.rb
hammer_cli-3.0.2 test/unit/options/sources/command_line_test.rb
hammer_cli-3.1.0 test/unit/options/sources/command_line_test.rb
hammer_cli-3.0.1 test/unit/options/sources/command_line_test.rb
hammer_cli-3.0.0 test/unit/options/sources/command_line_test.rb
hammer_cli-2.5.1 test/unit/options/sources/command_line_test.rb
hammer_cli-2.5.0 test/unit/options/sources/command_line_test.rb
hammer_cli-2.3.1 test/unit/options/sources/command_line_test.rb