Sha256: 573f97f67f0076dd1546a1d2e71a78389a2d66397a43942c155c8443d914678d

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 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

2 entries across 2 versions & 1 rubygems

Version Path
snmpjr-0.1.5-java spec/snmpjr/response_spec.rb
snmpjr-0.1.4-java spec/snmpjr/response_spec.rb