Sha256: d5f43481dc3707125d114783cc0a7f4a0254e30d0223e4abc38594340203c3c3

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require production_code

describe Snmpjr::Response do

  describe '.new' do
    context 'when initialized with a value' do
      it 'assigns that value' do
        response = described_class.new(value: 'Some value')
        expect(response.to_s).to eq 'Some value'
      end

      it 'sets the error to an empty string' do
        response = described_class.new(value: 'Some value')
        expect(response.error).to eq ''
      end
    end

    context 'when initialized with an error' do
      it 'assigns that error' do
        response = described_class.new(error: 'Some error')
        expect(response.error).to eq 'Some error'
      end

      it 'sets the value to an empty string' do
        response = described_class.new(error: 'Some error')
        expect(response.to_s).to eq ''
      end
    end
  end

  describe '#error?' do
    it 'returns true if there is an error' do
      response = described_class.new(error: 'Some error')
      expect(response.error?).to be_truthy
    end

    it 'returns false if there isnt an error' do
      response = described_class.new(value: 'Some value')
      expect(response.error?).to be_falsey
    end
  end

  describe '#==' do
    context 'when the objects are equal' do
      let(:other) { Snmpjr::Response.new(value: 'some value') }
      it 'returns true' do
        expect(described_class.new(value: 'some value')).to eq other
      end
    end

    context 'when the objects are not equal' do
      let(:other) { Snmpjr::Response.new(error: 'some value') }
      it 'returns true' do
        expect(described_class.new(error: 'some error')).to_not eq other
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
snmpjr-0.2.1-java spec/snmpjr/response_spec.rb
snmpjr-0.2.0-java spec/snmpjr/response_spec.rb
snmpjr-0.1.7-java spec/snmpjr/response_spec.rb