Sha256: e7034d2330c934cc07479ab730c59e14864345f0c66852c0179fdfdd75f72587

Contents?: true

Size: 1.04 KB

Versions: 36

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

require 'puppet/util/tag_set'

RSpec::Matchers.define :be_one_of do |*expected|
  match do |actual|
    expected.include? actual
  end

  failure_message do |actual|
    "expected #{actual.inspect} to be one of #{expected.map(&:inspect).join(' or ')}"
  end
end

describe Puppet::Util::TagSet do
  let(:set) { Puppet::Util::TagSet.new }

  it 'serializes to yaml as an array' do
    array = ['a', :b, 1, 5.4]
    set.merge(array)

    expect(Set.new(YAML.load(set.to_yaml))).to eq(Set.new(array))
  end

  it 'deserializes from a yaml array' do
    array = ['a', :b, 1, 5.4]

    expect(Puppet::Util::TagSet.from_yaml(array.to_yaml)).to eq(Puppet::Util::TagSet.new(array))
  end

  it 'round trips through json' do
    array = ['a', 'b', 1, 5.4]
    set.merge(array)

    tes = Puppet::Util::TagSet.from_data_hash(JSON.parse(set.to_json))
    expect(tes).to eq(set)
  end

  it 'can join its elements with a string separator' do
    array = ['a', 'b']
    set.merge(array)

    expect(set.join(', ')).to be_one_of('a, b', 'b, a')
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/util/tag_set_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.22-universal-darwin spec/unit/util/tag_set_spec.rb
puppet-5.5.21 spec/unit/util/tag_set_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.21-universal-darwin spec/unit/util/tag_set_spec.rb
puppet-5.5.20 spec/unit/util/tag_set_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.20-universal-darwin spec/unit/util/tag_set_spec.rb
puppet-5.5.19 spec/unit/util/tag_set_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.19-universal-darwin spec/unit/util/tag_set_spec.rb
puppet-5.5.18 spec/unit/util/tag_set_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/util/tag_set_spec.rb
puppet-5.5.18-universal-darwin spec/unit/util/tag_set_spec.rb