rspec-networking 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27e1529533844c6f359735dc609ecb1a937762787f2c609a147d4a30bdb700ee
4
- data.tar.gz: 9c6856542b1477181e7b5ee82c39525e5295ed145e1a6edeaadfbd8feac6b500
3
+ metadata.gz: e3bbe53912eef445cf379232b5bfeb54f5f4b08ac5b1a512d097284ad9f92082
4
+ data.tar.gz: 8f53cbeb1fe4b9329204c92062d14f0d59028d9a15e7b18e1921f1fd069f5836
5
5
  SHA512:
6
- metadata.gz: 0eb7ec667852a07380d2bc2344c04a175066b03ad86bfc5630f3b45f692555947e6ad02a505200fb73e76b0ff801214a684f19b2697baecf9bc52e941da5a326
7
- data.tar.gz: 3a2521fe2955a92542c82e322d0f82eb602f8967aaf208e814f303586fd6de72cb42680b8f6df59dd3fa77fedceda74ce3292e656922e012c9f96ba40275a68e
6
+ metadata.gz: 8038d82b745d89a9ad1c24f39275cdf1c20e1ec2416b0ffdc16ad03d06cccb4e6aa58d98da7f9b55474b4ea265a28bd1feac7737ca775855c01d29e6afcf56e9
7
+ data.tar.gz: d806849ad84301e317f7d080aaaef62d0f1998c2570588b6168c41558b9247504cd2c9913ffebecd387c2b333053384eaa2b7f3f67b0d878289ff4dab23584df
data/CHANGELOG.md CHANGED
@@ -1,2 +1,16 @@
1
+ ### 0.1.1 (2026-11-01)
2
+ - Manufacturer lookups use fresh IEEE data. Texas Instruments never matched, and OUIs with leading zeros (e.g. Microsoft 00:22:48) were missing.
3
+ - MAC addresses must match the whole string; a multi-line string no longer matches.
4
+ - `MMM.MMM.SSS.SSS` is no longer a MAC address (it matched IPv4 strings); Cisco `MMMM.MMSS.SSSS` is. Use colons or dashes with `.from` and `.for`.
5
+ - 64-bit MAC addresses accept dashes.
6
+ - MAC failure messages show `nil` as `nil`, and read "to be a MAC address".
7
+ - CIDR ranges like `10.0.0.0/8` are no longer IP addresses.
8
+ - IP failure messages show `nil` as `nil`.
9
+
10
+ ### 0.1.0 (2024-08-31)
11
+ - ip address
12
+ - mac addresses
13
+ - manufacturers
14
+
1
15
  ### 0.0.1 (2024-08-30)
2
16
  init
data/Gemfile.lock CHANGED
@@ -1,49 +1,76 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-networking (0.0.1)
4
+ rspec-networking (0.1.1)
5
5
  rspec-expectations (>= 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- byebug (11.1.3)
11
- concurrent-ruby (1.3.4)
12
- diff-lcs (1.5.1)
13
- docile (1.4.0)
14
- faker (3.4.2)
10
+ cgi (0.5.1)
11
+ concurrent-ruby (1.3.7)
12
+ date (3.5.1)
13
+ debug (1.11.1)
14
+ irb (~> 1.10)
15
+ reline (>= 0.3.8)
16
+ diff-lcs (1.6.2)
17
+ docile (1.4.1)
18
+ erb (4.0.4.1)
19
+ cgi (>= 0.3.3)
20
+ faker (3.5.3)
15
21
  i18n (>= 1.8.11, < 2)
16
- i18n (1.14.5)
22
+ i18n (1.14.8)
17
23
  concurrent-ruby (~> 1.0)
18
- rspec (3.13.0)
24
+ io-console (0.8.2)
25
+ irb (1.17.0)
26
+ pp (>= 0.6.0)
27
+ prism (>= 1.3.0)
28
+ rdoc (>= 4.0.0)
29
+ reline (>= 0.4.2)
30
+ pp (0.6.3)
31
+ prettyprint
32
+ prettyprint (0.2.0)
33
+ prism (1.9.0)
34
+ psych (5.3.1)
35
+ date
36
+ stringio
37
+ rdoc (7.2.0)
38
+ erb
39
+ psych (>= 4.0.0)
40
+ tsort
41
+ reline (0.6.3)
42
+ io-console (~> 0.5)
43
+ rspec (3.13.2)
19
44
  rspec-core (~> 3.13.0)
20
45
  rspec-expectations (~> 3.13.0)
21
46
  rspec-mocks (~> 3.13.0)
22
- rspec-core (3.13.0)
47
+ rspec-core (3.13.6)
23
48
  rspec-support (~> 3.13.0)
24
- rspec-expectations (3.13.0)
49
+ rspec-expectations (3.13.5)
25
50
  diff-lcs (>= 1.2.0, < 2.0)
26
51
  rspec-support (~> 3.13.0)
27
- rspec-mocks (3.13.0)
52
+ rspec-mocks (3.13.8)
28
53
  diff-lcs (>= 1.2.0, < 2.0)
29
54
  rspec-support (~> 3.13.0)
30
- rspec-support (3.13.1)
55
+ rspec-support (3.13.7)
31
56
  simplecov (0.22.0)
32
57
  docile (~> 1.1)
33
58
  simplecov-html (~> 0.11)
34
59
  simplecov_json_formatter (~> 0.1)
35
- simplecov-html (0.12.3)
60
+ simplecov-html (0.13.2)
36
61
  simplecov_json_formatter (0.1.4)
62
+ stringio (3.2.0)
63
+ tsort (0.2.0)
37
64
 
38
65
  PLATFORMS
39
66
  ruby
40
67
 
41
68
  DEPENDENCIES
42
- byebug
69
+ debug
43
70
  faker
44
71
  rspec
45
72
  rspec-networking!
46
73
  simplecov
47
74
 
48
75
  BUNDLED WITH
49
- 2.5.7
76
+ 4.0.16
data/README.md CHANGED
@@ -6,11 +6,59 @@ RSpec::Networking
6
6
  RSpec matchers for IP and MAC Addresses
7
7
 
8
8
 
9
+ ### Install
10
+ ```bash
11
+ gem install rspec-networking
12
+ ```
13
+
14
+
15
+ ### Usage
16
+
9
17
  ```ruby
10
18
  require "rspec/networking"
19
+
20
+
21
+ ### match an IP address ###
22
+ expect(obj).to be_an_ip_address
23
+
24
+ # check version
25
+ expect(obj).to be_an_ip_address.v4
26
+ expect(obj).to be_an_ip_address.v6
27
+
28
+ # check for localhost
29
+ expect(obj).to be_an_ip_address.localhost
30
+
31
+ # compose with other matchers
32
+ expect(data).to include(addr: an_ip_address)
33
+
34
+
35
+
36
+ ### match a MAC address ###
37
+ # 00:11:22:33:44:55, 00-11-22-33-44-55, 0011.2233.4455, or EUI-64
38
+ expect(obj).to be_a_mac_address
39
+
40
+ expect(obj).to be_a_mac_address.bits(48)
41
+
42
+ expect(obj).to be_a_mac_address.broadcast
43
+ expect(obj).to be_a_mac_address.multicast
44
+ expect(obj).to be_a_mac_address.unicast
45
+
46
+ # check manufacturer or specific device
47
+ expect(obj).to be_a_mac_address.from("xerox")
48
+ expect(obj).to be_a_mac_address.from("00:00:0C")
49
+ expect(obj).to be_a_mac_address.for(device)
50
+
51
+ # compose with other matchers
52
+ expect(data).to include(addr: a_mac_address)
11
53
  ```
12
54
 
13
55
 
56
+ ### Resources
57
+ - https://en.wikipedia.org/wiki/IP_address
58
+ - https://en.wikipedia.org/wiki/MAC_address
59
+ - https://www.lifewire.com/introduction-to-mac-addresses-817937
60
+
61
+
14
62
  ----
15
63
  ## Contributing
16
64
 
@@ -22,3 +70,5 @@ Yes please :)
22
70
  1. Commit your changes (`git commit -am 'awesome new feature'`)
23
71
  1. Push your branch (`git push origin my-feature`)
24
72
  1. Create a Pull Request
73
+
74
+ Manufacturer OUIs come from the [IEEE registry](https://standards-oui.ieee.org/); refresh them with `script/update_manufacturers`.
@@ -0,0 +1,42 @@
1
+ require "ipaddr"
2
+
3
+ RSpec::Matchers.define :be_an_ip_address do
4
+ chain :v4 do
5
+ @version = 4
6
+ end
7
+
8
+ chain :v6 do
9
+ @version = 6
10
+ end
11
+
12
+ chain :localhost do
13
+ @localhost = true
14
+ end
15
+
16
+ match do |actual|
17
+ return false unless actual.is_a?(String) || actual.is_a?(IPAddr)
18
+
19
+ addr = actual.is_a?(IPAddr) ? actual : IPAddr.new(actual)
20
+
21
+ # IPAddr also parses CIDR ranges, eg. "10.0.0.0/8"
22
+ return false unless addr.prefix == (addr.ipv4? ? 32 : 128)
23
+
24
+ return false if @version == 4 && !addr.ipv4?
25
+ return false if @version == 6 && !addr.ipv6?
26
+ return false if @localhost && !addr.loopback?
27
+
28
+ true
29
+ rescue IPAddr::Error
30
+ false
31
+ end
32
+
33
+ description do
34
+ if @version
35
+ "be an IPv#{@version} #{"localhost " if @localhost}address"
36
+ else
37
+ @localhost ? "be a localhost address" : "be an IP address"
38
+ end
39
+ end
40
+ end
41
+
42
+ RSpec::Matchers.alias_matcher(:an_ip_address, :be_an_ip_address) { |desc| desc.delete_prefix("be ") }