Skip to content
Snippets Groups Projects
Verified Commit afa1c6b1 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

Forgot to refactor all caps ENTITY and CALLSIGN

parent bfd6263a
No related branches found
No related tags found
No related merge requests found
require_relative '../../../lib/ax25'
BASE_ENTITY = "WI2ARD-10".freeze
BASE_ENTITY_CALLSIGN = "WI2ARD".freeze
BASE_ENTITY_SSID = 10
BASE_ADDRESS = "WI2ARD-10".freeze
BASE_ADDRESS_ENTITY = "WI2ARD".freeze
BASE_ADDRESS_SSID = 10
NOSSID_ENTITY = "WI2ARD".freeze
NOSSID_ENTITY_CALLSIGN = "WI2ARD".freeze
NOSSID_ENTITY_SSID = nil
NOSSID_ADDRESS = "WI2ARD".freeze
NOSSID_ADDRESS_ENTITY = "WI2ARD".freeze
NOSSID_ADDRESS_SSID = nil
ZEROSSID_ENTITY = "WI2ARD-0".freeze
ZEROSSID_ENTITY_CALLSIGN = "WI2ARD".freeze
ZEROSSID_ENTITY_SSID = 0
ZEROSSID_ADDRESS = "WI2ARD-0".freeze
ZEROSSID_ADDRESS_ENTITY = "WI2ARD".freeze
ZEROSSID_ADDRESS_SSID = 0
BAD_CALLSIGN_ENTITY = "WI2&ARD-10".freeze
BAD_CALLSIGN_ENTITY_CALLSIGN = "WI2&ARD".freeze
BAD_CALLSIGN_ENTITY_SSID = 10
BAD_ENTITY_ADDRESS = "WI2&ARD-10".freeze
BAD_ENTITY_ADDRESS_ENTITY = "WI2&ARD".freeze
BAD_ENTITY_ADDRESS_SSID = 10
BAD_HYPHEN_ENTITY = "WI2ARD-1-1".freeze
BAD_HYPHEN_ADDRESS = "WI2ARD-1-1".freeze
BAD_HYPHEN_NOSSID_ENTITY = "WI2ARD-".freeze
BAD_HYPHEN_NOSSID_ADDRESS = "WI2ARD-".freeze
BAD_LOWSSID_ENTITY_CALLSIGN = "WI2ARD".freeze
BAD_LOWSSID_ENTITY_SSID = -1
BAD_LOWSSID_ADDRESS_ENTITY = "WI2ARD".freeze
BAD_LOWSSID_ADDRESS_SSID = -1
BAD_HIGHSSID_ENTITY = "WI2ARD-16".freeze
BAD_HIGHSSID_ENTITY_CALLSIGN = "WI2ARD".freeze
BAD_HIGHSSID_ENTITY_SSID = 16
BAD_HIGHSSID_ADDRESS = "WI2ARD-16".freeze
BAD_HIGHSSID_ADDRESS_ENTITY = "WI2ARD".freeze
BAD_HIGHSSID_ADDRESS_SSID = 16
class AddressEquiv
public
......@@ -42,42 +42,42 @@ end
describe Ax25::Address do
describe ".new" do
context "Given a valid entity with ssid" do
address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, BASE_ADDRESS_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 entity property correctly" do
expect(address.entity).to eql(BASE_ENTITY_CALLSIGN)
expect(address.entity).to eql(BASE_ADDRESS_ENTITY)
end
it "set the ssid property correctly" do
expect(address.ssid).to eql(BASE_ENTITY_SSID)
expect(address.ssid).to eql(BASE_ADDRESS_SSID)
end
it "entity is frozen" do
expect(address.entity).to be_frozen
end
end
context "Given a valid entity with nil ssid" do
address = Ax25::ImmutableAddress.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(NOSSID_ADDRESS_ENTITY, NOSSID_ADDRESS_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 entity property correctly" do
expect(address.entity).to eql(NOSSID_ENTITY_CALLSIGN)
expect(address.entity).to eql(NOSSID_ADDRESS_ENTITY)
end
it "set the ssid property correctly" do
expect(address.ssid).to eql(NOSSID_ENTITY_SSID)
expect(address.ssid).to eql(NOSSID_ADDRESS_SSID)
end
end
context "Given a valid entity with zero for ssid" do
address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(ZEROSSID_ADDRESS_ENTITY, ZEROSSID_ADDRESS_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 entity property correctly" do
expect(address.entity).to eql(ZEROSSID_ENTITY_CALLSIGN)
expect(address.entity).to eql(ZEROSSID_ADDRESS_ENTITY)
end
it "set the ssid property correctly" do
expect(address.ssid).to be_nil
......@@ -86,49 +86,49 @@ describe Ax25::Address do
context "Given an invalid entity with valid ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(BAD_ENTITY_ADDRESS_ENTITY, BAD_ENTITY_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
context "Given a nil entity with valid ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(nil, BASE_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(nil, BASE_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
context "Given a non-string entity with valid ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(5, BASE_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(5, BASE_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
context "Given a empty string entity with valid ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new("", BASE_ENTITY_SSID)
address = Ax25::ImmutableAddress.new("", BASE_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with non-integer ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, "invalid")
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, "invalid")
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with ssid below 0" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(BAD_LOWSSID_ENTITY_CALLSIGN,BAD_LOWSSID_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(BAD_LOWSSID_ADDRESS_ENTITY,BAD_LOWSSID_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with ssid above 15" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(BAD_HIGHSSID_ADDRESS_ENTITY,BAD_HIGHSSID_ADDRESS_SSID)
}.to raise_error(ArgumentError)
end
end
......@@ -147,88 +147,88 @@ describe Ax25::Address do
end
describe ".from_raw" do
context "Given a valid entity with ssid" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
it "returns a Address object" do
expect(address).not_to be_nil
expect(address).to be_kind_of(Ax25::Address)
end
it "set the entity correctly" do
expect(address.entity).to eql(BASE_ENTITY_CALLSIGN)
expect(address.entity).to eql(BASE_ADDRESS_ENTITY)
end
it "set the ssid correctly" do
expect(address.ssid).to eql(BASE_ENTITY_SSID)
expect(address.ssid).to eql(BASE_ADDRESS_SSID)
end
end
context "Given a valid entity with 0 ssid" do
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ADDRESS)
it "returns a FrameAddress object" do
expect(address).not_to be_nil
expect(address).to be_kind_of(Ax25::Address)
end
it "the entity field was parssed correctly" do
expect(address.entity).to eql(ZEROSSID_ENTITY_CALLSIGN)
expect(address.entity).to eql(ZEROSSID_ADDRESS_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(address.ssid).to be_nil
end
end
context "Given a valid entity with no ssid" do
address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(NOSSID_ADDRESS)
it "returns a FrameAddress object" do
expect(address).not_to be_nil
expect(address).to be_kind_of(Ax25::Address)
end
it "the entity field was parssed correctly" do
expect(address.entity).to eql(NOSSID_ENTITY_CALLSIGN)
expect(address.entity).to eql(NOSSID_ADDRESS_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(address.ssid).to eql(NOSSID_ENTITY_SSID)
expect(address.ssid).to eql(NOSSID_ADDRESS_SSID)
end
end
context "Given an invalid entity with valid ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.from_raw(BAD_CALLSIGN_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BAD_ENTITY_ADDRESS)
}.to raise_error(ArgumentError)
end
end
context "Given a address with two hyphens" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_ADDRESS)
}.to raise_error(ArgumentError)
end
end
context "Given a address with a hyphen but no ssid" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_NOSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BAD_HYPHEN_NOSSID_ADDRESS)
}.to raise_error(ArgumentError)
end
end
context "Given a address with a an ssid greater than 15" do
it "throws an argument error" do
expect {
address = Ax25::ImmutableAddress.from_raw(BAD_HIGHSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BAD_HIGHSSID_ADDRESS)
}.to raise_error(ArgumentError)
end
end
end
describe ".entity" do
context "Given a Address with valid entity and with an ssid" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
it "then the entity should be frozen" do
expect(address.entity).to be_frozen
end
end
context "Given a Address with valid entity and without an ssid" do
address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(NOSSID_ADDRESS)
it "then the entity should be frozen" do
expect(address.entity).to be_frozen
end
end
context "Given any valid Address" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
it "then we should not be able to set a value" do
expect {
address.entity = "BAD1B"
......@@ -252,7 +252,7 @@ describe Ax25::Address do
end
describe ".ssid" do
context "Given any valid Address" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
it "then we should not be able to set a value" do
expect {
address.ssid = "1"
......@@ -267,7 +267,7 @@ describe Ax25::Address do
end
describe ".decrement_ssid" do
context "Given a Address that has a greater than 0 ssid" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
context "which has its ssid decremented" do
new_address = address.decrement_ssid
it "should produce a duplicated Address" do
......@@ -282,7 +282,7 @@ describe Ax25::Address do
end
end
context "Given a Address that has a ssid of 0" do
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ADDRESS)
context "which has its ssid decremented" do
it "throws a range error" do
expect{
......@@ -294,33 +294,33 @@ describe Ax25::Address do
end
describe ".to_s" do
context "Given a raw string with valid entity with ssid" do
address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY)
address = Ax25::ImmutableAddress.from_raw(BASE_ADDRESS)
it "then we should produce the correct string" do
expect(address.to_s).to eql(BASE_ENTITY)
expect(address.to_s).to eql(BASE_ADDRESS)
end
end
context "Given a raw string with valid entity with ssid of zero" do
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ADDRESS)
it "then we should produce the correct string" do
expect(address.to_s).to eql(NOSSID_ENTITY)
expect(address.to_s).to eql(NOSSID_ADDRESS)
end
end
context "Given a raw string with valid entity without ssid" do
address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY)
address = Ax25::ImmutableAddress.from_raw(NOSSID_ADDRESS)
it "then we should produce the correct string" do
expect(address.to_s).to eql(NOSSID_ENTITY)
expect(address.to_s).to eql(NOSSID_ADDRESS)
end
end
context "Given a FrameAddress from new with valid entity with non-zero ssid" do
address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, BASE_ADDRESS_SSID)
it "then we should produce the correct string" do
expect(address.to_s).to eql(BASE_ENTITY)
expect(address.to_s).to eql(BASE_ADDRESS)
end
end
context "Given a FrameAddress from new with valid entity with ssid of 0" do
address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID)
address = Ax25::ImmutableAddress.new(ZEROSSID_ADDRESS_ENTITY, ZEROSSID_ADDRESS_SSID)
it "then we should produce the correct string" do
expect(address.to_s).to eql(NOSSID_ENTITY)
expect(address.to_s).to eql(NOSSID_ADDRESS)
end
end
end
......@@ -328,15 +328,15 @@ describe Ax25::Address do
describe ".==" do
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)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, BASE_ADDRESS_SSID)
it "then equality should return true" do
expect(address == address_equiv).to be_truthy
end
end
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)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, 0)
address_equiv = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, nil)
it "then equality should return true" do
expect(address == address_equiv).to be_truthy
end
......@@ -344,14 +344,14 @@ describe Ax25::Address do
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)
address = Ax25::ImmutableAddress.new("BADCALL", BASE_ADDRESS_SSID)
it "then equality should return true" do
expect(address == address_equiv).to be_falsey
end
end
context "Given two equivelant addresss both instaces of Address class with different properties" do
address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, 0)
address_equiv = Ax25::ImmutableAddress.new("BADCALL", nil)
it "then equality should return true" do
expect(address == address_equiv).to be_falsey
......@@ -362,7 +362,7 @@ describe Ax25::Address do
describe ".eql?" do
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)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, BASE_ADDRESS_SSID)
it "throws an ArgumentError" do
expect {
address.eql? address_equiv
......@@ -371,8 +371,8 @@ describe Ax25::Address do
end
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)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, 0)
address_equiv = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, nil)
it "then eql should return true" do
expect(address.eql? address_equiv).to be_truthy
end
......@@ -380,7 +380,7 @@ describe Ax25::Address do
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)
address = Ax25::ImmutableAddress.new("BADCALL", BASE_ADDRESS_SSID)
it "throws an ArgumentError" do
expect {
address.eql? address_equiv
......@@ -389,7 +389,7 @@ describe Ax25::Address do
end
context "Given two equivelant addresss both instaces of Address class with different properties" do
address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, 0)
address = Ax25::ImmutableAddress.new(BASE_ADDRESS_ENTITY, 0)
address_equiv = Ax25::ImmutableAddress.new("BADCALL", nil)
it "then eql should return false" do
expect(address.eql? address_equiv).to be_falsey
......
require_relative '../../../lib/ax25/frame/hop'
BASE_HOP = "WI2ARD-10*".freeze
BASE_HOP_CALLSIGN = "WI2ARD".freeze
BASE_HOP_ENTITY = "WI2ARD".freeze
BASE_HOP_SSID = 10
BASE_HOP_SEEN = true
UNSEEN_HOP = "WI2ARD-10".freeze
UNSEEN_HOP_CALLSIGN = "WI2ARD".freeze
UNSEEN_HOP_ENTITY = "WI2ARD".freeze
UNSEEN_HOP_SSID = 10
UNSEEN_HOP_SEEN = false
NOSSID_HOP = "WI2ARD*".freeze
NOSSID_HOP_CALLSIGN = "WI2ARD".freeze
NOSSID_HOP_ENTITY = "WI2ARD".freeze
NOSSID_HOP_SSID = nil
NOSSID_HOP_SEEN = true
ZEROSSID_HOP = "WI2ARD-0*".freeze
ZEROSSID_HOP_CALLSIGN = "WI2ARD".freeze
ZEROSSID_HOP_ENTITY = "WI2ARD".freeze
ZEROSSID_HOP_SSID = 0
ZEROSSID_HOP_SEEN = true
NOSSID_UNSEEN_HOP = "WI2ARD".freeze
NOSSID_UNSEEN_HOP_CALLSIGN = "WI2ARD".freeze
NOSSID_UNSEEN_HOP_ENTITY = "WI2ARD".freeze
NOSSID_UNSEEN_HOP_SSID = nil
NOSSID_UNSEEN_HOP_SEEN = false
ZEROSSID_UNSEEN_HOP = "WI2ARD-0".freeze
ZEROSSID_UNSEEN_HOP_CALLSIGN = "WI2ARD".freeze
ZEROSSID_UNSEEN_HOP_ENTITY = "WI2ARD".freeze
ZEROSSID_UNSEEN_HOP_SSID = 0
ZEROSSID_UNSEEN_HOP_SEEN = false
BAD_CALLSIGN_HOP = "WI2&ARD-10*".freeze
BAD_CALLSIGN_HOP_CALLSIGN = "WI2&ARD".freeze
BAD_CALLSIGN_HOP_SSID = 10
BAD_CALLSIGN_HOP_SEEN = true
BAD_ENTITY_HOP = "WI2&ARD-10*".freeze
BAD_ENTITY_HOP_ENTITY = "WI2&ARD".freeze
BAD_ENTITY_HOP_SSID = 10
BAD_ENTITY_HOP_SEEN = true
BAD_HYPHEN_HOP = "WI2ARD-1-1*".freeze
BAD_HYPHEN_NOSSID_HOP = "WI2ARD-*".freeze
BAD_LOWSSID_HOP_CALLSIGN = "WI2ARD".freeze
BAD_LOWSSID_HOP_ENTITY = "WI2ARD".freeze
BAD_LOWSSID_HOP_SSID = -1
BAD_LOWSSID_HOP_SEEN = true
BAD_HIGHSSID_HOP = "WI2ARD-16*".freeze
BAD_HIGHSSID_HOP_CALLSIGN = "WI2ARD".freeze
BAD_HIGHSSID_HOP_ENTITY = "WI2ARD".freeze
BAD_HIGHSSID_HOP_SSID = 16
BAD_HIGHSSID_HOP_SEEN = true
......@@ -68,13 +68,13 @@ end
describe Ax25::Hop do
describe ".new" do
context "Given a valid entity with ssid and with seen flag" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, BASE_HOP_SSID, BASE_HOP_SEEN)
it "returns a FrameHop object with correct properties" do
expect(hop).not_to be_nil
expect(hop).to be_kind_of(Ax25::Hop)
end
it "set the entity property correctly" do
expect(hop.entity).to eql(BASE_HOP_CALLSIGN)
expect(hop.entity).to eql(BASE_HOP_ENTITY)
end
it "set the ssid property correctly" do
expect(hop.ssid).to eql(BASE_HOP_SSID)
......@@ -84,13 +84,13 @@ describe Ax25::Hop do
end
end
context "Given a valid entity with nil ssid and with seen flag" do
hop = Ax25::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(NOSSID_HOP_ENTITY, NOSSID_HOP_SSID, NOSSID_HOP_SEEN)
it "returns a FrameHop object with correct properties" do
expect(hop).not_to be_nil
expect(hop).to be_kind_of(Ax25::Hop)
end
it "set the entity property correctly" do
expect(hop.entity).to eql(NOSSID_HOP_CALLSIGN)
expect(hop.entity).to eql(NOSSID_HOP_ENTITY)
end
it "set the ssid property correctly" do
expect(hop.ssid).to eql(NOSSID_HOP_SSID)
......@@ -100,13 +100,13 @@ describe Ax25::Hop do
end
end
context "Given a valid entity with zero for ssid and with seen flag" do
hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_ENTITY, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN)
it "returns a FrameHop object with correct properties" do
expect(hop).not_to be_nil
expect(hop).to be_kind_of(Ax25::Hop)
end
it "set the entity property correctly" do
expect(hop.entity).to eql(ZEROSSID_HOP_CALLSIGN)
expect(hop.entity).to eql(ZEROSSID_HOP_ENTITY)
end
it "set the ssid property correctly" do
expect(hop.ssid).to be_nil
......@@ -118,7 +118,7 @@ describe Ax25::Hop do
context "Given an invalid entity with valid ssid and valid seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BAD_CALLSIGN_HOP_CALLSIGN, BAD_CALLSIGN_HOP_SSID, BAD_CALLSIGN_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BAD_ENTITY_HOP_ENTITY, BAD_ENTITY_HOP_SSID, BAD_ENTITY_HOP_SEEN)
}.to raise_error(ArgumentError)
end
end
......@@ -132,7 +132,7 @@ describe Ax25::Hop do
context "Given a valid entity with valid ssid and nil seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, nil)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, BASE_HOP_SSID, nil)
}.to raise_error(ArgumentError)
end
end
......@@ -153,28 +153,28 @@ describe Ax25::Hop do
context "Given a valid entity with non-integer ssid and valid seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, "invalid", BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, "invalid", BASE_HOP_SEEN)
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with valid ssid and non-boolean seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN,BASE_HOP_SSID, "invalid")
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY,BASE_HOP_SSID, "invalid")
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with ssid below 0 and valid seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BAD_LOWSSID_HOP_CALLSIGN,BAD_LOWSSID_HOP_SSID, BAD_LOWSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BAD_LOWSSID_HOP_ENTITY,BAD_LOWSSID_HOP_SSID, BAD_LOWSSID_HOP_SEEN)
}.to raise_error(ArgumentError)
end
end
context "Given a valid entity with ssid above 15 and valid seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.new(BAD_HIGHSSID_HOP_CALLSIGN,BAD_HIGHSSID_HOP_SSID, BAD_HIGHSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BAD_HIGHSSID_HOP_ENTITY,BAD_HIGHSSID_HOP_SSID, BAD_HIGHSSID_HOP_SEEN)
}.to raise_error(ArgumentError)
end
end
......@@ -199,7 +199,7 @@ describe Ax25::Hop do
expect(hop).to be_kind_of(Ax25::Hop)
end
it "set the entity correctly" do
expect(hop.entity).to eql(BASE_HOP_CALLSIGN)
expect(hop.entity).to eql(BASE_HOP_ENTITY)
end
it "set the ssid correctly" do
expect(hop.ssid).to eql(BASE_HOP_SSID)
......@@ -215,7 +215,7 @@ describe Ax25::Hop do
expect(hop).to be_kind_of(Ax25::Hop)
end
it "the entity field was parssed correctly" do
expect(hop.entity).to eql(UNSEEN_HOP_CALLSIGN)
expect(hop.entity).to eql(UNSEEN_HOP_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(hop.ssid).to eql(UNSEEN_HOP_SSID)
......@@ -231,7 +231,7 @@ describe Ax25::Hop do
expect(hop).to be_kind_of(Ax25::Hop)
end
it "the entity field was parssed correctly" do
expect(hop.entity).to eql(ZEROSSID_HOP_CALLSIGN)
expect(hop.entity).to eql(ZEROSSID_HOP_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(hop.ssid).to be_nil
......@@ -247,7 +247,7 @@ describe Ax25::Hop do
expect(hop).to be_kind_of(Ax25::Hop)
end
it "the entity field was parssed correctly" do
expect(hop.entity).to eql(NOSSID_HOP_CALLSIGN)
expect(hop.entity).to eql(NOSSID_HOP_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(hop.ssid).to eql(NOSSID_HOP_SSID)
......@@ -263,7 +263,7 @@ describe Ax25::Hop do
expect(hop).to be_kind_of(Ax25::Hop)
end
it "the entity field was parssed correctly" do
expect(hop.entity).to eql(NOSSID_UNSEEN_HOP_CALLSIGN)
expect(hop.entity).to eql(NOSSID_UNSEEN_HOP_ENTITY)
end
it "the ssid field was parssed correctly" do
expect(hop.ssid).to eql(NOSSID_UNSEEN_HOP_SSID)
......@@ -275,7 +275,7 @@ describe Ax25::Hop do
context "Given an invalid entity with valid ssid and valid seen flag" do
it "throws an argument error" do
expect {
hop = Ax25::ImmutableHop.from_raw(BAD_CALLSIGN_HOP)
hop = Ax25::ImmutableHop.from_raw(BAD_ENTITY_HOP)
}.to raise_error(ArgumentError)
end
end
......@@ -459,31 +459,31 @@ describe Ax25::Hop do
end
end
context "Given a FrameHop from new with valid entity with non-zero ssid and with seen flag" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, BASE_HOP_SSID, BASE_HOP_SEEN)
it "then we should produce the correct string" do
expect(hop.to_s).to eql(BASE_HOP)
end
end
context "Given a FrameHop from new with valid entity with non-zero ssid and without seen flag" do
hop = Ax25::ImmutableHop.new(UNSEEN_HOP_CALLSIGN, UNSEEN_HOP_SSID, UNSEEN_HOP_SEEN)
hop = Ax25::ImmutableHop.new(UNSEEN_HOP_ENTITY, UNSEEN_HOP_SSID, UNSEEN_HOP_SEEN)
it "then we should produce the correct string" do
expect(hop.to_s).to eql(UNSEEN_HOP)
end
end
context "Given a FrameHop from new with valid entity with nil ssid and with seen flag" do
hop = Ax25::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(NOSSID_HOP_ENTITY, NOSSID_HOP_SSID, NOSSID_HOP_SEEN)
it "then we should produce the correct string" do
expect(hop.to_s).to eql(NOSSID_HOP)
end
end
context "Given a FrameHop from new with valid entity with ssid of 0 and with seen flag" do
hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN)
hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_ENTITY, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN)
it "then we should produce the correct string" do
expect(hop.to_s).to eql(NOSSID_HOP)
end
end
context "Given a FrameHop from new with valid entity with ssid of zero and without seen flag" do
hop = Ax25::ImmutableHop.new(ZEROSSID_UNSEEN_HOP_CALLSIGN, ZEROSSID_UNSEEN_HOP_SSID, ZEROSSID_UNSEEN_HOP_SEEN)
hop = Ax25::ImmutableHop.new(ZEROSSID_UNSEEN_HOP_ENTITY, ZEROSSID_UNSEEN_HOP_SSID, ZEROSSID_UNSEEN_HOP_SEEN)
it "then we should produce the correct string" do
expect(hop.to_s).to eql(NOSSID_UNSEEN_HOP)
end
......@@ -493,15 +493,15 @@ describe Ax25::Hop do
describe ".==" do
context "Given one Hop and an equivelant non-Hop class with the same properties" do
hop_equiv = HopEquiv.new
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, BASE_HOP_SSID, BASE_HOP_SEEN)
it "then equality should return true" do
expect(hop == hop_equiv).to be_truthy
end
end
context "Given two equivelant hops both instaces of Hop class with the same properties" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, nil, BASE_HOP_SEEN)
it "then equality should return true" do
expect(hop == hop_equiv).to be_truthy
end
......@@ -516,7 +516,7 @@ describe Ax25::Hop do
end
context "Given two equivelant hops both instaces of Hop class with different properties" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN)
it "then equality should return true" do
expect(hop == hop_equiv).to be_falsey
......@@ -527,7 +527,7 @@ describe Ax25::Hop do
describe ".eql?" do
context "Given one Hop and an equivelant non-Hop class with the same properties" do
hop_equiv = HopEquiv.new
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, BASE_HOP_SSID, BASE_HOP_SEEN)
it "throws an ArgumentError" do
expect {
hop.eql? hop_equiv
......@@ -536,8 +536,8 @@ describe Ax25::Hop do
end
context "Given two equivelant hops both instaces of Hop class" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, nil, BASE_HOP_SEEN)
it "then eql should return true" do
expect(hop.eql? hop_equiv).to be_truthy
end
......@@ -554,7 +554,7 @@ describe Ax25::Hop do
end
context "Given two equivelant hops both instaces of Hop class with different properties" do
hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN)
hop = Ax25::ImmutableHop.new(BASE_HOP_ENTITY, 0, BASE_HOP_SEEN)
hop_equiv = Ax25::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN)
it "then eql should return false" do
expect(hop.eql? hop_equiv).to be_falsey
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment