Sha256: 83f0281ab99c838e6de4b5a550f59f0695c150bc422016a0442b6b848e9fd842

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require production_code

describe Snmpjr::Target do

  describe "#create" do
    let(:options) { { :host => '127.0.0.1', :port => 161, :community => 'some_community' } }

    it "creates an octet string for the community string" do
      expect(Snmpjr::Wrappers::SMI::OctetString).to receive(:new).with(options[:community])
      subject.create(options)
    end

    it "creates an smi address based on the ip and port name" do
      expect(Snmpjr::Wrappers::SMI::GenericAddress).to receive(:parse).with("udp:127.0.0.1/161")
      subject.create(options)
    end

    let(:community_target) { double Snmpjr::Wrappers::CommunityTarget }

    before do
      allow(Snmpjr::Wrappers::CommunityTarget).to receive(:new).and_return community_target
      allow(community_target).to receive(:version=)
      allow(community_target).to receive(:timeout=)
      allow(community_target).to receive(:community=)
      allow(community_target).to receive(:address=)
    end

    it "sets the snmp version to v2c and the timeout to 5000ms" do
      expect(community_target).to receive(:version=).with(1)
      expect(community_target).to receive(:timeout=).with(5000)
      subject.create(options)
    end

    it "returns the SNMP4J community target" do
      expect(subject.create(options).class).to eq community_target.class
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
snmpjr-0.1.4-java spec/snmpjr/target_spec.rb
snmpjr-0.1.2-java spec/snmpjr/target_spec.rb
snmpjr-0.1.3-java spec/snmpjr/target_spec.rb
snmpjr-0.1.0-java spec/snmpjr/target_spec.rb