diff --git a/.rspec b/.rspec index c895322c..333d91ee 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,3 @@ --format documentation --color ---order rand:123 \ No newline at end of file +--order rand diff --git a/spec/puppet/resource_api/type_definition_spec.rb b/spec/puppet/resource_api/type_definition_spec.rb index 592f02ea..adc4f9f1 100644 --- a/spec/puppet/resource_api/type_definition_spec.rb +++ b/spec/puppet/resource_api/type_definition_spec.rb @@ -119,6 +119,10 @@ Puppet.settings[:strict] = strict_level end + after(:each) do + Puppet::ResourceApi.warning_count = 0 + end + context 'when puppet strict is set to default (warning)' do it 'displays up to 100 warnings' do expect(Puppet).to receive(:warning).with(message).exactly(100).times @@ -156,6 +160,10 @@ Puppet.settings[:strict] = strict_level end + after(:each) do + Puppet::ResourceApi.warning_count = 0 + end + context 'when puppet strict is set to default (warning)' do it 'displays up to 100 warnings' do expect(Puppet).to receive(:warning).with(message).exactly(100).times diff --git a/spec/puppet/resource_api_spec.rb b/spec/puppet/resource_api_spec.rb index 29446642..36a1fa39 100644 --- a/spec/puppet/resource_api_spec.rb +++ b/spec/puppet/resource_api_spec.rb @@ -1814,22 +1814,29 @@ def set(_context, changes) end allow(provider_class).to receive(:new).and_return(provider) end + after(:each) do + # reset cached provider between tests + type.instance_variable_set(:@my_provider, nil) + end + it { expect { described_class.register_type(definition) }.not_to raise_error } - it 'is seen as a supported feature' do - expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter}) - expect { described_class.register_type(definition) }.not_to raise_error - end + context 'with the type registered' do + it 'is seen as a supported feature' do + expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter}) + expect { described_class.register_type(definition) }.not_to raise_error + end - it 'passes through the an empty array to `get`' do - expect(provider).to receive(:get).with(anything, []).and_return([]) - type.instances - end + it 'passes through the an empty array to `get`' do + expect(provider).to receive(:get).with(anything, []).and_return([]) + type.instances + end - it 'passes through the resource title to `get`' do - instance = type.new(name: 'bar', ensure: 'present') - expect(provider).to receive(:get).with(anything, ['bar']).and_return([]) - instance.retrieve + it 'passes through the resource title to `get`' do + instance = type.new(name: 'bar', ensure: 'present') + expect(provider).to receive(:get).with(anything, ['bar']).and_return([]) + instance.retrieve + end end end