Sha256: c7e52ccda4bb6dabc8048cd73498ea07c4ea964b253cd6a18f96c216d28f31a0

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe 'wrappers' do
  after :each do
    JenkinsPipelineBuilder.registry.clear_versions
  end

  before :all do
    JenkinsPipelineBuilder.credentials = {
      server_ip: '127.0.0.1',
      server_port: 8080,
      username: 'username',
      password: 'password',
      log_location: '/dev/null'
    }
  end

  before :each do
    builder = Nokogiri::XML::Builder.new { |xml| xml.buildWrappers }
    @n_xml = builder.doc
  end

  after :each do |example|
    name = example.description.gsub ' ', '_'
    File.open("./out/xml/wrapper_#{name}.xml", 'w') { |f| @n_xml.write_xml_to f }
  end

  context 'ansicolor' do
    before :each do
      JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:ansicolor].installed_version = '0.0'
    end

    it 'generates correct xml' do
      JenkinsPipelineBuilder.registry.traverse_registry_path('job', { wrappers: { ansicolor: true } }, @n_xml)

      node = @n_xml.root.xpath('//buildWrappers/hudson.plugins.ansicolor.AnsiColorBuildWrapper')
      expect(node.first).to be_truthy
      expect(node.first.content).to eq 'xterm'
    end

    it 'fails parameters are passed' do
      params = { wrappers: { ansicolor: { config: false } } }
      expect do
        JenkinsPipelineBuilder.registry.traverse_registry_path('job', params, @n_xml)
      end.to raise_error
    end
  end

  context 'timestamp' do
    before :each do
      JenkinsPipelineBuilder.registry.registry[:job][:wrappers][:timestamp].installed_version = '0.0'
    end

    it 'generates correct xml' do
      JenkinsPipelineBuilder.registry.traverse_registry_path('job', { wrappers: { timestamp: true } }, @n_xml)

      node = @n_xml.root.xpath('//buildWrappers/hudson.plugins.timestamper.TimestamperBuildWrapper')
      expect(node.first).to_not be_nil
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jenkins_pipeline_builder-0.8.2 spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
jenkins_pipeline_builder-0.8.1 spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb
jenkins_pipeline_builder-0.8.0 spec/lib/jenkins_pipeline_builder/extensions/wrappers_spec.rb