Sha256: 2ae3bd2f29d0c75601a440632c2d81f8b7983bf3412afb5d21ec93380446f4e4

Contents?: true

Size: 918 Bytes

Versions: 4

Compression:

Stored size: 918 Bytes

Contents

require 'test_helper'
require 'tempfile'

module Pups
  class ConfigTest < MiniTest::Test

    def test_config_from_env
      ENV["HELLO"] = "world"
      config = Config.new({})
      assert_equal("world", config.params["$ENV_HELLO"])
    end

    def test_integration

      f = Tempfile.new("test")
      f.close

      config = <<YAML
params:
  run: #{f.path}
run:
  - exec: echo hello world >> #{f.path}
YAML

      Config.new(YAML.load(config)).run
      assert_equal("hello world", File.read(f.path).strip)

    ensure
      f.unlink
    end

    def test_hooks
      yaml = <<YAML
run:
  - exec: 1
  - exec:
      hook: middle
      cmd: 2
  - exec: 3
hooks:
  after_middle:
    - exec: 2.1
  before_middle:
    - exec: 1.9
YAML

      config = Config.load_config(yaml).config
      assert_equal({ "exec" => 1.9 }, config["run"][1])
      assert_equal({ "exec" => 2.1 }, config["run"][3])


    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pups-1.0.3 test/config_test.rb
pups-1.0.2 test/config_test.rb
pups-1.0.1 test/config_test.rb
pups-1.0.0 test/config_test.rb