Sha256: fbc65fec0ffb715a6948de8111e18dc8354e24a076947de4447c3a45176d0394

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'test_helper'

class CommandTest < ActiveSupport::TestCase
  test 'lib/snippets is added to the PATH when command is run' do
    out = Command.new('which extract-gem-version', chdir: '/tmp').run
    script_path = Shipit::Engine.root.join('lib', 'snippets', 'extract-gem-version').to_s
    assert_equal "#{script_path}\r\n", out
  end

  test "#interpolate_environment_variables replace environment variables by their value" do
    command = Command.new('cap $ENVIRONMENT deploy', env: {'ENVIRONMENT' => 'production'}, chdir: '.')
    assert_equal [%(cap production deploy)], command.interpolated_arguments
  end

  test "#interpolate_environment_variables coerce nil to empty string" do
    command = Command.new('cap $FOO deploy', env: {'ENVIRONMENT' => 'production'}, chdir: '.')
    assert_equal [%(cap '' deploy)], command.interpolated_arguments
  end

  test "#interpolate_environment_variables fallback to ENV" do
    command = Command.new('cap $LANG deploy', env: {'ENVIRONMENT' => 'production'}, chdir: '.')
    assert_equal [%(cap #{ENV['LANG']} deploy)], command.interpolated_arguments
  end

  test "#timeout is 5 minutes by default" do
    command = Command.new('cap $LANG deploy', env: {'ENVIRONMENT' => 'production'}, chdir: '.')
    assert_equal 5.minutes.to_i, command.timeout
  end

  test "#timeout returns `default_timeout` if present" do
    command = Command.new('cap $LANG deploy', default_timeout: 5, env: {}, chdir: '.')
    assert_equal 5, command.timeout
  end

  test "#timeout returnsthe command option timeout over the `default_timeout` if present" do
    command = Command.new({'cap $LANG deploy' => {'timeout' => 10}}, default_timeout: 5, env: {}, chdir: '.')
    assert_equal 10, command.timeout
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shipit-engine-0.1.0 test/unit/command_test.rb
shipit-engine-0.0.1.pre test/unit/command_test.rb