pio 0.2.7 → 0.3.0

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +1 -0
  4. data/CONTRIBUTING.md +12 -0
  5. data/Gemfile +26 -23
  6. data/Guardfile +5 -0
  7. data/README.md +61 -19
  8. data/Rakefile +54 -56
  9. data/lib/pio/arp/frame.rb +8 -6
  10. data/lib/pio/arp/message.rb +9 -23
  11. data/lib/pio/arp/reply.rb +6 -15
  12. data/lib/pio/arp/request.rb +7 -16
  13. data/lib/pio/arp.rb +14 -17
  14. data/lib/pio/icmp/frame.rb +131 -0
  15. data/lib/pio/icmp/message.rb +100 -0
  16. data/lib/pio/icmp/reply.rb +17 -0
  17. data/lib/pio/icmp/request.rb +17 -0
  18. data/lib/pio/icmp.rb +27 -0
  19. data/lib/pio/ipv4_address.rb +22 -39
  20. data/lib/pio/lldp/chassis_id_tlv.rb +13 -16
  21. data/lib/pio/lldp/end_of_lldpdu_value.rb +4 -5
  22. data/lib/pio/lldp/frame.rb +21 -32
  23. data/lib/pio/lldp/management_address_value.rb +3 -4
  24. data/lib/pio/lldp/optional_tlv.rb +13 -22
  25. data/lib/pio/lldp/organizationally_specific_value.rb +3 -4
  26. data/lib/pio/lldp/port_description_value.rb +3 -4
  27. data/lib/pio/lldp/port_id_tlv.rb +6 -9
  28. data/lib/pio/lldp/system_capabilities_value.rb +3 -4
  29. data/lib/pio/lldp/system_description_value.rb +3 -4
  30. data/lib/pio/lldp/system_name_value.rb +3 -4
  31. data/lib/pio/lldp/ttl_tlv.rb +6 -9
  32. data/lib/pio/lldp.rb +20 -36
  33. data/lib/pio/mac.rb +30 -53
  34. data/lib/pio/message_util.rb +19 -0
  35. data/lib/pio/type/config.reek +4 -0
  36. data/lib/pio/type/ethernet_header.rb +7 -4
  37. data/lib/pio/type/ip_address.rb +5 -8
  38. data/lib/pio/type/ipv4_header.rb +37 -0
  39. data/lib/pio/type/mac_address.rb +7 -8
  40. data/lib/pio/util.rb +21 -0
  41. data/lib/pio/version.rb +2 -2
  42. data/lib/pio.rb +4 -4
  43. data/pio.gemspec +15 -17
  44. data/pio.org +499 -76
  45. data/pio.org_archive +86 -0
  46. data/rubocop-todo.yml +9 -0
  47. data/spec/pio/arp/reply_spec.rb +106 -118
  48. data/spec/pio/arp/request_spec.rb +90 -101
  49. data/spec/pio/arp_spec.rb +105 -113
  50. data/spec/pio/icmp/reply_spec.rb +132 -0
  51. data/spec/pio/icmp/request_spec.rb +131 -0
  52. data/spec/pio/icmp_spec.rb +159 -0
  53. data/spec/pio/ipv4_address_spec.rb +87 -97
  54. data/spec/pio/lldp_spec.rb +237 -186
  55. data/spec/pio/mac_spec.rb +82 -93
  56. data/spec/spec_helper.rb +10 -13
  57. metadata +20 -2
data/pio.org_archive CHANGED
@@ -855,3 +855,89 @@ CLOSED: [2013-10-10 木 13:41] SCHEDULED: <2013-10-04 金>
855
855
  :ARCHIVE_ITAGS: PIO
856
856
  :END:
857
857
  [2013-10-04 金 08:46]
858
+
859
+ ** DONE git パスワードを省略できるように
860
+ CLOSED: [2013-11-08 金 10:54]
861
+ :PROPERTIES:
862
+ :ID: 02BD00DD-6C97-4F3E-832A-A468ABC4A222
863
+ :ARCHIVE_TIME: 2013-11-08 金 11:02
864
+ :ARCHIVE_FILE: ~/play/pio/pio.org
865
+ :ARCHIVE_OLPATH: Tasks
866
+ :ARCHIVE_CATEGORY: pio
867
+ :ARCHIVE_TODO: DONE
868
+ :ARCHIVE_ITAGS: PIO
869
+ :END:
870
+ [2013-09-13 金 17:07]
871
+
872
+ ** DONE 0.2.2 リリース
873
+ CLOSED: [2013-09-26 木 15:34]
874
+ :LOGBOOK:
875
+ CLOCK: [2013-09-19 木 14:29]--[2013-09-19 木 16:39] => 2:10
876
+ :END:
877
+ :PROPERTIES:
878
+ :ARCHIVE_TIME: 2013-11-11 月 09:43
879
+ :ARCHIVE_FILE: ~/play/pio/pio.org
880
+ :ARCHIVE_OLPATH: Releases
881
+ :ARCHIVE_CATEGORY: pio
882
+ :ARCHIVE_TODO: DONE
883
+ :ARCHIVE_ITAGS: PIO
884
+ :END:
885
+ [2013-09-19 木 14:17]
886
+ *** DONE IP -> IPv4Address
887
+ SCHEDULED: <2013-09-26 木>
888
+ [2013-09-26 木 13:33]
889
+ *** DONE 鈴木さんの IPv4Address への PR を Pio へ誘導
890
+ CLOSED: [2013-09-19 木 14:29] SCHEDULED: <2013-09-19 木>
891
+ :LOGBOOK:
892
+ CLOCK: [2013-09-19 木 14:27]--[2013-09-19 木 14:29] => 0:02
893
+ :END:
894
+ - State "TODO" from "WAITING" [2013-09-19 木 14:18]
895
+ - State "WAITING" from "TODO" [2013-09-18 水 12:05] \\
896
+ 0.2.0 をリリースしてから。
897
+ [2013-09-14 土 10:22]
898
+
899
+ 鈴木さんが trema-edge に出している PR はこちら
900
+ https://github.com/trema/trema-edge/pull/22
901
+
902
+ コメントしておいた。
903
+ https://github.com/trema/trema-edge/pull/22#issuecomment-24717877
904
+ *** DONE チケットを切ったことを鈴木さんに確認
905
+ CLOSED: [2013-09-24 火 20:57] SCHEDULED: <2013-09-24 火 13:45>
906
+ :PROPERTIES:
907
+ :Effort: 0:05
908
+ :END:
909
+ [2013-09-20 金 09:26]
910
+
911
+ ** DONE 0.2.3 リリース
912
+ CLOSED: [2013-09-26 木 15:35]
913
+ :PROPERTIES:
914
+ :ARCHIVE_TIME: 2013-11-11 月 09:43
915
+ :ARCHIVE_FILE: ~/play/pio/pio.org
916
+ :ARCHIVE_OLPATH: Releases
917
+ :ARCHIVE_CATEGORY: pio
918
+ :ARCHIVE_TODO: DONE
919
+ :ARCHIVE_ITAGS: PIO
920
+ :END:
921
+ [2013-09-26 木 15:34]
922
+ *** DONE Trema への組込み
923
+ CLOSED: [2013-09-26 木 15:35]
924
+ [2013-09-26 木 15:35]
925
+ *** DONE gem の命名規則に合わせる
926
+ CLOSED: [2013-09-26 木 08:28] SCHEDULED: <2013-09-26 木>
927
+ :LOGBOOK:
928
+ CLOCK: [2013-09-26 木 08:20]--[2013-09-26 木 08:28] => 0:08
929
+ CLOCK: [2013-09-26 木 08:05]--[2013-09-26 木 08:06] => 0:01
930
+ :END:
931
+ :PROPERTIES:
932
+ :Effort: 0:30
933
+ :END:
934
+ [2013-09-26 木 08:05]
935
+ *** DONE 明示的に spec_helper.rb をロードしてる部分をなくす
936
+ CLOSED: [2013-09-26 木 08:18] SCHEDULED: <2013-09-26 木>
937
+ :LOGBOOK:
938
+ CLOCK: [2013-09-26 木 08:14]--[2013-09-26 木 08:15] => 0:01
939
+ :END:
940
+ :PROPERTIES:
941
+ :Effort: 0:30
942
+ :END:
943
+ [2013-09-26 木 08:14]
data/rubocop-todo.yml ADDED
@@ -0,0 +1,9 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`.
2
+ # The point is for the user to remove these configuration records
3
+ # one by one as the offences are removed from the code base.
4
+
5
+ HashSyntax:
6
+ EnforcedStyle: hash_rockets
7
+
8
+ Lambda:
9
+ Enabled: false
@@ -1,147 +1,135 @@
1
- require "pio/arp/reply"
2
-
3
-
4
- module Pio
5
- class Arp
6
- describe Reply do
7
- context ".new" do
8
- subject {
9
- Arp::Reply.new(
10
- :source_mac => source_mac,
11
- :destination_mac => destination_mac,
12
- :sender_protocol_address => sender_protocol_address,
13
- :target_protocol_address => target_protocol_address
14
- )
15
- }
16
-
17
- let( :arp_reply_dump ) {
18
- [
19
- 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # destination mac address
20
- 0x00, 0x16, 0x9d, 0x1d, 0x9c, 0xc4, # source mac address
21
- 0x08, 0x06, # ethernet type
22
- 0x00, 0x01, # arp hardware type
23
- 0x08, 0x00, # arp protocol type
24
- 0x06, # hardware address size
25
- 0x04, # protocol address size
26
- 0x00, 0x02, # operational code
27
- 0x00, 0x16, 0x9d, 0x1d, 0x9c, 0xc4, # sender hardware address
28
- 0xc0, 0xa8, 0x53, 0xfe, # sender protocol address
29
- 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # target hardware address
30
- 0xc0, 0xa8, 0x53, 0x03, # target protocol address
31
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # padding
32
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34
- 0x00, 0x00, 0x00, 0x00,
35
- ].pack( "C*" )
36
- }
37
-
38
-
39
- context "with Integer MAC and IP address" do
40
- let( :source_mac ) { 0x00169d1d9cc4 }
41
- let( :destination_mac ) { 0x002682ebead1 }
42
- let( :sender_protocol_address ) { 0xc0a853fe }
43
- let( :target_protocol_address ) { 0xc0a85303 }
44
-
45
- context "#to_binary" do
46
- it "returns an Arp Reply binary String" do
47
- expect( subject.to_binary ).to eq arp_reply_dump
48
- end
49
-
50
- it "returns a valid ether frame with size = 64" do
51
- expect( subject.to_binary.size ).to eq 64
52
- end
53
- end
54
- end
55
-
1
+ # -*- coding: utf-8 -*-
2
+ require 'pio/arp/reply'
3
+
4
+ describe Pio::Arp::Reply do
5
+ context '.new' do
6
+ subject do
7
+ Pio::Arp::Reply.new(
8
+ :source_mac => source_mac,
9
+ :destination_mac => destination_mac,
10
+ :sender_protocol_address => sender_protocol_address,
11
+ :target_protocol_address => target_protocol_address
12
+ )
13
+ end
56
14
 
57
- context "with String MAC and Integer IP address" do
58
- let( :source_mac ) { "00:16:9d:1d:9c:c4" }
59
- let( :destination_mac ) { "00:26:82:eb:ea:d1" }
60
- let( :sender_protocol_address ) { 0xc0a853fe }
61
- let( :target_protocol_address ) { 0xc0a85303 }
15
+ let(:arp_reply_dump) do
16
+ [
17
+ 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # destination mac address
18
+ 0x00, 0x16, 0x9d, 0x1d, 0x9c, 0xc4, # source mac address
19
+ 0x08, 0x06, # ethernet type
20
+ 0x00, 0x01, # arp hardware type
21
+ 0x08, 0x00, # arp protocol type
22
+ 0x06, # hardware address size
23
+ 0x04, # protocol address size
24
+ 0x00, 0x02, # operational code
25
+ 0x00, 0x16, 0x9d, 0x1d, 0x9c, 0xc4, # sender hardware address
26
+ 0xc0, 0xa8, 0x53, 0xfe, # sender protocol address
27
+ 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # target hardware address
28
+ 0xc0, 0xa8, 0x53, 0x03, # target protocol address
29
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # padding
30
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32
+ 0x00, 0x00, 0x00, 0x00,
33
+ ].pack('C*')
34
+ end
62
35
 
63
- context "#to_binary" do
64
- it "returns an Arp Reply binary String" do
65
- expect( subject.to_binary ).to eq arp_reply_dump
66
- end
36
+ context 'with Integer MAC and IP address' do
37
+ let(:source_mac) { 0x00169d1d9cc4 }
38
+ let(:destination_mac) { 0x002682ebead1 }
39
+ let(:sender_protocol_address) { 0xc0a853fe }
40
+ let(:target_protocol_address) { 0xc0a85303 }
67
41
 
68
- it "returns a valid ether frame with size = 64" do
69
- expect( subject.to_binary.size ).to eq 64
70
- end
71
- end
42
+ context '#to_binary' do
43
+ it 'returns an Arp Reply binary String' do
44
+ expect(subject.to_binary).to eq arp_reply_dump
72
45
  end
73
46
 
47
+ it 'returns a valid ether frame with size = 64' do
48
+ expect(subject.to_binary.size).to eq 64
49
+ end
50
+ end
51
+ end
74
52
 
75
- context "when Integer MAC and String IP address" do
76
- let( :source_mac ) { 0x00169d1d9cc4 }
77
- let( :destination_mac ) { 0x002682ebead1 }
78
- let( :sender_protocol_address ) { "192.168.83.254" }
79
- let( :target_protocol_address ) { "192.168.83.3" }
80
-
81
- context "#to_binary" do
82
- it "returns an Arp Reply binary String" do
83
- expect( subject.to_binary ).to eq arp_reply_dump
84
- end
53
+ context 'with String MAC and Integer IP address' do
54
+ let(:source_mac) { '00:16:9d:1d:9c:c4' }
55
+ let(:destination_mac) { '00:26:82:eb:ea:d1' }
56
+ let(:sender_protocol_address) { 0xc0a853fe }
57
+ let(:target_protocol_address) { 0xc0a85303 }
85
58
 
86
- it "returns a valid ether frame with size = 64" do
87
- expect( subject.to_binary.size ).to eq 64
88
- end
89
- end
59
+ context '#to_binary' do
60
+ it 'returns an Arp Reply binary String' do
61
+ expect(subject.to_binary).to eq arp_reply_dump
90
62
  end
91
63
 
64
+ it 'returns a valid ether frame with size = 64' do
65
+ expect(subject.to_binary.size).to eq 64
66
+ end
67
+ end
68
+ end
92
69
 
93
- context "when :source_mac is not set" do
94
- let( :source_mac ) { nil }
95
- let( :destination_mac ) { 0x002682ebead1 }
96
- let( :sender_protocol_address ) { "192.168.83.3" }
97
- let( :target_protocol_address ) { "192.168.83.254" }
70
+ context 'when Integer MAC and String IP address' do
71
+ let(:source_mac) { 0x00169d1d9cc4 }
72
+ let(:destination_mac) { 0x002682ebead1 }
73
+ let(:sender_protocol_address) { '192.168.83.254' }
74
+ let(:target_protocol_address) { '192.168.83.3' }
98
75
 
99
- it "raises an invalid MAC address error" do
100
- expect { subject }.to raise_error( "Invalid MAC address: nil" )
101
- end
76
+ context '#to_binary' do
77
+ it 'returns an Arp Reply binary String' do
78
+ expect(subject.to_binary).to eq arp_reply_dump
102
79
  end
103
80
 
81
+ it 'returns a valid ether frame with size = 64' do
82
+ expect(subject.to_binary.size).to eq 64
83
+ end
84
+ end
85
+ end
104
86
 
105
- context "when :destination_mac is not set" do
106
- let( :source_mac ) { 0x00169d1d9cc4 }
107
- let( :destination_mac ) { nil }
108
- let( :sender_protocol_address ) { "192.168.83.3" }
109
- let( :target_protocol_address ) { "192.168.83.254" }
87
+ context 'when :source_mac is not set' do
88
+ let(:source_mac) { nil }
89
+ let(:destination_mac) { 0x002682ebead1 }
90
+ let(:sender_protocol_address) { '192.168.83.3' }
91
+ let(:target_protocol_address) { '192.168.83.254' }
110
92
 
111
- it "raises an invalid MAC address error" do
112
- expect { subject }.to raise_error( "Invalid MAC address: nil" )
113
- end
114
- end
93
+ it 'raises an invalid MAC address error' do
94
+ expect { subject }.to raise_error('Invalid MAC address: nil')
95
+ end
96
+ end
115
97
 
98
+ context 'when :destination_mac is not set' do
99
+ let(:source_mac) { 0x00169d1d9cc4 }
100
+ let(:destination_mac) { nil }
101
+ let(:sender_protocol_address) { '192.168.83.3' }
102
+ let(:target_protocol_address) { '192.168.83.254' }
116
103
 
117
- context "when :sender_protocol_address is not set" do
118
- let( :source_mac ) { 0x00169d1d9cc4 }
119
- let( :destination_mac ) { 0x002682ebead1 }
120
- let( :sender_protocol_address ) { nil }
121
- let( :target_protocol_address ) { "192.168.83.254" }
104
+ it 'raises an invalid MAC address error' do
105
+ expect { subject }.to raise_error('Invalid MAC address: nil')
106
+ end
107
+ end
122
108
 
123
- it "raises an invalid IPv4 address error" do
124
- expect { subject }.to raise_error( "Invalid IPv4 address: nil" )
125
- end
126
- end
109
+ context 'when :sender_protocol_address is not set' do
110
+ let(:source_mac) { 0x00169d1d9cc4 }
111
+ let(:destination_mac) { 0x002682ebead1 }
112
+ let(:sender_protocol_address) { nil }
113
+ let(:target_protocol_address) { '192.168.83.254' }
127
114
 
115
+ it 'raises an invalid IPv4 address error' do
116
+ expect { subject }.to raise_error('Invalid IPv4 address: nil')
117
+ end
118
+ end
128
119
 
129
- context "when :target_protocol_address is not set" do
130
- let( :source_mac ) { 0x00169d1d9cc4 }
131
- let( :destination_mac ) { 0x002682ebead1 }
132
- let( :sender_protocol_address ) { "192.168.83.3" }
133
- let( :target_protocol_address ) { nil }
120
+ context 'when :target_protocol_address is not set' do
121
+ let(:source_mac) { 0x00169d1d9cc4 }
122
+ let(:destination_mac) { 0x002682ebead1 }
123
+ let(:sender_protocol_address) { '192.168.83.3' }
124
+ let(:target_protocol_address) { nil }
134
125
 
135
- it "raises an invalid IPv4 address error" do
136
- expect { subject }.to raise_error( "Invalid IPv4 address: nil" )
137
- end
138
- end
126
+ it 'raises an invalid IPv4 address error' do
127
+ expect { subject }.to raise_error('Invalid IPv4 address: nil')
139
128
  end
140
129
  end
141
130
  end
142
131
  end
143
132
 
144
-
145
133
  ### Local variables:
146
134
  ### mode: Ruby
147
135
  ### coding: utf-8-unix
@@ -1,128 +1,117 @@
1
- require "pio/arp/request"
2
-
3
-
4
- module Pio
5
- class Arp
6
- describe Request do
7
- context ".new" do
8
- subject {
9
- Arp::Request.new(
10
- :source_mac => source_mac,
11
- :sender_protocol_address => sender_protocol_address,
12
- :target_protocol_address => target_protocol_address
13
- )
14
- }
15
-
16
- let( :arp_request_dump ) {
17
- [
18
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, # destination mac address
19
- 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # source mac address
20
- 0x08, 0x06, # ethernet type
21
- 0x00, 0x01, # arp hardware type
22
- 0x08, 0x00, # arp protocol type
23
- 0x06, # hardware address size
24
- 0x04, # protocol address size
25
- 0x00, 0x01, # operational code
26
- 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # sender hardware address
27
- 0xc0, 0xa8, 0x53, 0x03, # sender protocol address
28
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # target hardware address
29
- 0xc0, 0xa8, 0x53, 0xfe, # target protocol address
30
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # padding
31
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33
- 0x00, 0x00, 0x00, 0x00,
34
- ].pack( "C*" )
35
- }
36
-
37
-
38
- context "with Integer MAC and IP address" do
39
- let( :source_mac ) { 0x002682ebead1 }
40
- let( :sender_protocol_address ) { 0xc0a85303 }
41
- let( :target_protocol_address ) { 0xc0a853fe }
42
-
43
- context "#to_binary" do
44
- it "returns an Arp Request binary String" do
45
- expect( subject.to_binary ).to eq arp_request_dump
46
- end
47
-
48
- it "returns a valid ether frame with size = 64" do
49
- expect( subject.to_binary.size ).to eq 64
50
- end
51
- end
52
- end
53
-
1
+ # -*- coding: utf-8 -*-
2
+ require 'pio/arp/request'
3
+
4
+ describe Pio::Arp::Request do
5
+ context '.new' do
6
+ subject do
7
+ Pio::Arp::Request.new(
8
+ :source_mac => source_mac,
9
+ :sender_protocol_address => sender_protocol_address,
10
+ :target_protocol_address => target_protocol_address
11
+ )
12
+ end
54
13
 
55
- context "with String MAC and IP address" do
56
- let( :source_mac ) { "00:26:82:eb:ea:d1" }
57
- let( :sender_protocol_address ) { 0xc0a85303 }
58
- let( :target_protocol_address ) { 0xc0a853fe }
14
+ let(:arp_request_dump) do
15
+ [
16
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, # destination mac address
17
+ 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # source mac address
18
+ 0x08, 0x06, # ethernet type
19
+ 0x00, 0x01, # arp hardware type
20
+ 0x08, 0x00, # arp protocol type
21
+ 0x06, # hardware address size
22
+ 0x04, # protocol address size
23
+ 0x00, 0x01, # operational code
24
+ 0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # sender hardware address
25
+ 0xc0, 0xa8, 0x53, 0x03, # sender protocol address
26
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # target hardware address
27
+ 0xc0, 0xa8, 0x53, 0xfe, # target protocol address
28
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # padding
29
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31
+ 0x00, 0x00, 0x00, 0x00,
32
+ ].pack('C*')
33
+ end
59
34
 
60
- context "#to_binary" do
61
- it "returns an Arp Request binary String" do
62
- expect( subject.to_binary ).to eq arp_request_dump
63
- end
35
+ context 'with Integer MAC and IP address' do
36
+ let(:source_mac) { 0x002682ebead1 }
37
+ let(:sender_protocol_address) { 0xc0a85303 }
38
+ let(:target_protocol_address) { 0xc0a853fe }
64
39
 
65
- it "returns a valid ether frame with size = 64" do
66
- expect( subject.to_binary.size ).to eq 64
67
- end
68
- end
40
+ context '#to_binary' do
41
+ it 'returns an Arp Request binary String' do
42
+ expect(subject.to_binary).to eq arp_request_dump
69
43
  end
70
44
 
45
+ it 'returns a valid ether frame with size = 64' do
46
+ expect(subject.to_binary.size).to eq 64
47
+ end
48
+ end
49
+ end
71
50
 
72
- context "with Integer MAC and String IP address" do
73
- let( :source_mac ) { 0x002682ebead1 }
74
- let( :sender_protocol_address ) { "192.168.83.3" }
75
- let( :target_protocol_address ) { "192.168.83.254" }
51
+ context 'with String MAC and IP address' do
52
+ let(:source_mac) { '00:26:82:eb:ea:d1' }
53
+ let(:sender_protocol_address) { 0xc0a85303 }
54
+ let(:target_protocol_address) { 0xc0a853fe }
76
55
 
77
- context "#to_binary" do
78
- it "returns an Arp Request binary String" do
79
- expect( subject.to_binary ).to eq arp_request_dump
80
- end
56
+ context '#to_binary' do
57
+ it 'returns an Arp Request binary String' do
58
+ expect(subject.to_binary).to eq arp_request_dump
59
+ end
81
60
 
82
- it "returns a valid ether frame with size = 64" do
83
- expect( subject.to_binary.size ).to eq 64
84
- end
85
- end
61
+ it 'returns a valid ether frame with size = 64' do
62
+ expect(subject.to_binary.size).to eq 64
86
63
  end
64
+ end
65
+ end
87
66
 
67
+ context 'with Integer MAC and String IP address' do
68
+ let(:source_mac) { 0x002682ebead1 }
69
+ let(:sender_protocol_address) { '192.168.83.3' }
70
+ let(:target_protocol_address) { '192.168.83.254' }
88
71
 
89
- context "when :source_mac is not set" do
90
- let( :source_mac ) { nil }
91
- let( :sender_protocol_address ) { "192.168.83.3" }
92
- let( :target_protocol_address ) { "192.168.83.254" }
72
+ context '#to_binary' do
73
+ it 'returns an Arp Request binary String' do
74
+ expect(subject.to_binary).to eq arp_request_dump
75
+ end
93
76
 
94
- it "raises an invalid MAC address error" do
95
- expect { subject }.to raise_error( "Invalid MAC address: nil" )
96
- end
77
+ it 'returns a valid ether frame with size = 64' do
78
+ expect(subject.to_binary.size).to eq 64
97
79
  end
80
+ end
81
+ end
98
82
 
83
+ context 'when :source_mac is not set' do
84
+ let(:source_mac) { nil }
85
+ let(:sender_protocol_address) { '192.168.83.3' }
86
+ let(:target_protocol_address) { '192.168.83.254' }
99
87
 
100
- context "when :sender_protocol_address is not set" do
101
- let( :source_mac ) { 0x002682ebead1 }
102
- let( :sender_protocol_address ) { nil }
103
- let( :target_protocol_address ) { "192.168.83.254" }
88
+ it 'raises an invalid MAC address error' do
89
+ expect { subject }.to raise_error('Invalid MAC address: nil')
90
+ end
91
+ end
104
92
 
105
- it "raises an invalid IPv4 address error" do
106
- expect { subject }.to raise_error( "Invalid IPv4 address: nil" )
107
- end
108
- end
93
+ context 'when :sender_protocol_address is not set' do
94
+ let(:source_mac) { 0x002682ebead1 }
95
+ let(:sender_protocol_address) { nil }
96
+ let(:target_protocol_address) { '192.168.83.254' }
109
97
 
98
+ it 'raises an invalid IPv4 address error' do
99
+ expect { subject }.to raise_error('Invalid IPv4 address: nil')
100
+ end
101
+ end
110
102
 
111
- context "when :target_protocol_address is not set" do
112
- let( :source_mac ) { 0x002682ebead1 }
113
- let( :sender_protocol_address ) { "192.168.83.254" }
114
- let( :target_protocol_address ) { nil }
103
+ context 'when :target_protocol_address is not set' do
104
+ let(:source_mac) { 0x002682ebead1 }
105
+ let(:sender_protocol_address) { '192.168.83.254' }
106
+ let(:target_protocol_address) { nil }
115
107
 
116
- it "raises an invalid IPv4 address error" do
117
- expect { subject }.to raise_error( "Invalid IPv4 address: nil" )
118
- end
119
- end
108
+ it 'raises an invalid IPv4 address error' do
109
+ expect { subject }.to raise_error('Invalid IPv4 address: nil')
120
110
  end
121
111
  end
122
112
  end
123
113
  end
124
114
 
125
-
126
115
  ### Local variables:
127
116
  ### mode: Ruby
128
117
  ### coding: utf-8-unix