diff --git a/lib/ax25/encoder/aprs_kiss.rb b/lib/ax25/encoder/aprs_kiss.rb index 76c067b2811a4d760685bc18b04f7a32179592d5..5f205669da5676fd1b89e8bb3c8ae8fd07244735 100644 --- a/lib/ax25/encoder/aprs_kiss.rb +++ b/lib/ax25/encoder/aprs_kiss.rb @@ -34,8 +34,8 @@ module Ax25 frame_map = @data_stream.read return nil if frame_map.nil? - source = Ax25::ImmutableEntity.from_raw(frame_map[:source]) - destination = Ax25::ImmutableEntity.from_raw(frame_map[:destination]) + source = Ax25::ImmutableAddress.from_raw(frame_map[:source]) + destination = Ax25::ImmutableAddress.from_raw(frame_map[:destination]) path = Ax25::ImmutablePath.from_raw(frame_map[:path]) diff --git a/lib/ax25/encoder/igate_tcp.rb b/lib/ax25/encoder/igate_tcp.rb index 96a8d9c14c4154abff5771a6e9d57495aa8bc5cf..2b60b7447be0672fccf65bf5c8c971faddd4c604 100644 --- a/lib/ax25/encoder/igate_tcp.rb +++ b/lib/ax25/encoder/igate_tcp.rb @@ -56,8 +56,8 @@ module Ax25 path = path.split(',') - decoded_source = Ax25::ImmutableEntity.from_raw(decoded_source, strict_callsign: false, strict_ssid: false) - decoded_destination = Ax25::ImmutableEntity.from_raw(path.shift, strict_callsign: false, strict_ssid: false) + decoded_source = Ax25::ImmutableAddress.from_raw(decoded_source, strict_callsign: false, strict_ssid: false) + decoded_destination = Ax25::ImmutableAddress.from_raw(path.shift, strict_callsign: false, strict_ssid: false) decoded_path = Ax25::ImmutablePath.from_raw(path, strict_callsign: false, strict_ssid: false) decoded_payload = frame_so_far diff --git a/lib/ax25/frame.rb b/lib/ax25/frame.rb index 1043b96fe844e30d7e84556eab04163a0ba308b3..2944feca97f24a90c85ddcb670cfe2c08fc331cc 100644 --- a/lib/ax25/frame.rb +++ b/lib/ax25/frame.rb @@ -1,6 +1,6 @@ require 'ax25/frame/immutable_frame' -require 'ax25/frame/entity' -require 'ax25/frame/immutable_entity' +require 'ax25/frame/address' +require 'ax25/frame/immutable_address' require 'ax25/frame/hop' require 'ax25/frame/immutable_hop' require 'ax25/frame/path' diff --git a/lib/ax25/frame/entity.rb b/lib/ax25/frame/address.rb similarity index 89% rename from lib/ax25/frame/entity.rb rename to lib/ax25/frame/address.rb index 2f86f9d1a7ff137c8df2d230d958d45173416639..48c098780c9c3149763f139750bae963843a4b99 100644 --- a/lib/ax25/frame/entity.rb +++ b/lib/ax25/frame/address.rb @@ -1,6 +1,6 @@ module Ax25 public - module Entity + module Address include Abstractify::Abstract abstract :decrement_ssid, :==, :eql?, :to_s diff --git a/lib/ax25/frame/hop.rb b/lib/ax25/frame/hop.rb index 63e7fa77778ee11dfc0b9fc9bfa988dda8b1f905..43050bad143ea2da7a012524a602b18c57516ccd 100644 --- a/lib/ax25/frame/hop.rb +++ b/lib/ax25/frame/hop.rb @@ -1,9 +1,9 @@ -require 'ax25/frame/entity' +require 'ax25/frame/address' module Ax25 public module Hop - include Ax25::Entity + include Ax25::Address include Abstractify::Abstract abstract :toggle_seen, :decrement_ssid, :==, :eql?, :to_s, :seen? diff --git a/lib/ax25/frame/immutable_entity.rb b/lib/ax25/frame/immutable_address.rb similarity index 87% rename from lib/ax25/frame/immutable_entity.rb rename to lib/ax25/frame/immutable_address.rb index e50830447714062a7467d0b5044165bfe9a8d581..8bb5ac4a5fcf5af5ae7645913a289c3ed5e9b7e2 100644 --- a/lib/ax25/frame/immutable_entity.rb +++ b/lib/ax25/frame/immutable_address.rb @@ -1,9 +1,9 @@ -require 'ax25/frame/entity' +require 'ax25/frame/address' module Ax25 public - class ImmutableEntity - include Entity + class ImmutableAddress + include Address attr_reader :callsign, :ssid @@ -48,19 +48,19 @@ module Ax25 ssid = split_hop[1].to_i end - return Ax25::ImmutableEntity.new(callsign, ssid, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + return Ax25::ImmutableAddress.new(callsign, ssid, strict_callsign: strict_callsign, strict_ssid: strict_ssid) end public def decrement_ssid raise RangeError.new("SSID can not be decremented when it is currently 0 or nil") if (self.ssid.nil?) or (self.ssid <= 0) - return Ax25::ImmutableEntity.new(self.callsign, self.ssid - 1, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableAddress.new(self.callsign, self.ssid - 1, strict_callsign: false, strict_ssid: false) end public def eql?(other) - raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Ax25::Entity + raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Ax25::Address return self == other end diff --git a/lib/ax25/frame/immutable_hop.rb b/lib/ax25/frame/immutable_hop.rb index 5bac37b74454981007f940fee9143b1d3c6114b9..cce45ec637eeb94f9a7d0864af7c499809e31fed 100644 --- a/lib/ax25/frame/immutable_hop.rb +++ b/lib/ax25/frame/immutable_hop.rb @@ -1,9 +1,9 @@ require 'ax25/frame/hop' -require 'ax25/frame/immutable_entity' +require 'ax25/frame/immutable_address' module Ax25 public - class ImmutableHop < Ax25::ImmutableEntity + class ImmutableHop < Ax25::ImmutableAddress include Hop public diff --git a/lib/ax25/frame/immutable_message.rb b/lib/ax25/frame/immutable_message.rb index 21f6018c6bd2f5559aff50d90ac72be450e6d4e9..b58b44d7def34d532a86e8804bcbf38b61c8ae69 100644 --- a/lib/ax25/frame/immutable_message.rb +++ b/lib/ax25/frame/immutable_message.rb @@ -17,10 +17,10 @@ module Ax25 # Creates a new frame, all fields are duplicated but and immutable. All # fields are validated. # - # @param source [Ax25::Entity] The source callsign for the frame. Must be a + # @param source [Ax25::Address] The source callsign for the frame. Must be a # non-null string of non-zero length with only letters, numbers and # dashes. Will be converted uppercase. - # @param destination [Ax25::Entity] The destination callsign for the frame. Must + # @param destination [Ax25::Address] The destination callsign for the frame. Must # be a non-null string of non-zero length with only letters, numbers, # and dashes. Will be converted to uppercase. # @param payload [String] The payload of the frame. Must be a non-null @@ -31,8 +31,8 @@ module Ax25 raise ArgumentError.new("destination argument can not be nil") if destination.nil? raise ArgumentError.new("payload argument can not be nil") if payload.nil? - raise ArgumentError.new("source argument must be a Entity, but found: " + source.class.to_s) if not source.kind_of? Ax25::Entity - raise ArgumentError.new("destination argument must be a Entity, but found: " + source.class.to_s) if not destination.kind_of? Ax25::Entity + raise ArgumentError.new("source argument must be a Address, but found: " + source.class.to_s) if not source.kind_of? Ax25::Address + raise ArgumentError.new("destination argument must be a Address, but found: " + source.class.to_s) if not destination.kind_of? Ax25::Address raise ArgumentError.new("payload argument must be a string, but found: " + source.class.to_s) if not payload.kind_of? String # The following both duplicate/clone the argument and convert it to uppercase diff --git a/spec/ax25/encoder/aprs_kiss_spec.rb b/spec/ax25/encoder/aprs_kiss_spec.rb index 555a970be5123ef7054aad04f4d9e8adfd22755d..6396d1bf99ed8913327ca6da782c34a7ff1219d3 100644 --- a/spec/ax25/encoder/aprs_kiss_spec.rb +++ b/spec/ax25/encoder/aprs_kiss_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../lib/ax25' FRAME_KISS = Ax25::ImmutableFrame.new( - Ax25::ImmutableEntity.from_raw('W2GMD-1'), - Ax25::ImmutableEntity.from_raw('OMG'), + Ax25::ImmutableAddress.from_raw('W2GMD-1'), + Ax25::ImmutableAddress.from_raw('OMG'), Ax25::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), 'test_encode_frame' ) diff --git a/spec/ax25/encoder/igate_tcp_spec.rb b/spec/ax25/encoder/igate_tcp_spec.rb index c9b9970173f124a3f5650b722a25c59a5ba8e610..9748f836f2caeaa6b4fd671de95bea3c94f452c3 100644 --- a/spec/ax25/encoder/igate_tcp_spec.rb +++ b/spec/ax25/encoder/igate_tcp_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../lib/ax25' DECODED_FRAME_IGATE = Ax25::ImmutableFrame.new( - Ax25::ImmutableEntity.from_raw('W2GMD-1'), - Ax25::ImmutableEntity.from_raw('OMG'), + Ax25::ImmutableAddress.from_raw('W2GMD-1'), + Ax25::ImmutableAddress.from_raw('OMG'), Ax25::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), 'test_encode_frame' ) diff --git a/spec/ax25/frame/entity_spec.rb b/spec/ax25/frame/entity_spec.rb index 0a65e158ef7ba86e5bb23670ab1bcc6f3997637a..7cede04be0f98e4776837b477ab192ad073907a3 100644 --- a/spec/ax25/frame/entity_spec.rb +++ b/spec/ax25/frame/entity_spec.rb @@ -27,7 +27,7 @@ BAD_HIGHSSID_ENTITY = "WI2ARD-16".freeze BAD_HIGHSSID_ENTITY_CALLSIGN = "WI2ARD".freeze BAD_HIGHSSID_ENTITY_SSID = 16 -class EntityEquiv +class AddressEquiv public def callsign return "WI2ARD" @@ -39,254 +39,254 @@ class EntityEquiv end end -describe Ax25::Entity do +describe Ax25::Address do describe ".new" do context "Given a valid callsign with ssid" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) - it "returns a Entity object with correct properties" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + it "returns a Address object with correct properties" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "set the callsign property correctly" do - expect(entity.callsign).to eql(BASE_ENTITY_CALLSIGN) + expect(address.callsign).to eql(BASE_ENTITY_CALLSIGN) end it "set the ssid property correctly" do - expect(entity.ssid).to eql(BASE_ENTITY_SSID) + expect(address.ssid).to eql(BASE_ENTITY_SSID) end it "callsign is frozen" do - expect(entity.callsign).to be_frozen + expect(address.callsign).to be_frozen end end context "Given a valid callsign with nil ssid" do - entity = Ax25::ImmutableEntity.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID) - it "returns a Entity object with correct properties" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID) + it "returns a Address object with correct properties" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "set the callsign property correctly" do - expect(entity.callsign).to eql(NOSSID_ENTITY_CALLSIGN) + expect(address.callsign).to eql(NOSSID_ENTITY_CALLSIGN) end it "set the ssid property correctly" do - expect(entity.ssid).to eql(NOSSID_ENTITY_SSID) + expect(address.ssid).to eql(NOSSID_ENTITY_SSID) end end context "Given a valid callsign with zero for ssid" do - entity = Ax25::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) - it "returns a Entity object with correct properties" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) + it "returns a Address object with correct properties" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "set the callsign property correctly" do - expect(entity.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) + expect(address.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) end it "set the ssid property correctly" do - expect(entity.ssid).to be_nil + expect(address.ssid).to be_nil end end context "Given an invalid callsign with valid ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID) + address = Ax25::ImmutableAddress.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a nil callsign with valid ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(nil, BASE_ENTITY_SSID) + address = Ax25::ImmutableAddress.new(nil, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a non-string callsign with valid ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(5, BASE_ENTITY_SSID) + address = Ax25::ImmutableAddress.new(5, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a empty string callsign with valid ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new("", BASE_ENTITY_SSID) + address = Ax25::ImmutableAddress.new("", BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a valid callsign with non-integer ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, "invalid") + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, "invalid") }.to raise_error(ArgumentError) end end context "Given a valid callsign with ssid below 0" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(BAD_LOWSSID_ENTITY_CALLSIGN,BAD_LOWSSID_ENTITY_SSID) + address = Ax25::ImmutableAddress.new(BAD_LOWSSID_ENTITY_CALLSIGN,BAD_LOWSSID_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a valid callsign with ssid above 15" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID) + address = Ax25::ImmutableAddress.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a lowercase callsign with valid ssid" do - entity = Ax25::ImmutableEntity.new("wi2ard", 2) + address = Ax25::ImmutableAddress.new("wi2ard", 2) it "converts the callsign to uppercase" do - expect(entity.callsign).to eql("WI2ARD") + expect(address.callsign).to eql("WI2ARD") end end context "Given a callsign with extra spaces before and after and valid ssid" do - entity = Ax25::ImmutableEntity.new(" WI2ARD ", 2) + address = Ax25::ImmutableAddress.new(" WI2ARD ", 2) it "strips the extra spaces" do - expect(entity.callsign).to eql("WI2ARD") + expect(address.callsign).to eql("WI2ARD") end end end describe ".from_raw" do context "Given a valid callsign with ssid" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) - it "returns a Entity object" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) + it "returns a Address object" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "set the callsign correctly" do - expect(entity.callsign).to eql(BASE_ENTITY_CALLSIGN) + expect(address.callsign).to eql(BASE_ENTITY_CALLSIGN) end it "set the ssid correctly" do - expect(entity.ssid).to eql(BASE_ENTITY_SSID) + expect(address.ssid).to eql(BASE_ENTITY_SSID) end end context "Given a valid callsign with 0 ssid" do - entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) - it "returns a FrameEntity object" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY) + it "returns a FrameAddress object" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "the callsign field was parssed correctly" do - expect(entity.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) + expect(address.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) end it "the ssid field was parssed correctly" do - expect(entity.ssid).to be_nil + expect(address.ssid).to be_nil end end context "Given a valid callsign with no ssid" do - entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) - it "returns a FrameEntity object" do - expect(entity).not_to be_nil - expect(entity).to be_kind_of(Ax25::Entity) + address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) + it "returns a FrameAddress object" do + expect(address).not_to be_nil + expect(address).to be_kind_of(Ax25::Address) end it "the callsign field was parssed correctly" do - expect(entity.callsign).to eql(NOSSID_ENTITY_CALLSIGN) + expect(address.callsign).to eql(NOSSID_ENTITY_CALLSIGN) end it "the ssid field was parssed correctly" do - expect(entity.ssid).to eql(NOSSID_ENTITY_SSID) + expect(address.ssid).to eql(NOSSID_ENTITY_SSID) end end context "Given an invalid callsign with valid ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.from_raw(BAD_CALLSIGN_ENTITY) + address = Ax25::ImmutableAddress.from_raw(BAD_CALLSIGN_ENTITY) }.to raise_error(ArgumentError) end end - context "Given a entity with two hyphens" do + context "Given a address with two hyphens" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.from_raw(BAD_HYPHEN_ENTITY) + address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_ENTITY) }.to raise_error(ArgumentError) end end - context "Given a entity with a hyphen but no ssid" do + context "Given a address with a hyphen but no ssid" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.from_raw(BAD_HYPHEN_NOSSID_ENTITY) + address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_NOSSID_ENTITY) }.to raise_error(ArgumentError) end end - context "Given a entity with a an ssid greater than 15" do + context "Given a address with a an ssid greater than 15" do it "throws an argument error" do expect { - entity = Ax25::ImmutableEntity.from_raw(BAD_HIGHSSID_ENTITY) + address = Ax25::ImmutableAddress.from_raw(BAD_HIGHSSID_ENTITY) }.to raise_error(ArgumentError) end end end describe ".callsign" do - context "Given a Entity with valid callsign and with an ssid" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) + context "Given a Address with valid callsign and with an ssid" do + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then the callsign should be frozen" do - expect(entity.callsign).to be_frozen + expect(address.callsign).to be_frozen end end - context "Given a Entity with valid callsign and without an ssid" do - entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) + context "Given a Address with valid callsign and without an ssid" do + address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) it "then the callsign should be frozen" do - expect(entity.callsign).to be_frozen + expect(address.callsign).to be_frozen end end - context "Given any valid Entity" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) + context "Given any valid Address" do + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then we should not be able to set a value" do expect { - entity.callsign = "BAD1B" + address.callsign = "BAD1B" }.to raise_error(NoMethodError) end it "then we should not be able to alter a value" do expect { - entity.callsign << "XX" + address.callsign << "XX" }.to raise_error(FrozenError) end it "then the callsign passed to from_raw should be duplicated" do passed_call = "WI2AR" orig_call = passed_call.dup.freeze - entity = Ax25::ImmutableEntity.from_raw(passed_call) + address = Ax25::ImmutableAddress.from_raw(passed_call) passed_call << "D" - expect(entity.callsign).to eql(orig_call) + expect(address.callsign).to eql(orig_call) expect(passed_call).to eql("WI2ARD") expect(orig_call).to eql("WI2AR") end end end describe ".ssid" do - context "Given any valid Entity" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) + context "Given any valid Address" do + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then we should not be able to set a value" do expect { - entity.ssid = "1" + address.ssid = "1" }.to raise_error(NoMethodError) end it "then we should not be able to alter a value" do expect { - entity.ssid += 1 + address.ssid += 1 }.to raise_error(NoMethodError) end end end describe ".decrement_ssid" do - context "Given a Entity that has a greater than 0 ssid" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) + context "Given a Address that has a greater than 0 ssid" do + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) context "which has its ssid decremented" do - new_entity = entity.decrement_ssid - it "should produce a duplicated Entity" do - expect(entity).to_not eql(new_entity) + new_address = address.decrement_ssid + it "should produce a duplicated Address" do + expect(address).to_not eql(new_address) end it "should have a different ssid" do - expect(new_entity.ssid).to_not eql(entity.ssid) + expect(new_address.ssid).to_not eql(address.ssid) end it "should have ssid that is one less than before" do - expect(new_entity.ssid).to eql(entity.ssid - 1) + expect(new_address.ssid).to eql(address.ssid - 1) end end end - context "Given a Entity that has a ssid of 0" do - entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) + context "Given a Address that has a ssid of 0" do + address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY) context "which has its ssid decremented" do it "throws a range error" do expect{ - entity.decrement_ssid + address.decrement_ssid }.to raise_error(RangeError) end end @@ -294,105 +294,105 @@ describe Ax25::Entity do end describe ".to_s" do context "Given a raw string with valid callsign with ssid" do - entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) + address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then we should produce the correct string" do - expect(entity.to_s).to eql(BASE_ENTITY) + expect(address.to_s).to eql(BASE_ENTITY) end end context "Given a raw string with valid callsign with ssid of zero" do - entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) + address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY) it "then we should produce the correct string" do - expect(entity.to_s).to eql(NOSSID_ENTITY) + expect(address.to_s).to eql(NOSSID_ENTITY) end end context "Given a raw string with valid callsign without ssid" do - entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) + address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) it "then we should produce the correct string" do - expect(entity.to_s).to eql(NOSSID_ENTITY) + expect(address.to_s).to eql(NOSSID_ENTITY) end end - context "Given a FrameEntity from new with valid callsign with non-zero ssid" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + context "Given a FrameAddress from new with valid callsign with non-zero ssid" do + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "then we should produce the correct string" do - expect(entity.to_s).to eql(BASE_ENTITY) + expect(address.to_s).to eql(BASE_ENTITY) end end - context "Given a FrameEntity from new with valid callsign with ssid of 0" do - entity = Ax25::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) + context "Given a FrameAddress from new with valid callsign with ssid of 0" do + address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) it "then we should produce the correct string" do - expect(entity.to_s).to eql(NOSSID_ENTITY) + expect(address.to_s).to eql(NOSSID_ENTITY) end end end describe ".==" do - context "Given one Entity and an equivelant non-Entity class with the same properties" do - entity_equiv = EntityEquiv.new - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + context "Given one Address and an equivelant non-Address class with the same properties" do + address_equiv = AddressEquiv.new + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "then equality should return true" do - expect(entity == entity_equiv).to be_truthy + expect(address == address_equiv).to be_truthy end end - context "Given two equivelant entitys both instaces of Entity class with the same properties" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) + context "Given two equivelant addresss both instaces of Address class with the same properties" do + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0) + address_equiv = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, nil) it "then equality should return true" do - expect(entity == entity_equiv).to be_truthy + expect(address == address_equiv).to be_truthy end end - context "Given one Entity and a equivelant non-Entity class with different properties" do - entity_equiv = EntityEquiv.new - entity = Ax25::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) + context "Given one Address and a equivelant non-Address class with different properties" do + address_equiv = AddressEquiv.new + address = Ax25::ImmutableAddress.new("BADCALL", BASE_ENTITY_SSID) it "then equality should return true" do - expect(entity == entity_equiv).to be_falsey + expect(address == address_equiv).to be_falsey end end - context "Given two equivelant entitys both instaces of Entity class with different properties" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Ax25::ImmutableEntity.new("BADCALL", nil) + context "Given two equivelant addresss both instaces of Address class with different properties" do + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0) + address_equiv = Ax25::ImmutableAddress.new("BADCALL", nil) it "then equality should return true" do - expect(entity == entity_equiv).to be_falsey + expect(address == address_equiv).to be_falsey end end end describe ".eql?" do - context "Given one Entity and an equivelant non-Entity class with the same properties" do - entity_equiv = EntityEquiv.new - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + context "Given one Address and an equivelant non-Address class with the same properties" do + address_equiv = AddressEquiv.new + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "throws an ArgumentError" do expect { - entity.eql? entity_equiv + address.eql? address_equiv }.to raise_error(ArgumentError) end end - context "Given two equivelant entitys both instaces of Entity class" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) + context "Given two equivelant addresss both instaces of Address class" do + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0) + address_equiv = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, nil) it "then eql should return true" do - expect(entity.eql? entity_equiv).to be_truthy + expect(address.eql? address_equiv).to be_truthy end end - context "Given one Entity and a equivelant non-Entity class with different properties" do - entity_equiv = EntityEquiv.new - entity = Ax25::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) + context "Given one Address and a equivelant non-Address class with different properties" do + address_equiv = AddressEquiv.new + address = Ax25::ImmutableAddress.new("BADCALL", BASE_ENTITY_SSID) it "throws an ArgumentError" do expect { - entity.eql? entity_equiv + address.eql? address_equiv }.to raise_error(ArgumentError) end end - context "Given two equivelant entitys both instaces of Entity class with different properties" do - entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Ax25::ImmutableEntity.new("BADCALL", nil) + context "Given two equivelant addresss both instaces of Address class with different properties" do + address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0) + address_equiv = Ax25::ImmutableAddress.new("BADCALL", nil) it "then eql should return false" do - expect(entity.eql? entity_equiv).to be_falsey + expect(address.eql? address_equiv).to be_falsey end end end