|
4 | 4 |
|
5 | 5 | describe Puppet::Type.type(:host) do |
6 | 6 | let(:provider) { FakeHostProvider.new } |
7 | | - let(:resource) { instance_double('Puppet::Type::Host', provider: provider) } |
| 7 | + let(:resource) { instance_double('Puppet::Type::Host', provider:) } |
8 | 8 |
|
9 | 9 | it 'has :name be its namevar' do |
10 | 10 | expect(described_class.key_attributes).to eq([:name]) |
|
257 | 257 | '::0:a:b:c:d:e:f', # syntactically correct, but bad form (::0:... could be combined) |
258 | 258 | 'a:b:c:d:e:f:0::'].each do |ip| |
259 | 259 | it "accepts #{ip.inspect} as an IPv6 address" do |
260 | | - expect { described_class.new(name: 'foo', ip: ip) }.not_to raise_error |
| 260 | + expect { described_class.new(name: 'foo', ip:) }.not_to raise_error |
261 | 261 | end |
262 | 262 | end |
263 | 263 |
|
|
588 | 588 | '::3333:4444:5555:6666:7777:8888:', |
589 | 589 | '::2222:3333:4444:5555:6666:7777:8888:'].each do |ip| |
590 | 590 | it "rejects #{ip.inspect} as an IPv6 address" do |
591 | | - expect { described_class.new(name: 'foo', ip: ip) }.to raise_error(Puppet::ResourceError, %r{Parameter ip failed}) |
| 591 | + expect { described_class.new(name: 'foo', ip:) }.to raise_error(Puppet::ResourceError, %r{Parameter ip failed}) |
592 | 592 | end |
593 | 593 | end |
594 | 594 |
|
|
623 | 623 |
|
624 | 624 | describe 'when syncing' do |
625 | 625 | it 'sends the first value to the provider for ip property' do |
626 | | - ip = described_class.attrclass(:ip).new(resource: resource, should: ['192.168.0.1', '192.168.0.2']) |
| 626 | + ip = described_class.attrclass(:ip).new(resource:, should: ['192.168.0.1', '192.168.0.2']) |
627 | 627 | ip.sync |
628 | 628 |
|
629 | 629 | expect(provider.ip).to eq('192.168.0.1') |
630 | 630 | end |
631 | 631 |
|
632 | 632 | it 'sends the first value to the provider for comment property' do |
633 | | - comment = described_class.attrclass(:comment).new(resource: resource, should: ['Bazinga', 'Notme']) |
| 633 | + comment = described_class.attrclass(:comment).new(resource:, should: ['Bazinga', 'Notme']) |
634 | 634 | comment.sync |
635 | 635 |
|
636 | 636 | expect(provider.comment).to eq('Bazinga') |
637 | 637 | end |
638 | 638 |
|
639 | 639 | it 'sends the joined array to the provider for host_alias' do |
640 | | - host_aliases = described_class.attrclass(:host_aliases).new(resource: resource, should: ['foo', 'bar']) |
| 640 | + host_aliases = described_class.attrclass(:host_aliases).new(resource:, should: ['foo', 'bar']) |
641 | 641 | host_aliases.sync |
642 | 642 |
|
643 | 643 | expect(provider.host_aliases).to eq('foo bar') |
644 | 644 | end |
645 | 645 |
|
646 | 646 | it 'alsoes use the specified delimiter for joining' do |
647 | | - host_aliases = described_class.attrclass(:host_aliases).new(resource: resource, should: ['foo', 'bar']) |
| 647 | + host_aliases = described_class.attrclass(:host_aliases).new(resource:, should: ['foo', 'bar']) |
648 | 648 | allow(host_aliases).to receive(:delimiter).and_return "\t" |
649 | 649 | host_aliases.sync |
650 | 650 |
|
651 | 651 | expect(provider.host_aliases).to eq("foo\tbar") |
652 | 652 | end |
653 | 653 |
|
654 | 654 | it 'cares about the order of host_aliases' do |
655 | | - host_aliases = described_class.attrclass(:host_aliases).new(resource: resource, should: ['foo', 'bar']) |
| 655 | + host_aliases = described_class.attrclass(:host_aliases).new(resource:, should: ['foo', 'bar']) |
656 | 656 | expect(host_aliases.insync?(['foo', 'bar'])).to eq(true) |
657 | 657 | expect(host_aliases.insync?(['bar', 'foo'])).to eq(false) |
658 | 658 | end |
659 | 659 |
|
660 | 660 | it 'does not consider aliases to be in sync if should is a subset of current' do |
661 | | - host_aliases = described_class.attrclass(:host_aliases).new(resource: resource, should: ['foo', 'bar']) |
| 661 | + host_aliases = described_class.attrclass(:host_aliases).new(resource:, should: ['foo', 'bar']) |
662 | 662 | expect(host_aliases.insync?(['foo', 'bar', 'anotherone'])).to eq(false) |
663 | 663 | end |
664 | 664 | end |
|
0 commit comments