On Sat, May 07, 2011 at 06:47:30PM +0200, Brice Figureau wrote:
> We were leaking some mocks in the network device singleton from
> tests to tests.
> 
> Signed-off-by: Brice Figureau <[email protected]>
> ---
>  lib/puppet/util/network_device.rb     |    5 +++++
>  spec/unit/util/network_device_spec.rb |    4 ++++
>  2 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/puppet/util/network_device.rb 
> b/lib/puppet/util/network_device.rb
> index d9c1aa3..a650670 100644
> --- a/lib/puppet/util/network_device.rb
> +++ b/lib/puppet/util/network_device.rb
> @@ -9,4 +9,9 @@ class Puppet::Util::NetworkDevice
>    rescue => detail
>      raise "Can't load #{device.provider} for #{device.name}: #{detail}"
>    end
> +
> +  # for tests reset
> +  def self.clear
> +    @current = nil
> +  end
>  end
> \ No newline at end of file
> diff --git a/spec/unit/util/network_device_spec.rb 
> b/spec/unit/util/network_device_spec.rb
> index 70cb509..347986a 100644
> --- a/spec/unit/util/network_device_spec.rb
> +++ b/spec/unit/util/network_device_spec.rb
> @@ -10,6 +10,10 @@ describe Puppet::Util::NetworkDevice do
>      @device = OpenStruct.new(:name => "name", :provider => "test")
>    end
>  
> +  after(:each) do
> +    Puppet::Util::NetworkDevice.clear
> +  end
> +
>    class Puppet::Util::NetworkDevice::Test
>      class Device
>        def initialize(device)
> -- 
> 1.7.5.1
> 

+1

patch looks good (as far as I can judge) and rake spec is working again.

-Stefan

Attachment: pgpbbfof631S9.pgp
Description: PGP signature

Reply via email to