Sha256: 7c7d8af385340b2b6032831df7c08277413d42c5419227a8e839193de40d2c89

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

require 'ronin/mac_address'

describe MACAddress do
  let(:address) { '00:01:02:03:04:05' }

  subject { described_class.new(:address => address) }

  describe "extract" do
    subject { described_class }

    let(:mac1) { subject.parse('00:12:34:56:78:9a') }
    let(:mac2) { subject.parse('AA:BB:CC:DD:EE:FF') }
    let(:text)  { "MACs: #{mac1}, #{mac2}." }

    it "should extract multiple MAC Addresses from text" do
      expect(subject.extract(text)).to eq([mac1, mac2])
    end

    it "should yield the extracted MAC Addresses if a block is given" do
      macs = []

      subject.extract(text) { |mac| macs << mac }

      expect(macs).to eq([mac1, mac2])
    end
  end

  describe "validations" do
    it "should require an address" do
      mac = described_class.new
      expect(mac).not_to be_valid

      mac.address = address
      expect(mac).to be_valid
    end
  end

  describe "#to_i" do
    let(:integer) { 0x000102030405 }

    it "should convert the MAC Address to an Integer" do
      expect(subject.to_i).to eq(integer)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-1.5.1 spec/mac_address_spec.rb