rspec-networking 0.1.0 → 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 +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +42 -15
- data/README.md +9 -0
- data/lib/rspec/networking/ip_address.rb +9 -21
- data/lib/rspec/networking/mac_address/apple.txt +348 -26
- data/lib/rspec/networking/mac_address/eero.txt +49 -0
- data/lib/rspec/networking/mac_address/google.txt +30 -0
- data/lib/rspec/networking/mac_address/microsoft.txt +32 -2
- data/lib/rspec/networking/mac_address/nokia.txt +80 -1
- data/lib/rspec/networking/mac_address/oracle.txt +6 -0
- data/lib/rspec/networking/mac_address/sony.txt +25 -8
- data/lib/rspec/networking/mac_address/texas_instruments.txt +401 -335
- data/lib/rspec/networking/mac_address/toshiba.txt +3 -3
- data/lib/rspec/networking/mac_address/xerox.txt +11 -11
- data/lib/rspec/networking/mac_address/xiaomi.txt +82 -1
- data/lib/rspec/networking/mac_address/zyxel.txt +20 -3
- data/lib/rspec/networking/mac_address.rb +52 -77
- data/lib/rspec/networking/mac_address_manufacturers.rb +5 -14
- data/lib/rspec/networking/version.rb +1 -1
- data/rspec-networking.gemspec +11 -8
- data/script/update_manufacturers +43 -0
- metadata +10 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3bbe53912eef445cf379232b5bfeb54f5f4b08ac5b1a512d097284ad9f92082
|
|
4
|
+
data.tar.gz: 8f53cbeb1fe4b9329204c92062d14f0d59028d9a15e7b18e1921f1fd069f5836
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8038d82b745d89a9ad1c24f39275cdf1c20e1ec2416b0ffdc16ad03d06cccb4e6aa58d98da7f9b55474b4ea265a28bd1feac7737ca775855c01d29e6afcf56e9
|
|
7
|
+
data.tar.gz: d806849ad84301e317f7d080aaaef62d0f1998c2570588b6168c41558b9247504cd2c9913ffebecd387c2b333053384eaa2b7f3f67b0d878289ff4dab23584df
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
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
|
+
|
|
1
10
|
### 0.1.0 (2024-08-31)
|
|
2
11
|
- ip address
|
|
3
12
|
- mac addresses
|
data/Gemfile.lock
CHANGED
|
@@ -1,49 +1,76 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rspec-networking (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
|
-
|
|
11
|
-
concurrent-ruby (1.3.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
22
|
+
i18n (1.14.8)
|
|
17
23
|
concurrent-ruby (~> 1.0)
|
|
18
|
-
|
|
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.
|
|
47
|
+
rspec-core (3.13.6)
|
|
23
48
|
rspec-support (~> 3.13.0)
|
|
24
|
-
rspec-expectations (3.13.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
69
|
+
debug
|
|
43
70
|
faker
|
|
44
71
|
rspec
|
|
45
72
|
rspec-networking!
|
|
46
73
|
simplecov
|
|
47
74
|
|
|
48
75
|
BUNDLED WITH
|
|
49
|
-
|
|
76
|
+
4.0.16
|
data/README.md
CHANGED
|
@@ -17,10 +17,13 @@ gem install rspec-networking
|
|
|
17
17
|
```ruby
|
|
18
18
|
require "rspec/networking"
|
|
19
19
|
|
|
20
|
+
|
|
21
|
+
### match an IP address ###
|
|
20
22
|
expect(obj).to be_an_ip_address
|
|
21
23
|
|
|
22
24
|
# check version
|
|
23
25
|
expect(obj).to be_an_ip_address.v4
|
|
26
|
+
expect(obj).to be_an_ip_address.v6
|
|
24
27
|
|
|
25
28
|
# check for localhost
|
|
26
29
|
expect(obj).to be_an_ip_address.localhost
|
|
@@ -31,14 +34,18 @@ expect(data).to include(addr: an_ip_address)
|
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
### match a MAC address ###
|
|
37
|
+
# 00:11:22:33:44:55, 00-11-22-33-44-55, 0011.2233.4455, or EUI-64
|
|
34
38
|
expect(obj).to be_a_mac_address
|
|
35
39
|
|
|
40
|
+
expect(obj).to be_a_mac_address.bits(48)
|
|
41
|
+
|
|
36
42
|
expect(obj).to be_a_mac_address.broadcast
|
|
37
43
|
expect(obj).to be_a_mac_address.multicast
|
|
38
44
|
expect(obj).to be_a_mac_address.unicast
|
|
39
45
|
|
|
40
46
|
# check manufacturer or specific device
|
|
41
47
|
expect(obj).to be_a_mac_address.from("xerox")
|
|
48
|
+
expect(obj).to be_a_mac_address.from("00:00:0C")
|
|
42
49
|
expect(obj).to be_a_mac_address.for(device)
|
|
43
50
|
|
|
44
51
|
# compose with other matchers
|
|
@@ -63,3 +70,5 @@ Yes please :)
|
|
|
63
70
|
1. Commit your changes (`git commit -am 'awesome new feature'`)
|
|
64
71
|
1. Push your branch (`git push origin my-feature`)
|
|
65
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`.
|
|
@@ -14,41 +14,29 @@ RSpec::Matchers.define :be_an_ip_address do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
match do |actual|
|
|
17
|
-
@actual = actual
|
|
18
|
-
|
|
19
17
|
return false unless actual.is_a?(String) || actual.is_a?(IPAddr)
|
|
20
18
|
|
|
21
19
|
addr = actual.is_a?(IPAddr) ? actual : IPAddr.new(actual)
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
21
|
+
# IPAddr also parses CIDR ranges, eg. "10.0.0.0/8"
|
|
22
|
+
return false unless addr.prefix == (addr.ipv4? ? 32 : 128)
|
|
26
23
|
|
|
27
|
-
if @
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return false if @version == 4 && !addr.ipv4?
|
|
25
|
+
return false if @version == 6 && !addr.ipv6?
|
|
26
|
+
return false if @localhost && !addr.loopback?
|
|
30
27
|
|
|
31
28
|
true
|
|
32
|
-
rescue IPAddr::
|
|
29
|
+
rescue IPAddr::Error
|
|
33
30
|
false
|
|
34
31
|
end
|
|
35
32
|
|
|
36
33
|
description do
|
|
37
34
|
if @version
|
|
38
|
-
|
|
39
|
-
"an IPv#{@version} #{addr}"
|
|
35
|
+
"be an IPv#{@version} #{"localhost " if @localhost}address"
|
|
40
36
|
else
|
|
41
|
-
@localhost ? "a localhost" : "an IP address"
|
|
37
|
+
@localhost ? "be a localhost address" : "be an IP address"
|
|
42
38
|
end
|
|
43
39
|
end
|
|
44
|
-
|
|
45
|
-
failure_message do
|
|
46
|
-
"expected '#{@actual}' to be #{description}"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
failure_message_when_negated do
|
|
50
|
-
"expected '#{@actual}' not to be #{description}"
|
|
51
|
-
end
|
|
52
40
|
end
|
|
53
41
|
|
|
54
|
-
RSpec::Matchers.alias_matcher
|
|
42
|
+
RSpec::Matchers.alias_matcher(:an_ip_address, :be_an_ip_address) { |desc| desc.delete_prefix("be ") }
|