Sha256: 55e724e67c599d105e81a06df9d3d42eaa6fe81624e0dfa224c704c09318ee30

Contents?: true

Size: 1.41 KB

Versions: 34

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'ostruct'
require 'puppet/util/network_device'

describe Puppet::Util::NetworkDevice do

  before(:each) do
    @device = OpenStruct.new(:name => "name", :provider => "test")
  end

  after(:each) do
    Puppet::Util::NetworkDevice.teardown
  end

  class Puppet::Util::NetworkDevice::Test
    class Device
      def initialize(device)
      end
    end
  end

  describe "when initializing the remote network device singleton" do
    it "should load the network device code" do
      Puppet::Util::NetworkDevice.expects(:require)
      Puppet::Util::NetworkDevice.init(@device)
    end

    it "should create a network device instance" do
      Puppet::Util::NetworkDevice.stubs(:require)
      Puppet::Util::NetworkDevice::Test::Device.expects(:new)
      Puppet::Util::NetworkDevice.init(@device)
    end

    it "should raise an error if the remote device instance can't be created" do
      Puppet::Util::NetworkDevice.stubs(:require).raises("error")
      lambda { Puppet::Util::NetworkDevice.init(@device) }.should raise_error
    end

    it "should let caller to access the singleton device" do
      device = stub 'device'
      Puppet::Util::NetworkDevice.stubs(:require)
      Puppet::Util::NetworkDevice::Test::Device.expects(:new).returns(device)
      Puppet::Util::NetworkDevice.init(@device)

      Puppet::Util::NetworkDevice.current.should == device
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/util/network_device_spec.rb
puppet-2.7.25 spec/unit/util/network_device_spec.rb
puppet-2.7.24 spec/unit/util/network_device_spec.rb
puppet-2.7.23 spec/unit/util/network_device_spec.rb
puppet-2.7.22 spec/unit/util/network_device_spec.rb
puppet-2.7.21 spec/unit/util/network_device_spec.rb
puppet-2.7.20 spec/unit/util/network_device_spec.rb
puppet-2.7.20.rc1 spec/unit/util/network_device_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/network_device_spec.rb
puppet-2.7.19 spec/unit/util/network_device_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/network_device_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/network_device_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/network_device_spec.rb
puppet-2.7.18 spec/unit/util/network_device_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/network_device_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/network_device_spec.rb
puppet-2.7.17 spec/unit/util/network_device_spec.rb
puppet-2.7.16 spec/unit/util/network_device_spec.rb
puppet-2.7.14 spec/unit/util/network_device_spec.rb
puppet-2.7.13 spec/unit/util/network_device_spec.rb