Sha256: 31208d1da6704652a1f39ff5a62e7735165fd5f5a9e9fdd245b439c0e19e1b10

Contents?: true

Size: 1.55 KB

Versions: 79

Compression:

Stored size: 1.55 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", :url => "telnet://admin:password@127.0.0.1", :options => { :debug => false })
  end

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

  class Puppet::Util::NetworkDevice::Test
    class Device
      def initialize(device, options)
      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).with("telnet://admin:password@127.0.0.1", :debug => false)
      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

79 entries across 79 versions & 1 rubygems

Version Path
puppet-3.6.2-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.6.1 spec/unit/util/network_device_spec.rb
puppet-3.6.1-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.6.0 spec/unit/util/network_device_spec.rb
puppet-3.6.0-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.6.0.rc1 spec/unit/util/network_device_spec.rb
puppet-3.6.0.rc1-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.5.1 spec/unit/util/network_device_spec.rb
puppet-3.5.1-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.5.1.rc1 spec/unit/util/network_device_spec.rb
puppet-3.5.1.rc1-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc3 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc3-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc2 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc2-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc1 spec/unit/util/network_device_spec.rb
puppet-3.5.0.rc1-x86-mingw32 spec/unit/util/network_device_spec.rb
puppet-3.4.3 spec/unit/util/network_device_spec.rb
puppet-3.4.2 spec/unit/util/network_device_spec.rb
puppet-3.4.1 spec/unit/util/network_device_spec.rb