Skip to content

Commit

Permalink
(maint) have the #inject_device test clean up after itself
Browse files Browse the repository at this point in the history
Before the fix:
```
david@davids:~/git/puppet-resource_api$ SPEC_OPTS="--exclude-pattern spec/\{fixtures/\*\*/\*.rb,fixtures/modules/\*/\*\*/\*.rb\}" bundle exec rspec ./spec/puppet/resource_api/transport_spec.rb[1:4:2:1] ./spec/puppet/resource_api_spec.rb[1:16:2:1] --seed 40589 -fd
Run options: include {:ids=>{"./spec/puppet/resource_api/transport_spec.rb"=>["1:4:2:1"], "./spec/puppet/resource_api_spec.rb"=>["1:16:2:1"]}}

Randomized with seed 40589

Puppet::ResourceApi::Transport
  #inject_device(name, transport)
    when puppet does not have set_device
      wraps the transport and sets it as current in NetworkDevice

Puppet::ResourceApi
  #load_provider
    when loading a provider that doesn't create the correct class
      should raise Puppet::DevError with message matching /provider class Puppet::Provider::NoClass::NoClass not found/ (FAILED - 1)

Failures:

  1) Puppet::ResourceApi#load_provider when loading a provider that doesn't create the correct class should raise Puppet::DevError with message matching /provider class Puppet::Provider::NoClass::NoClass not found/
     Failure/Error: it { expect { described_class.load_provider('no_class') }.to raise_error Puppet::DevError, %r{provider class Puppet::Provider::NoClass::NoClass not found} }

       expected Puppet::DevError with message matching /provider class Puppet::Provider::NoClass::NoClass not found/, got #<Puppet::DevError: Found neither the device-specific provider class Puppet::Provider::NoClass::Mocks... the generic provider class Puppet::Provider::NoClass::NoClass in puppet/provider/no_class/no_class> with backtrace:
         # ./lib/puppet/resource_api.rb:437:in `rescue in load_provider'
         # ./lib/puppet/resource_api.rb:416:in `load_provider'
         # ./spec/puppet/resource_api_spec.rb:1202:in `block (5 levels) in <top (required)>'
         # ./spec/puppet/resource_api_spec.rb:1202:in `block (4 levels) in <top (required)>'
     # ./spec/puppet/resource_api_spec.rb:1202:in `block (4 levels) in <top (required)>'

Finished in 0.05427 seconds (files took 0.94482 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/puppet/resource_api_spec.rb:1202 # Puppet::ResourceApi#load_provider when loading a provider that doesn't create the correct class should raise Puppet::DevError with message matching /provider class Puppet::Provider::NoClass::NoClass not found/

Randomized with seed 40589

david@davids:~/git/puppet-resource_api$
```

After the fix:
```
david@davids:~/git/puppet-resource_api$ SPEC_OPTS="--exclude-pattern spec/\{fixtures/\*\*/\*.rb,fixtures/modules/\*/\*\*/\*.rb\}" bundle exec rspec ./spec/puppet/resource_api/transport_spec.rb[1:4:2:1] ./spec/puppet/resource_api_spec.rb[1:16:2:1] --seed 40589 -fd
Run options: include {:ids=>{"./spec/puppet/resource_api/transport_spec.rb"=>["1:4:2:1"], "./spec/puppet/resource_api_spec.rb"=>["1:16:2:1"]}}

Randomized with seed 40589

Puppet::ResourceApi::Transport
  #inject_device(name, transport)
    when puppet does not have set_device
      wraps the transport and sets it as current in NetworkDevice

Puppet::ResourceApi
  #load_provider
    when loading a provider that doesn't create the correct class
      should raise Puppet::DevError with message matching /provider class Puppet::Provider::NoClass::NoClass not found/

Finished in 0.03734 seconds (files took 0.95637 seconds to load)
2 examples, 0 failures

Randomized with seed 40589

david@davids:~/git/puppet-resource_api$

```
  • Loading branch information
DavidS committed Jun 13, 2019
1 parent f84be3a commit 2cd01d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/puppet/resource_api/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ class Wibble; end
end
end

after(:each) do
Puppet::Util::NetworkDevice.instance_variable_set(:@current, nil)
end

context 'when puppet has set_device' do
it 'wraps the transport and calls set_device within NetworkDevice' do
expect(Puppet::ResourceApi::Transport::Wrapper).to receive(:new).with(device_name, transport).and_return(wrapper)
Expand Down

0 comments on commit 2cd01d1

Please sign in to comment.