Sha256: 047d7cad5a88c4aeac56d9d1dd9e7b5698e135133706b25fb4ccbb64b3723a0a

Contents?: true

Size: 1.93 KB

Versions: 92

Compression:

Stored size: 1.93 KB

Contents

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

require 'puppet/provider/interface/cisco'

provider_class = Puppet::Type.type(:interface).provider(:cisco)

describe provider_class do
  before do
    @device = stub_everything 'device'
    @resource = stub("resource", :name => "Fa0/1")
    @provider = provider_class.new(@device, @resource)
  end

  it "should have a parent of Puppet::Provider::Cisco" do
    provider_class.should < Puppet::Provider::Cisco
  end

  it "should have an instances method" do
    provider_class.should respond_to(:instances)
  end

  describe "when looking up instances at prefetch" do
    before do
      @device.stubs(:command).yields(@device)
    end

    it "should delegate to the device interface fetcher" do
      @device.expects(:interface)
      provider_class.lookup(@device, "Fa0/1")
    end

    it "should return the given interface data" do
      @device.expects(:interface).returns({ :description => "thisone", :mode => :access})
      provider_class.lookup(@device, "Fa0").should == {:description => "thisone", :mode => :access }
    end

  end

  describe "when an instance is being flushed" do
    it "should call the device interface update method with current and past properties" do
      @instance = provider_class.new(@device, :ensure => :present, :name => "Fa0/1", :description => "myinterface")
      @instance.description = "newdesc"
      @instance.resource = @resource
      @resource.stubs(:[]).with(:name).returns("Fa0/1")
      device = stub_everything 'device'
      @instance.stubs(:device).returns(device)
      device.expects(:command).yields(device)
      interface = stub 'interface'
      device.expects(:new_interface).with("Fa0/1").returns(interface)
      interface.expects(:update).with( {:ensure => :present, :name => "Fa0/1", :description => "myinterface"},
                                       {:ensure => :present, :name => "Fa0/1", :description => "newdesc"})

      @instance.flush
    end
  end
end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.6 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.5 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.4 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.3 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.2 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.1 spec/unit/provider/interface/cisco_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/provider/interface/cisco_spec.rb