Sha256: 4890157b7fca5f5796ae332d5b8481a047e008ef67b4e0ca3be02349215378f8

Contents?: true

Size: 1.41 KB

Versions: 13

Compression:

Stored size: 1.41 KB

Contents

#! /usr/bin/env ruby
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

13 entries across 13 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/util/network_device_spec.rb
puppet-3.1.1 spec/unit/util/network_device_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/util/network_device_spec.rb
puppet-3.1.0 spec/unit/util/network_device_spec.rb
puppet-3.1.0.rc2 spec/unit/util/network_device_spec.rb
puppet-3.1.0.rc1 spec/unit/util/network_device_spec.rb
puppet-3.0.2 spec/unit/util/network_device_spec.rb
puppet-3.0.2.rc3 spec/unit/util/network_device_spec.rb
puppet-3.0.2.rc2 spec/unit/util/network_device_spec.rb
puppet-3.0.2.rc1 spec/unit/util/network_device_spec.rb
puppet-3.0.1 spec/unit/util/network_device_spec.rb
puppet-3.0.1.rc1 spec/unit/util/network_device_spec.rb
puppet-3.0.0 spec/unit/util/network_device_spec.rb