Sha256: 7eb5ef3d16625b50861b1ed3f34b0d8285bcd79b0d054d33ccd3c70848ba4c4f

Contents?: true

Size: 1.89 KB

Versions: 28

Compression:

Stored size: 1.89 KB

Contents

# -*- encoding: utf-8 -*-
#
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
#
# Copyright (C) 2014, Fletcher Nichol
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "../spec_helper"

require "kitchen/login_command"

describe Kitchen::LoginCommand do

  let(:cmd)   { "" }
  let(:argv)  { Array.new }
  let(:opts)  { Hash.new }

  let(:login_command) { Kitchen::LoginCommand.new(cmd, argv, opts) }

  it "#command returns the command" do
    cmd << "one"

    login_command.command.must_equal "one"
  end

  it "#arguments defaults to an empty array" do
    Kitchen::LoginCommand.new("echo", nil).arguments.must_equal []
  end

  it "#arguments returns the command arguments" do
    argv.concat(["-o", "two"])

    login_command.arguments.must_equal ["-o", "two"]
  end

  it "#options defaults to an empty hash" do
    Kitchen::LoginCommand.new(cmd, argv, nil).options.must_equal {}
  end

  it "#options returns the options hash from the constructor" do
    opts[:cake] = "yummy"

    login_command.options.must_equal(:cake => "yummy")
  end

  it "#exec_args returns an array of arguments for Kernel.exec" do
    cmd << "alpha"
    login_command.exec_args.must_equal ["alpha", {}]

    argv.concat(["-o", "beta"])
    login_command.exec_args.must_equal ["alpha", "-o", "beta", {}]

    opts[:charlie] = "delta"
    login_command.exec_args.must_equal [
      "alpha", "-o", "beta", { :charlie => "delta" }]
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
test-kitchen-1.14.1 spec/kitchen/login_command_spec.rb
test-kitchen-1.14.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.13.2 spec/kitchen/login_command_spec.rb
test-kitchen-1.13.1 spec/kitchen/login_command_spec.rb
test-kitchen-1.13.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.12.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.11.1 spec/kitchen/login_command_spec.rb
test-kitchen-1.11.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.10.2 spec/kitchen/login_command_spec.rb
test-kitchen-1.10.2.dev spec/kitchen/login_command_spec.rb
test-kitchen-1.10.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.9.2 spec/kitchen/login_command_spec.rb
test-kitchen-1.9.1 spec/kitchen/login_command_spec.rb
test-kitchen-1.9.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.8.0 spec/kitchen/login_command_spec.rb
test-kitchen-1.7.3 spec/kitchen/login_command_spec.rb
test-kitchen-1.7.2 spec/kitchen/login_command_spec.rb
test-kitchen-1.7.1 spec/kitchen/login_command_spec.rb
test-kitchen-1.7.1.dev spec/kitchen/login_command_spec.rb
test-kitchen-1.6.0 spec/kitchen/login_command_spec.rb