The project is in a healthy, maintained state
RSpec matchers for IP and MAC addresses
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

RSpec::Networking

Gem codecov

RSpec matchers for IP and MAC Addresses

Install

gem install rspec-networking

Usage

require "rspec/networking"


###  match an IP address  ###
expect(obj).to be_an_ip_address

# check version
expect(obj).to be_an_ip_address.v4
expect(obj).to be_an_ip_address.v6

# check for localhost
expect(obj).to be_an_ip_address.localhost

# compose with other matchers
expect(data).to include(addr: an_ip_address)



###  match a MAC address  ###
# 00:11:22:33:44:55, 00-11-22-33-44-55, 0011.2233.4455, or EUI-64
expect(obj).to be_a_mac_address

expect(obj).to be_a_mac_address.bits(48)

expect(obj).to be_a_mac_address.broadcast
expect(obj).to be_a_mac_address.multicast
expect(obj).to be_a_mac_address.unicast

# check manufacturer or specific device
expect(obj).to be_a_mac_address.from("xerox")
expect(obj).to be_a_mac_address.from("00:00:0C")
expect(obj).to be_a_mac_address.for(device)

# compose with other matchers
expect(data).to include(addr: a_mac_address)

Resources


Contributing

Yes please :)

  1. Fork it
  2. Create your feature branch (git checkout -b my-feature)
  3. Ensure the tests pass (bundle exec rspec)
  4. Commit your changes (git commit -am 'awesome new feature')
  5. Push your branch (git push origin my-feature)
  6. Create a Pull Request

Manufacturer OUIs come from the IEEE registry; refresh them with script/update_manufacturers.