Sha256: 6c3e34af0221a1f4b029b171b6bf9a9a3b7bf234d7d871005525f4d8b8d529d4

Contents?: true

Size: 1.85 KB

Versions: 34

Compression:

Stored size: 1.85 KB

Contents

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

require 'puppet/provider/vlan/cisco'

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

describe provider_class do
  before do
    @device = stub_everything 'device'
    @resource = stub("resource", :name => "200")
    @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 vlans" do
      @device.expects(:parse_vlans)
      provider_class.lookup(@device, "200")
    end

    it "should return only the given vlan" do
      @device.expects(:parse_vlans).returns({"200" => { :description => "thisone" }, "1" => { :description => "nothisone" }})
      provider_class.lookup(@device, "200").should == {:description => "thisone" }
    end

  end

  describe "when an instance is being flushed" do
    it "should call the device update_vlan method with its vlan id, current attributes, and desired attributes" do
      @instance = provider_class.new(@device, :ensure => :present, :name => "200", :description => "myvlan")
      @instance.description = "myvlan2"
      @instance.resource = @resource
      @resource.stubs(:[]).with(:name).returns("200")
      device = stub_everything 'device'
      @instance.stubs(:device).returns(device)
      device.expects(:command).yields(device)
      device.expects(:update_vlan).with(@instance.name, {:ensure => :present, :name => "200", :description => "myvlan"},
                                                   {:ensure => :present, :name => "200", :description => "myvlan2"})

      @instance.flush
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

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