ronin-support 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -1
  6. data/ChangeLog.md +28 -0
  7. data/Gemfile +6 -7
  8. data/README.md +53 -32
  9. data/Rakefile +1 -2
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +5 -5
  12. data/lib/ronin/binary/hexdump.rb +5 -5
  13. data/lib/ronin/binary/hexdump/parser.rb +5 -5
  14. data/lib/ronin/binary/struct.rb +5 -5
  15. data/lib/ronin/binary/template.rb +7 -7
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +37 -31
  19. data/lib/ronin/extensions/ip_addr.rb +6 -7
  20. data/lib/ronin/extensions/kernel.rb +5 -5
  21. data/lib/ronin/extensions/meta.rb +5 -5
  22. data/lib/ronin/extensions/regexp.rb +5 -5
  23. data/lib/ronin/extensions/resolv.rb +5 -5
  24. data/lib/ronin/extensions/string.rb +5 -5
  25. data/lib/ronin/formatting.rb +5 -5
  26. data/lib/ronin/formatting/binary.rb +5 -5
  27. data/lib/ronin/formatting/digest.rb +5 -5
  28. data/lib/ronin/formatting/extensions.rb +5 -5
  29. data/lib/ronin/formatting/extensions/binary.rb +5 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
  32. data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
  33. data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
  35. data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
  36. data/lib/ronin/formatting/extensions/digest.rb +5 -5
  37. data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
  38. data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
  39. data/lib/ronin/formatting/extensions/html.rb +5 -5
  40. data/lib/ronin/formatting/extensions/html/integer.rb +5 -5
  41. data/lib/ronin/formatting/extensions/html/string.rb +7 -7
  42. data/lib/ronin/formatting/extensions/http.rb +5 -5
  43. data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
  44. data/lib/ronin/formatting/extensions/http/string.rb +7 -7
  45. data/lib/ronin/formatting/extensions/sql.rb +5 -5
  46. data/lib/ronin/formatting/extensions/sql/string.rb +15 -13
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +5 -5
  49. data/lib/ronin/formatting/extensions/text/string.rb +5 -5
  50. data/lib/ronin/formatting/html.rb +5 -5
  51. data/lib/ronin/formatting/http.rb +5 -5
  52. data/lib/ronin/formatting/sql.rb +5 -5
  53. data/lib/ronin/formatting/text.rb +5 -5
  54. data/lib/ronin/fuzzing.rb +5 -5
  55. data/lib/ronin/fuzzing/extensions.rb +5 -5
  56. data/lib/ronin/fuzzing/extensions/string.rb +5 -5
  57. data/lib/ronin/fuzzing/fuzzer.rb +5 -5
  58. data/lib/ronin/fuzzing/fuzzing.rb +7 -7
  59. data/lib/ronin/fuzzing/mutator.rb +5 -5
  60. data/lib/ronin/fuzzing/repeater.rb +5 -5
  61. data/lib/ronin/fuzzing/template.rb +5 -5
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +5 -5
  64. data/lib/ronin/network/dns.rb +5 -5
  65. data/lib/ronin/network/esmtp.rb +5 -5
  66. data/lib/ronin/network/extensions.rb +5 -5
  67. data/lib/ronin/network/extensions/dns.rb +5 -5
  68. data/lib/ronin/network/extensions/dns/net.rb +5 -5
  69. data/lib/ronin/network/extensions/esmtp.rb +5 -5
  70. data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
  71. data/lib/ronin/network/extensions/http.rb +5 -5
  72. data/lib/ronin/network/extensions/http/net.rb +5 -5
  73. data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
  74. data/lib/ronin/network/extensions/imap.rb +5 -5
  75. data/lib/ronin/network/extensions/imap/net.rb +5 -5
  76. data/lib/ronin/network/extensions/pop3.rb +5 -5
  77. data/lib/ronin/network/extensions/pop3/net.rb +5 -5
  78. data/lib/ronin/network/extensions/smtp.rb +5 -5
  79. data/lib/ronin/network/extensions/smtp/net.rb +5 -5
  80. data/lib/ronin/network/extensions/ssl.rb +5 -5
  81. data/lib/ronin/network/extensions/ssl/net.rb +5 -5
  82. data/lib/ronin/network/extensions/tcp.rb +5 -5
  83. data/lib/ronin/network/extensions/tcp/net.rb +5 -5
  84. data/lib/ronin/network/extensions/telnet.rb +5 -5
  85. data/lib/ronin/network/extensions/telnet/net.rb +5 -5
  86. data/lib/ronin/network/extensions/udp.rb +5 -5
  87. data/lib/ronin/network/extensions/udp/net.rb +5 -5
  88. data/lib/ronin/network/ftp.rb +5 -5
  89. data/lib/ronin/network/http.rb +5 -5
  90. data/lib/ronin/network/http/exceptions.rb +5 -5
  91. data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
  92. data/lib/ronin/network/http/http.rb +52 -57
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +5 -5
  95. data/lib/ronin/network/mixins.rb +5 -5
  96. data/lib/ronin/network/mixins/dns.rb +5 -5
  97. data/lib/ronin/network/mixins/esmtp.rb +5 -5
  98. data/lib/ronin/network/mixins/ftp.rb +5 -5
  99. data/lib/ronin/network/mixins/http.rb +7 -7
  100. data/lib/ronin/network/mixins/imap.rb +5 -5
  101. data/lib/ronin/network/mixins/mixin.rb +5 -5
  102. data/lib/ronin/network/mixins/pop3.rb +5 -5
  103. data/lib/ronin/network/mixins/smtp.rb +5 -5
  104. data/lib/ronin/network/mixins/ssl.rb +5 -5
  105. data/lib/ronin/network/mixins/tcp.rb +5 -5
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +5 -5
  108. data/lib/ronin/network/mixins/unix.rb +5 -5
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +5 -5
  111. data/lib/ronin/network/proxy.rb +5 -5
  112. data/lib/ronin/network/smtp.rb +5 -5
  113. data/lib/ronin/network/smtp/email.rb +6 -6
  114. data/lib/ronin/network/smtp/smtp.rb +5 -5
  115. data/lib/ronin/network/ssl.rb +7 -7
  116. data/lib/ronin/network/tcp.rb +5 -5
  117. data/lib/ronin/network/tcp/proxy.rb +5 -5
  118. data/lib/ronin/network/tcp/tcp.rb +32 -23
  119. data/lib/ronin/network/telnet.rb +7 -5
  120. data/lib/ronin/network/udp.rb +5 -5
  121. data/lib/ronin/network/udp/proxy.rb +5 -5
  122. data/lib/ronin/network/udp/udp.rb +28 -26
  123. data/lib/ronin/network/unix.rb +7 -7
  124. data/lib/ronin/path.rb +32 -36
  125. data/lib/ronin/spec/ui/output.rb +5 -5
  126. data/lib/ronin/support.rb +5 -5
  127. data/lib/ronin/support/inflector.rb +5 -5
  128. data/lib/ronin/support/support.rb +5 -5
  129. data/lib/ronin/support/version.rb +6 -6
  130. data/lib/ronin/templates.rb +5 -5
  131. data/lib/ronin/templates/erb.rb +5 -5
  132. data/lib/ronin/templates/template.rb +5 -5
  133. data/lib/ronin/ui/output.rb +5 -5
  134. data/lib/ronin/ui/output/helpers.rb +5 -5
  135. data/lib/ronin/ui/output/output.rb +17 -21
  136. data/lib/ronin/ui/output/terminal.rb +5 -5
  137. data/lib/ronin/ui/output/terminal/color.rb +5 -5
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +5 -5
  140. data/lib/ronin/wordlist.rb +7 -7
  141. data/ronin-support.gemspec +1 -0
  142. data/spec/binary/hexdump/parser_spec.rb +22 -22
  143. data/spec/binary/struct_spec.rb +56 -56
  144. data/spec/binary/template_spec.rb +106 -104
  145. data/spec/extensions/enumerable_spec.rb +4 -4
  146. data/spec/extensions/file_spec.rb +12 -14
  147. data/spec/extensions/ip_addr_spec.rb +30 -30
  148. data/spec/extensions/kernel_spec.rb +7 -7
  149. data/spec/extensions/regexp_spec.rb +69 -69
  150. data/spec/extensions/resolv_spec.rb +2 -2
  151. data/spec/extensions/string_spec.rb +30 -29
  152. data/spec/formatting/binary/array_spec.rb +2 -2
  153. data/spec/formatting/binary/base64_spec.rb +8 -8
  154. data/spec/formatting/binary/float_spec.rb +6 -4
  155. data/spec/formatting/binary/integer_spec.rb +25 -25
  156. data/spec/formatting/binary/string_spec.rb +32 -30
  157. data/spec/formatting/digest/string_spec.rb +5 -5
  158. data/spec/formatting/html/integer_spec.rb +6 -6
  159. data/spec/formatting/html/string_spec.rb +10 -10
  160. data/spec/formatting/http/integer_spec.rb +3 -3
  161. data/spec/formatting/http/string_spec.rb +5 -5
  162. data/spec/formatting/sql/string_spec.rb +21 -19
  163. data/spec/formatting/text/array_spec.rb +15 -15
  164. data/spec/formatting/text/string_spec.rb +33 -33
  165. data/spec/fuzzing/extensions/string_spec.rb +11 -11
  166. data/spec/fuzzing/fuzzer_spec.rb +15 -15
  167. data/spec/fuzzing/fuzzing_spec.rb +5 -5
  168. data/spec/fuzzing/mutator_spec.rb +15 -15
  169. data/spec/fuzzing/repeater_spec.rb +7 -7
  170. data/spec/fuzzing/template_spec.rb +11 -11
  171. data/spec/mixin_spec.rb +10 -12
  172. data/spec/network/dns_spec.rb +34 -32
  173. data/spec/network/ftp_spec.rb +9 -9
  174. data/spec/network/http/http_spec.rb +237 -144
  175. data/spec/network/http/proxy_spec.rb +37 -37
  176. data/spec/network/network_spec.rb +1 -1
  177. data/spec/network/proxy_spec.rb +19 -19
  178. data/spec/network/smtp/email_spec.rb +14 -14
  179. data/spec/network/ssl_spec.rb +9 -9
  180. data/spec/network/tcp/proxy_spec.rb +9 -7
  181. data/spec/network/tcp/tcp_spec.rb +161 -118
  182. data/spec/network/telnet_spec.rb +5 -5
  183. data/spec/network/udp/udp_spec.rb +123 -96
  184. data/spec/network/unix_spec.rb +24 -25
  185. data/spec/path_spec.rb +43 -18
  186. data/spec/spec_helper.rb +0 -1
  187. data/spec/support/inflector_spec.rb +4 -4
  188. data/spec/support_spec.rb +1 -1
  189. data/spec/templates/erb_spec.rb +3 -3
  190. data/spec/templates/template_spec.rb +10 -10
  191. data/spec/ui/shell_spec.rb +15 -15
  192. data/spec/wordlist_spec.rb +19 -19
  193. metadata +408 -366
  194. data/.gemtest +0 -0
@@ -14,28 +14,28 @@ describe Binary::Struct do
14
14
  end
15
15
 
16
16
  it "should return the layout" do
17
- subject.class.layout.should == [
17
+ expect(subject.class.layout).to eq([
18
18
  :x,
19
19
  :y
20
- ]
20
+ ])
21
21
  end
22
22
 
23
23
  context "when given fields" do
24
24
  it "should populate fields" do
25
- subject.class.fields.should == {
25
+ expect(subject.class.fields).to eq({
26
26
  :x => [:uint, nil],
27
27
  :y => [:uint, nil]
28
- }
28
+ })
29
29
  end
30
30
 
31
31
  it "should define reader methods" do
32
- subject.should respond_to(:x)
33
- subject.should respond_to(:y)
32
+ expect(subject).to respond_to(:x)
33
+ expect(subject).to respond_to(:y)
34
34
  end
35
35
 
36
36
  it "should define writer methods" do
37
- subject.should respond_to(:x=)
38
- subject.should respond_to(:y=)
37
+ expect(subject).to respond_to(:x=)
38
+ expect(subject).to respond_to(:y=)
39
39
  end
40
40
  end
41
41
  end
@@ -48,8 +48,8 @@ describe Binary::Struct do
48
48
  end
49
49
 
50
50
  it "should determine if fields exist" do
51
- subject.field?(:x).should == true
52
- subject.field?(:foo).should == false
51
+ expect(subject.field?(:x)).to be(true)
52
+ expect(subject.field?(:foo)).to be(false)
53
53
  end
54
54
  end
55
55
 
@@ -61,14 +61,14 @@ describe Binary::Struct do
61
61
  end
62
62
 
63
63
  it "should return the endianness of the Struct" do
64
- subject.endian.should == :little
64
+ expect(subject.endian).to eq(:little)
65
65
  end
66
66
 
67
67
  context "when given an argument" do
68
68
  it "should set the endianness" do
69
69
  subject.endian :big
70
70
 
71
- subject.endian.should == :big
71
+ expect(subject.endian).to eq(:big)
72
72
  end
73
73
  end
74
74
  end
@@ -87,11 +87,11 @@ describe Binary::Struct do
87
87
  end
88
88
 
89
89
  it "should register a new type in typedefs" do
90
- subject.typedefs.should have_key(:test_t)
90
+ expect(subject.typedefs).to have_key(:test_t)
91
91
  end
92
92
 
93
93
  it "should resolve the existing type" do
94
- subject.typedefs[:test_t].should == :uint32
94
+ expect(subject.typedefs[:test_t]).to eq(:uint32)
95
95
  end
96
96
  end
97
97
 
@@ -119,40 +119,40 @@ describe Binary::Struct do
119
119
  end
120
120
 
121
121
  it "should set integers to 0" do
122
- subject[:int].should == 0
122
+ expect(subject[:int]).to eq(0)
123
123
  end
124
124
 
125
125
  it "should set arrays of integers to [0, ...]" do
126
- subject[:int_array].should == [0, 0]
126
+ expect(subject[:int_array]).to eq([0, 0])
127
127
  end
128
128
 
129
129
  it "should set floats to 0.0" do
130
- subject[:float].should == 0.0
130
+ expect(subject[:float]).to eq(0.0)
131
131
  end
132
132
 
133
133
  it "should set arrays of floats to [0.0, ...]" do
134
- subject[:float_array].should == [0.0, 0.0]
134
+ expect(subject[:float_array]).to eq([0.0, 0.0])
135
135
  end
136
136
 
137
137
  it "should set chars to '\\0'" do
138
- subject[:char].should == "\0"
138
+ expect(subject[:char]).to eq("\0")
139
139
  end
140
140
 
141
141
  it "should set arrays of chars to ''" do
142
- subject[:char_array].should == ''
142
+ expect(subject[:char_array]).to eq('')
143
143
  end
144
144
 
145
145
  it "should set strings to ''" do
146
- subject[:string].should == ''
146
+ expect(subject[:string]).to eq('')
147
147
  end
148
148
 
149
149
  it "should initialize nested structs" do
150
- subject[:struct][:int].should == 0
150
+ expect(subject[:struct][:int]).to eq(0)
151
151
  end
152
152
 
153
153
  it "should initialize arrays of nested structs" do
154
- subject[:struct_array][0][:int].should == 0
155
- subject[:struct_array][1][:int].should == 0
154
+ expect(subject[:struct_array][0][:int]).to eq(0)
155
+ expect(subject[:struct_array][1][:int]).to eq(0)
156
156
  end
157
157
  end
158
158
 
@@ -167,24 +167,24 @@ describe Binary::Struct do
167
167
  struct.new
168
168
  end
169
169
 
170
- before(:all) do
170
+ before do
171
171
  subject.instance_variable_set('@x',10)
172
172
  end
173
173
 
174
174
  it "should access the instance variable" do
175
- subject[:x].should == 10
175
+ expect(subject[:x]).to eq(10)
176
176
  end
177
177
 
178
178
  it "should still call the underlying reader method" do
179
- subject.should_receive(:x).and_return(10)
179
+ expect(subject).to receive(:x).and_return(10)
180
180
 
181
181
  subject[:x]
182
182
  end
183
183
 
184
184
  it "should raise ArgumentError for unknown fields" do
185
- lambda {
185
+ expect {
186
186
  subject[:foo]
187
- }.should raise_error(ArgumentError)
187
+ }.to raise_error(ArgumentError)
188
188
  end
189
189
  end
190
190
 
@@ -199,26 +199,26 @@ describe Binary::Struct do
199
199
  struct.new
200
200
  end
201
201
 
202
- before(:each) do
202
+ before do
203
203
  subject.instance_variable_set('@x',0)
204
204
  end
205
205
 
206
206
  it "should set the underlying instance variable" do
207
207
  subject[:x] = 20
208
208
 
209
- subject.instance_variable_get('@x').should == 20
209
+ expect(subject.instance_variable_get('@x')).to eq(20)
210
210
  end
211
211
 
212
212
  it "should still call the underlying writer method" do
213
- subject.should_receive(:x=).with(20)
213
+ expect(subject).to receive(:x=).with(20)
214
214
 
215
215
  subject[:x] = 20
216
216
  end
217
217
 
218
218
  it "should raise ArgumentError for unknown fields" do
219
- lambda {
219
+ expect {
220
220
  subject[:foo] = 20
221
- }.should raise_error(ArgumentError)
221
+ }.to raise_error(ArgumentError)
222
222
  end
223
223
  end
224
224
 
@@ -236,13 +236,13 @@ describe Binary::Struct do
236
236
  struct.new
237
237
  end
238
238
 
239
- before(:each) do
239
+ before do
240
240
  subject.x = x
241
241
  subject.y = y
242
242
  end
243
243
 
244
244
  it "should return the values of the fields" do
245
- subject.values.should == [x, y]
245
+ expect(subject.values).to eq([x, y])
246
246
  end
247
247
 
248
248
  context "nested structs" do
@@ -264,12 +264,12 @@ describe Binary::Struct do
264
264
  struct.new
265
265
  end
266
266
 
267
- before(:each) do
267
+ before do
268
268
  subject.z.int = z
269
269
  end
270
270
 
271
271
  it "should nest the values of nested structs" do
272
- subject.values.should == [x, y, [z]]
272
+ expect(subject.values).to eq([x, y, [z]])
273
273
  end
274
274
  end
275
275
 
@@ -292,13 +292,13 @@ describe Binary::Struct do
292
292
  struct.new
293
293
  end
294
294
 
295
- before(:each) do
295
+ before do
296
296
  subject.z[0].int = z
297
297
  subject.z[1].int = z
298
298
  end
299
299
 
300
300
  it "should nest the values of nested structs" do
301
- subject.values.should == [x, y, [[z], [z]]]
301
+ expect(subject.values).to eq([x, y, [[z], [z]]])
302
302
  end
303
303
  end
304
304
  end
@@ -320,7 +320,7 @@ describe Binary::Struct do
320
320
  struct.new
321
321
  end
322
322
 
323
- before(:all) do
323
+ before do
324
324
  subject.x = 100
325
325
  subject.y = 15.0
326
326
  subject.z.int = -1
@@ -329,12 +329,12 @@ describe Binary::Struct do
329
329
  end
330
330
 
331
331
  it "should reset fields to their default values" do
332
- subject.x.should == 0
333
- subject.y.should == 0.0
332
+ expect(subject.x).to eq(0)
333
+ expect(subject.y).to eq(0.0)
334
334
  end
335
335
 
336
336
  it "should reinitialize nested structs" do
337
- subject.z.int.should == 0
337
+ expect(subject.z.int).to eq(0)
338
338
  end
339
339
  end
340
340
 
@@ -352,12 +352,12 @@ describe Binary::Struct do
352
352
  struct.new
353
353
  end
354
354
 
355
- before(:each) do
355
+ before do
356
356
  subject.chars = string
357
357
  end
358
358
 
359
359
  it "should pack arrays of chars into a String" do
360
- subject.pack.should == packed
360
+ expect(subject.pack).to eq(packed)
361
361
  end
362
362
  end
363
363
 
@@ -379,13 +379,13 @@ describe Binary::Struct do
379
379
  struct.new
380
380
  end
381
381
 
382
- before(:each) do
382
+ before do
383
383
  subject.int = 10
384
384
  subject.struct.int = 20
385
385
  end
386
386
 
387
387
  it "should pack the nested struct fields" do
388
- subject.pack.should == packed
388
+ expect(subject.pack).to eq(packed)
389
389
  end
390
390
  end
391
391
 
@@ -407,14 +407,14 @@ describe Binary::Struct do
407
407
  struct.new
408
408
  end
409
409
 
410
- before(:each) do
410
+ before do
411
411
  subject.int = 10
412
412
  subject.struct[0].int = 20
413
413
  subject.struct[1].int = 30
414
414
  end
415
415
 
416
416
  it "should pack the nested fields" do
417
- subject.pack.should == packed
417
+ expect(subject.pack).to eq(packed)
418
418
  end
419
419
  end
420
420
  end
@@ -436,7 +436,7 @@ describe Binary::Struct do
436
436
  it "should unpack arrays of chars into a String" do
437
437
  subject.unpack(packed)
438
438
 
439
- subject.chars.should == string
439
+ expect(subject.chars).to eq(string)
440
440
  end
441
441
  end
442
442
 
@@ -461,8 +461,8 @@ describe Binary::Struct do
461
461
  it "should unpack the nested struct fields" do
462
462
  subject.unpack(packed)
463
463
 
464
- subject.int.should == 10
465
- subject.struct.int.should == 20
464
+ expect(subject.int).to eq(10)
465
+ expect(subject.struct.int).to eq(20)
466
466
  end
467
467
  end
468
468
 
@@ -487,9 +487,9 @@ describe Binary::Struct do
487
487
  it "should unpack the nested fields" do
488
488
  subject.unpack(packed)
489
489
 
490
- subject.int.should == 10
491
- subject.struct[0].int.should == 20
492
- subject.struct[1].int.should == 30
490
+ expect(subject.int).to eq(10)
491
+ expect(subject.struct[0].int).to eq(20)
492
+ expect(subject.struct[1].int).to eq(30)
493
493
  end
494
494
  end
495
495
  end
@@ -1,3 +1,5 @@
1
+ # encoding: US-ASCII
2
+
1
3
  require 'spec_helper'
2
4
  require 'ronin/binary/template'
3
5
 
@@ -5,71 +7,71 @@ describe Binary::Template do
5
7
  describe "TYPES" do
6
8
  subject { described_class::TYPES }
7
9
 
8
- it("uint8 => C") { subject[:uint8].should == 'C' }
9
- it("uint16 => S") { subject[:uint16].should == 'S' }
10
- it("uint32 => L") { subject[:uint32].should == 'L' }
11
- it("uint64 => Q") { subject[:uint64].should == 'Q' }
12
- it("int8 => C") { subject[:int8].should == 'c' }
13
- it("int16 => S") { subject[:int16].should == 's' }
14
- it("int32 => L") { subject[:int32].should == 'l' }
15
- it("int64 => Q") { subject[:int64].should == 'q' }
10
+ it("uint8 => C") { expect(subject[:uint8]).to eq('C' ) }
11
+ it("uint16 => S") { expect(subject[:uint16]).to eq('S' ) }
12
+ it("uint32 => L") { expect(subject[:uint32]).to eq('L' ) }
13
+ it("uint64 => Q") { expect(subject[:uint64]).to eq('Q' ) }
14
+ it("int8 => C") { expect(subject[:int8]).to eq('c' ) }
15
+ it("int16 => S") { expect(subject[:int16]).to eq('s' ) }
16
+ it("int32 => L") { expect(subject[:int32]).to eq('l' ) }
17
+ it("int64 => Q") { expect(subject[:int64]).to eq('q' ) }
16
18
  if RUBY_VERSION < '1.9.'
17
- it("uint16_le => v") { subject[:uint16_le].should == 'v' }
18
- it("uint32_le => V") { subject[:uint32_le].should == 'V' }
19
- it("uint16_be => n") { subject[:uint16_be].should == 'n' }
20
- it("uint32_be => N") { subject[:uint32_be].should == 'N' }
21
- end
22
- it("uchar => Z") { subject[:uchar].should == 'Z' }
23
- it("ushort => S!") { subject[:ushort].should == 'S!'}
24
- it("uint => I!") { subject[:uint].should == 'I!'}
25
- it("ulong => L!") { subject[:ulong].should == 'L!'}
26
- it("ulong_long => Q") { subject[:ulong_long].should == 'Q' }
27
- it("char => Z") { subject[:char].should == 'Z' }
28
- it("short => s!") { subject[:short].should == 's!'}
29
- it("int => i!") { subject[:int].should == 'i!'}
30
- it("long => l!") { subject[:long].should == 'l!'}
31
- it("long_long => q") { subject[:long_long].should == 'q' }
32
- it("utf8 => U") { subject[:utf8].should == 'U' }
33
- it("float => F") { subject[:float].should == 'F' }
34
- it("double => D") { subject[:double].should == 'D' }
35
- it("float_le => e") { subject[:float_le].should == 'e' }
36
- it("double_le => E") { subject[:double_le].should == 'E' }
37
- it("float_be => g") { subject[:float_be].should == 'g' }
38
- it("double_ge => G") { subject[:double_be].should == 'G' }
39
- it("ubyte => C") { subject[:ubyte].should == 'C' }
40
- it("byte => c") { subject[:byte].should == 'c' }
41
- it("string => Z*") { subject[:string].should == 'Z*'}
19
+ it("uint16_le => v") { expect(subject[:uint16_le]).to eq('v' ) }
20
+ it("uint32_le => V") { expect(subject[:uint32_le]).to eq('V' ) }
21
+ it("uint16_be => n") { expect(subject[:uint16_be]).to eq('n' ) }
22
+ it("uint32_be => N") { expect(subject[:uint32_be]).to eq('N' ) }
23
+ end
24
+ it("uchar => Z") { expect(subject[:uchar]).to eq('Z' ) }
25
+ it("ushort => S!") { expect(subject[:ushort]).to eq('S!') }
26
+ it("uint => I!") { expect(subject[:uint]).to eq('I!') }
27
+ it("ulong => L!") { expect(subject[:ulong]).to eq('L!') }
28
+ it("ulong_long => Q") { expect(subject[:ulong_long]).to eq('Q' ) }
29
+ it("char => Z") { expect(subject[:char]).to eq('Z' ) }
30
+ it("short => s!") { expect(subject[:short]).to eq('s!') }
31
+ it("int => i!") { expect(subject[:int]).to eq('i!') }
32
+ it("long => l!") { expect(subject[:long]).to eq('l!') }
33
+ it("long_long => q") { expect(subject[:long_long]).to eq('q' ) }
34
+ it("utf8 => U") { expect(subject[:utf8]).to eq('U' ) }
35
+ it("float => F") { expect(subject[:float]).to eq('F' ) }
36
+ it("double => D") { expect(subject[:double]).to eq('D' ) }
37
+ it("float_le => e") { expect(subject[:float_le]).to eq('e' ) }
38
+ it("double_le => E") { expect(subject[:double_le]).to eq('E' ) }
39
+ it("float_be => g") { expect(subject[:float_be]).to eq('g' ) }
40
+ it("double_ge => G") { expect(subject[:double_be]).to eq('G' ) }
41
+ it("ubyte => C") { expect(subject[:ubyte]).to eq('C' ) }
42
+ it("byte => c") { expect(subject[:byte]).to eq('c' ) }
43
+ it("string => Z*") { expect(subject[:string]).to eq('Z*') }
42
44
 
43
45
  if RUBY_VERSION > '1.9.'
44
46
  context "Ruby 1.9" do
45
- it("uint16_le => S<") { subject[:uint16_le].should == 'S<' }
46
- it("uint32_le => L<") { subject[:uint32_le].should == 'L<' }
47
- it("uint64_le => Q<") { subject[:uint64_le].should == 'Q<' }
48
- it("int16_le => S<") { subject[:int16_le].should == 's<' }
49
- it("int32_le => L<") { subject[:int32_le].should == 'l<' }
50
- it("int64_le => Q<") { subject[:int64_le].should == 'q<' }
51
- it("uint16_be => S>") { subject[:uint16_be].should == 'S>' }
52
- it("uint32_be => L>") { subject[:uint32_be].should == 'L>' }
53
- it("uint64_be => Q>") { subject[:uint64_be].should == 'Q>' }
54
- it("int16_be => S>") { subject[:int16_be].should == 's>' }
55
- it("int32_be => L>") { subject[:int32_be].should == 'l>' }
56
- it("int64_be => Q>") { subject[:int64_be].should == 'q>' }
57
- it("ushort_le => S!<") { subject[:ushort_le].should == 'S!<'}
58
- it("uint_le => I!<") { subject[:uint_le].should == 'I!<'}
59
- it("ulong_le => L!<") { subject[:ulong_le].should == 'L!<'}
60
- it("ulong_long_le => L!<") { subject[:ulong_long_le].should == 'Q<' }
61
- it("short_le => S!<") { subject[:short_le].should == 's!<'}
62
- it("int_le => I!<") { subject[:int_le].should == 'i!<'}
63
- it("long_le => L!<") { subject[:long_le].should == 'l!<'}
64
- it("long_long_le => L!<") { subject[:long_long_le].should == 'q<' }
65
- it("ushort_be => S!>") { subject[:ushort_be].should == 'S!>'}
66
- it("uint_be => I!>") { subject[:uint_be].should == 'I!>'}
67
- it("ulong_be => L!>") { subject[:ulong_be].should == 'L!>'}
68
- it("ulong_long_be => L!>") { subject[:ulong_long_be].should == 'Q>' }
69
- it("short_be => S!>") { subject[:short_be].should == 's!>'}
70
- it("int_be => I!>") { subject[:int_be].should == 'i!>'}
71
- it("long_be => L!>") { subject[:long_be].should == 'l!>'}
72
- it("long_long_be => L!>") { subject[:long_long_be].should == 'q>' }
47
+ it("uint16_le => S<") { expect(subject[:uint16_le]).to eq('S<' ) }
48
+ it("uint32_le => L<") { expect(subject[:uint32_le]).to eq('L<' ) }
49
+ it("uint64_le => Q<") { expect(subject[:uint64_le]).to eq('Q<' ) }
50
+ it("int16_le => S<") { expect(subject[:int16_le]).to eq('s<' ) }
51
+ it("int32_le => L<") { expect(subject[:int32_le]).to eq('l<' ) }
52
+ it("int64_le => Q<") { expect(subject[:int64_le]).to eq('q<' ) }
53
+ it("uint16_be => S>") { expect(subject[:uint16_be]).to eq('S>' ) }
54
+ it("uint32_be => L>") { expect(subject[:uint32_be]).to eq('L>' ) }
55
+ it("uint64_be => Q>") { expect(subject[:uint64_be]).to eq('Q>' ) }
56
+ it("int16_be => S>") { expect(subject[:int16_be]).to eq('s>' ) }
57
+ it("int32_be => L>") { expect(subject[:int32_be]).to eq('l>' ) }
58
+ it("int64_be => Q>") { expect(subject[:int64_be]).to eq('q>' ) }
59
+ it("ushort_le => S!<") { expect(subject[:ushort_le]).to eq('S!<') }
60
+ it("uint_le => I!<") { expect(subject[:uint_le]).to eq('I!<') }
61
+ it("ulong_le => L!<") { expect(subject[:ulong_le]).to eq('L!<') }
62
+ it("ulong_long_le => L!<") { expect(subject[:ulong_long_le]).to eq('Q<' ) }
63
+ it("short_le => S!<") { expect(subject[:short_le]).to eq('s!<') }
64
+ it("int_le => I!<") { expect(subject[:int_le]).to eq('i!<') }
65
+ it("long_le => L!<") { expect(subject[:long_le]).to eq('l!<') }
66
+ it("long_long_le => L!<") { expect(subject[:long_long_le]).to eq('q<' ) }
67
+ it("ushort_be => S!>") { expect(subject[:ushort_be]).to eq('S!>') }
68
+ it("uint_be => I!>") { expect(subject[:uint_be]).to eq('I!>') }
69
+ it("ulong_be => L!>") { expect(subject[:ulong_be]).to eq('L!>') }
70
+ it("ulong_long_be => L!>") { expect(subject[:ulong_long_be]).to eq('Q>' ) }
71
+ it("short_be => S!>") { expect(subject[:short_be]).to eq('s!>') }
72
+ it("int_be => I!>") { expect(subject[:int_be]).to eq('i!>') }
73
+ it("long_be => L!>") { expect(subject[:long_be]).to eq('l!>') }
74
+ it("long_long_be => L!>") { expect(subject[:long_long_be]).to eq('q>' ) }
73
75
  end
74
76
  end
75
77
  end
@@ -79,17 +81,17 @@ describe Binary::Template do
79
81
 
80
82
  context "when given :endian" do
81
83
  it "should translate endian-types" do
82
- subject.translate(:uint, :endian => :little).should == :uint_le
84
+ expect(subject.translate(:uint, :endian => :little)).to eq(:uint_le)
83
85
  end
84
86
 
85
87
  it "should not translate non-endian-types" do
86
- subject.translate(:string, :endian => :little).should == :string
88
+ expect(subject.translate(:string, :endian => :little)).to eq(:string)
87
89
  end
88
90
 
89
91
  it "should raise an ArgumentError for unknown endianness" do
90
- lambda {
92
+ expect {
91
93
  subject.translate(:uint, :endian => :foo)
92
- }.should raise_error(ArgumentError)
94
+ }.to raise_error(ArgumentError)
93
95
  end
94
96
  end
95
97
  end
@@ -101,17 +103,17 @@ describe Binary::Template do
101
103
  subject { described_class }
102
104
 
103
105
  it "should translate types to their pack codes" do
104
- subject.compile([type]).should == code
106
+ expect(subject.compile([type])).to eq(code)
105
107
  end
106
108
 
107
109
  it "should support specifying the length of a field" do
108
- subject.compile([[type, 10]]).should == "#{code}10"
110
+ expect(subject.compile([[type, 10]])).to eq("#{code}10")
109
111
  end
110
112
 
111
113
  it "should raise ArgumentError for unknown types" do
112
- lambda {
114
+ expect {
113
115
  subject.compile([:foo])
114
- }.should raise_error(ArgumentError)
116
+ }.to raise_error(ArgumentError)
115
117
  end
116
118
  end
117
119
 
@@ -119,16 +121,16 @@ describe Binary::Template do
119
121
  subject { described_class.new [:uint32, :string] }
120
122
 
121
123
  it "should store the types" do
122
- subject.fields.should == [
124
+ expect(subject.fields).to eq([
123
125
  :uint32,
124
126
  :string
125
- ]
127
+ ])
126
128
  end
127
129
 
128
130
  it "should raise ArgumentError for unknown types" do
129
- lambda {
131
+ expect {
130
132
  described_class.new [:foo]
131
- }.should raise_error(ArgumentError)
133
+ }.to raise_error(ArgumentError)
132
134
  end
133
135
  end
134
136
 
@@ -161,7 +163,7 @@ describe Binary::Template do
161
163
  subject { described_class.new [:byte] }
162
164
 
163
165
  it "should pack a signed byte" do
164
- subject.pack(byte).should == char
166
+ expect(subject.pack(byte)).to eq(char)
165
167
  end
166
168
  end
167
169
 
@@ -170,7 +172,7 @@ describe Binary::Template do
170
172
  subject { described_class.new [[:byte, n]] }
171
173
 
172
174
  it "should pack multiple signed characters" do
173
- subject.pack(*bytes).should == chars
175
+ expect(subject.pack(*bytes)).to eq(chars)
174
176
  end
175
177
  end
176
178
 
@@ -178,7 +180,7 @@ describe Binary::Template do
178
180
  subject { described_class.new [:char] }
179
181
 
180
182
  it "should pack a signed character" do
181
- subject.pack(char).should == char
183
+ expect(subject.pack(char)).to eq(char)
182
184
  end
183
185
  end
184
186
 
@@ -187,7 +189,7 @@ describe Binary::Template do
187
189
  subject { described_class.new [[:char, n]] }
188
190
 
189
191
  it "should pack multiple signed characters" do
190
- subject.pack(*chars).should == string
192
+ expect(subject.pack(*chars)).to eq(string)
191
193
  end
192
194
 
193
195
  context "padding" do
@@ -195,7 +197,7 @@ describe Binary::Template do
195
197
  subject { described_class.new [[:char, n + padding]] }
196
198
 
197
199
  it "should pad the string with '\\0' characters" do
198
- subject.pack(*chars).should == (string + ("\0" * padding))
200
+ expect(subject.pack(*chars)).to eq((string + ("\0" * padding)))
199
201
  end
200
202
  end
201
203
  end
@@ -204,7 +206,7 @@ describe Binary::Template do
204
206
  subject { described_class.new [:uint8] }
205
207
 
206
208
  it "should pack an unsigned 8bit integer" do
207
- subject.pack(uint8).should == "\xff"
209
+ expect(subject.pack(uint8)).to eq("\xff")
208
210
  end
209
211
  end
210
212
 
@@ -212,7 +214,7 @@ describe Binary::Template do
212
214
  subject { described_class.new [:uint16] }
213
215
 
214
216
  it "should pack an unsigned 16bit integer" do
215
- subject.pack(uint16).should == "\xff\xff"
217
+ expect(subject.pack(uint16)).to eq("\xff\xff")
216
218
  end
217
219
  end
218
220
 
@@ -220,7 +222,7 @@ describe Binary::Template do
220
222
  subject { described_class.new [:uint32] }
221
223
 
222
224
  it "should pack an unsigned 32bit integer" do
223
- subject.pack(uint32).should == "\xff\xff\xff\xff"
225
+ expect(subject.pack(uint32)).to eq("\xff\xff\xff\xff")
224
226
  end
225
227
  end
226
228
 
@@ -228,7 +230,7 @@ describe Binary::Template do
228
230
  subject { described_class.new [:uint64] }
229
231
 
230
232
  it "should pack an unsigned 64bit integer" do
231
- subject.pack(uint64).should == "\xff\xff\xff\xff\xff\xff\xff\xff"
233
+ expect(subject.pack(uint64)).to eq("\xff\xff\xff\xff\xff\xff\xff\xff")
232
234
  end
233
235
  end
234
236
 
@@ -236,7 +238,7 @@ describe Binary::Template do
236
238
  subject { described_class.new [:int8] }
237
239
 
238
240
  it "should pack an signed 8bit integer" do
239
- subject.pack(int8).should == "\xff"
241
+ expect(subject.pack(int8)).to eq("\xff")
240
242
  end
241
243
  end
242
244
 
@@ -244,7 +246,7 @@ describe Binary::Template do
244
246
  subject { described_class.new [:int16] }
245
247
 
246
248
  it "should pack an unsigned 16bit integer" do
247
- subject.pack(int16).should == "\xff\xff"
249
+ expect(subject.pack(int16)).to eq("\xff\xff")
248
250
  end
249
251
  end
250
252
 
@@ -252,7 +254,7 @@ describe Binary::Template do
252
254
  subject { described_class.new [:int32] }
253
255
 
254
256
  it "should pack an unsigned 32bit integer" do
255
- subject.pack(int32).should == "\xff\xff\xff\xff"
257
+ expect(subject.pack(int32)).to eq("\xff\xff\xff\xff")
256
258
  end
257
259
  end
258
260
 
@@ -260,7 +262,7 @@ describe Binary::Template do
260
262
  subject { described_class.new [:int64] }
261
263
 
262
264
  it "should pack an unsigned 64bit integer" do
263
- subject.pack(int64).should == "\xff\xff\xff\xff\xff\xff\xff\xff"
265
+ expect(subject.pack(int64)).to eq("\xff\xff\xff\xff\xff\xff\xff\xff")
264
266
  end
265
267
  end
266
268
 
@@ -268,7 +270,7 @@ describe Binary::Template do
268
270
  subject { described_class.new [:string] }
269
271
 
270
272
  it "should pack a string" do
271
- subject.pack(string).should == "#{string}\0"
273
+ expect(subject.pack(string)).to eq("#{string}\0")
272
274
  end
273
275
  end
274
276
  end
@@ -278,7 +280,7 @@ describe Binary::Template do
278
280
  subject { described_class.new [:byte] }
279
281
 
280
282
  it "should unpack a signed byte" do
281
- subject.unpack(char).should == [byte]
283
+ expect(subject.unpack(char)).to eq([byte])
282
284
  end
283
285
  end
284
286
 
@@ -287,7 +289,7 @@ describe Binary::Template do
287
289
  subject { described_class.new [[:byte, n]] }
288
290
 
289
291
  it "should pack multiple signed characters" do
290
- subject.unpack(chars).should == bytes
292
+ expect(subject.unpack(chars)).to eq(bytes)
291
293
  end
292
294
  end
293
295
 
@@ -295,7 +297,7 @@ describe Binary::Template do
295
297
  subject { described_class.new [:char] }
296
298
 
297
299
  it "should unpack a signed character" do
298
- subject.unpack(char).should == [char]
300
+ expect(subject.unpack(char)).to eq([char])
299
301
  end
300
302
  end
301
303
 
@@ -304,7 +306,7 @@ describe Binary::Template do
304
306
  subject { described_class.new [[:char, n]] }
305
307
 
306
308
  it "should unpack multiple signed characters" do
307
- subject.unpack(string).should == [chars]
309
+ expect(subject.unpack(string)).to eq([chars])
308
310
  end
309
311
 
310
312
  context "padding" do
@@ -312,7 +314,7 @@ describe Binary::Template do
312
314
  subject { described_class.new [[:char, n + padding]] }
313
315
 
314
316
  it "should strip '\\0' padding characters" do
315
- subject.unpack(string + ("\0" * padding)).should == [chars]
317
+ expect(subject.unpack(string + ("\0" * padding))).to eq([chars])
316
318
  end
317
319
  end
318
320
  end
@@ -321,7 +323,7 @@ describe Binary::Template do
321
323
  subject { described_class.new [:uint8] }
322
324
 
323
325
  it "should unpack an unsigned 8bit integer" do
324
- subject.unpack("\xff").should == [uint8]
326
+ expect(subject.unpack("\xff")).to eq([uint8])
325
327
  end
326
328
  end
327
329
 
@@ -329,7 +331,7 @@ describe Binary::Template do
329
331
  subject { described_class.new [:uint16] }
330
332
 
331
333
  it "should unpack an unsigned 16bit integer" do
332
- subject.unpack("\xff\xff").should == [uint16]
334
+ expect(subject.unpack("\xff\xff")).to eq([uint16])
333
335
  end
334
336
  end
335
337
 
@@ -337,7 +339,7 @@ describe Binary::Template do
337
339
  subject { described_class.new [:uint32] }
338
340
 
339
341
  it "should unpack an unsigned 32bit integer" do
340
- subject.unpack("\xff\xff\xff\xff").should == [uint32]
342
+ expect(subject.unpack("\xff\xff\xff\xff")).to eq([uint32])
341
343
  end
342
344
  end
343
345
 
@@ -345,7 +347,7 @@ describe Binary::Template do
345
347
  subject { described_class.new [:uint64] }
346
348
 
347
349
  it "should unpack an unsigned 64bit integer" do
348
- subject.unpack("\xff\xff\xff\xff\xff\xff\xff\xff").should == [uint64]
350
+ expect(subject.unpack("\xff\xff\xff\xff\xff\xff\xff\xff")).to eq([uint64])
349
351
  end
350
352
  end
351
353
 
@@ -353,7 +355,7 @@ describe Binary::Template do
353
355
  subject { described_class.new [:int8] }
354
356
 
355
357
  it "should unpack an signed 8bit integer" do
356
- subject.unpack("\xff").should == [int8]
358
+ expect(subject.unpack("\xff")).to eq([int8])
357
359
  end
358
360
  end
359
361
 
@@ -361,7 +363,7 @@ describe Binary::Template do
361
363
  subject { described_class.new [:int16] }
362
364
 
363
365
  it "should unpack an unsigned 16bit integer" do
364
- subject.unpack("\xff\xff").should == [int16]
366
+ expect(subject.unpack("\xff\xff")).to eq([int16])
365
367
  end
366
368
  end
367
369
 
@@ -369,7 +371,7 @@ describe Binary::Template do
369
371
  subject { described_class.new [:int32] }
370
372
 
371
373
  it "should unpack an unsigned 32bit integer" do
372
- subject.unpack("\xff\xff\xff\xff").should == [int32]
374
+ expect(subject.unpack("\xff\xff\xff\xff")).to eq([int32])
373
375
  end
374
376
  end
375
377
 
@@ -377,7 +379,7 @@ describe Binary::Template do
377
379
  subject { described_class.new [:int64] }
378
380
 
379
381
  it "should unpack an unsigned 64bit integer" do
380
- subject.unpack("\xff\xff\xff\xff\xff\xff\xff\xff").should == [int64]
382
+ expect(subject.unpack("\xff\xff\xff\xff\xff\xff\xff\xff")).to eq([int64])
381
383
  end
382
384
  end
383
385
 
@@ -385,7 +387,7 @@ describe Binary::Template do
385
387
  subject { described_class.new [:string] }
386
388
 
387
389
  it "should unpack a string" do
388
- subject.unpack("#{string}\0").should == [string]
390
+ expect(subject.unpack("#{string}\0")).to eq([string])
389
391
  end
390
392
  end
391
393
  end
@@ -394,7 +396,7 @@ describe Binary::Template do
394
396
  subject { described_class.new [:uint32, :string] }
395
397
 
396
398
  it "should return the pack format String" do
397
- subject.to_s.should == "LZ*"
399
+ expect(subject.to_s).to eq("LZ*")
398
400
  end
399
401
  end
400
402
 
@@ -404,11 +406,11 @@ describe Binary::Template do
404
406
  subject { template.inspect }
405
407
 
406
408
  it "should inspect the class" do
407
- subject.should include(described_class.name)
409
+ expect(subject).to include(described_class.name)
408
410
  end
409
411
 
410
412
  it "should inspect the template" do
411
- subject.should include(template.fields.inspect)
413
+ expect(subject).to include(template.fields.inspect)
412
414
  end
413
415
  end
414
416
  end