Sha256: 717fec9b4a0d85446abdc2d55d3f9ebafe75a9461e256b4964cd9c255f011df2

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require production_code

describe Snmpjr::Target do

  describe '#create' do
    let(:options) { { host: '127.0.0.1', port: 161, community: 'some_community', timeout: 50, retries: 2 } }

    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=)
      allow(community_target).to receive(:retries=)
    end

    it 'sets the snmp version to v2c and the timeout to 50ms' do
      expect(community_target).to receive(:version=).with(1)
      expect(community_target).to receive(:timeout=).with(50)
      expect(community_target).to receive(:retries=).with(2)
      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.2.2-java spec/snmpjr/target_spec.rb
snmpjr-0.2.1-java spec/snmpjr/target_spec.rb
snmpjr-0.2.0-java spec/snmpjr/target_spec.rb
snmpjr-0.1.7-java spec/snmpjr/target_spec.rb