Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/net/dns/rr/classes_spec.rb
Views: 11789
# -*- coding:binary -*-1require 'spec_helper'23require 'net/dns'45RSpec.describe Net::DNS::RR::Classes do67subject do8described_class.new9end1011describe '#initialize' do12subject(:rr_class) do13described_class.allocate14end1516it 'raises when initialized with no args' do17expect { rr_class.send(:initialize) }.to raise_error(ArgumentError)18end1920it 'respects default RR class when initialized with a nil RR class' do21rr_class.send(:initialize, nil)22expect(rr_class.to_i).to eql(1)23expect(rr_class.to_s).to eql('IN')24end2526# TODO: figure out why this doesn't work27skip 'respects configured default RR class' do28rr_class.send(:default=, 'NONE')29expect(rr_class.to_i).to eql(254)30expect(rr_class.to_s).to eql('NONE')31end3233it 'initializes with a valid RR class Integer argument' do34rr_class.send(:initialize, 4)35expect(rr_class.to_i).to eql(4)36expect(rr_class.to_s).to eql('HS')37end3839it 'raises when the supplied RR class Integer is invalid' do40expect { rr_class.send(:initialize, 123456) }.to raise_error(ClassArgumentError)41expect { rr_class.send(:initialize, -1) }.to raise_error(ClassArgumentError)42end4344it 'initializes with a valid RR class String argument' do45rr_class.send(:initialize, 'CH')46expect(rr_class.to_i).to eql(3)47expect(rr_class.to_s).to eql('CH')48rr_class.send(:initialize, 'CLASS9')49expect(rr_class.to_i).to eql(9)50expect(rr_class.to_s).to eql('CLASS9')51rr_class.send(:initialize, 'CLASS1')52expect(rr_class.to_i).to eql(1)53expect(rr_class.to_s).to eql('IN')54end5556it 'raises when the supplied RR class String is invalid' do57expect { rr_class.send(:initialize, 'cats') }.to raise_error(ClassArgumentError)58expect { rr_class.send(:initialize, 'CLASS123456') }.to raise_error(ClassArgumentError)59end60end61end626364