Sha256: 1e27a511e427b299c20dd3a875d110b2426d4d38d12e913e39701c87ec902952

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require_relative './test_xml_generator'

class TestXmlParameter < Test::Unit::TestCase
  def test_parameter
    builder = JenkinsJob::Builder.new

    builder.freestyle 'foo' do
      parameter 'GERRIT_BRANCH' do
        default 'master'
      end

      parameter 'SKIP_TEST' do
        default 'true'
      end
    end

    actual = builder.config_as_xml_node('foo')

    { 1 => { 'name' => 'GERRIT_BRANCH', 'defaultValue' => 'master' },
      2 => { 'name' => 'SKIP_TEST', 'defaultValue' => 'true' } }.each do |item, data|
      data.each do |k, v|
        assert_equal v, actual.xpath('./project/properties/hudson.model.ParametersDefinitionProperty/parameterDefinitions/' \
          "hudson.model.StringParameterDefinition[#{item}]/#{k}").text, "item #{item}, #{k}"
      end
    end
  end

  def test_password_parameter
    builder = JenkinsJob::Builder.new

    builder.freestyle 'foo' do
      password_parameter 'PASS' do
        default 'xyz='
      end
    end

    actual = builder.config_as_xml_node('foo')

    { 'name' => 'PASS', 'defaultValue' => 'xyz=' }.each do |k, v|
      assert_equal v, actual.xpath('./project/properties/hudson.model.ParametersDefinitionProperty/parameterDefinitions/' \
        "hudson.model.PasswordParameterDefinition/#{k}").text
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubyjobbuilderdsl-0.0.5 test/test_parameter.rb
rubyjobbuilderdsl-0.0.3 test/test_parameter.rb
rubyjobbuilderdsl-0.0.2 test/test_parameter.rb
rubyjobbuilderdsl-0.0.1 test/test_parameter.rb
rubyjobbuilderdsl-0.0.0 test/test_parameter.rb