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.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +28 -0
- data/Gemfile +6 -7
- data/README.md +53 -32
- data/Rakefile +1 -2
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +5 -5
- data/lib/ronin/binary/hexdump.rb +5 -5
- data/lib/ronin/binary/hexdump/parser.rb +5 -5
- data/lib/ronin/binary/struct.rb +5 -5
- data/lib/ronin/binary/template.rb +7 -7
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +37 -31
- data/lib/ronin/extensions/ip_addr.rb +6 -7
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +5 -5
- data/lib/ronin/extensions/resolv.rb +5 -5
- data/lib/ronin/extensions/string.rb +5 -5
- data/lib/ronin/formatting.rb +5 -5
- data/lib/ronin/formatting/binary.rb +5 -5
- data/lib/ronin/formatting/digest.rb +5 -5
- data/lib/ronin/formatting/extensions.rb +5 -5
- data/lib/ronin/formatting/extensions/binary.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
- data/lib/ronin/formatting/extensions/digest.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
- data/lib/ronin/formatting/extensions/html.rb +5 -5
- data/lib/ronin/formatting/extensions/html/integer.rb +5 -5
- data/lib/ronin/formatting/extensions/html/string.rb +7 -7
- data/lib/ronin/formatting/extensions/http.rb +5 -5
- data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/http/string.rb +7 -7
- data/lib/ronin/formatting/extensions/sql.rb +5 -5
- data/lib/ronin/formatting/extensions/sql/string.rb +15 -13
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +5 -5
- data/lib/ronin/formatting/extensions/text/string.rb +5 -5
- data/lib/ronin/formatting/html.rb +5 -5
- data/lib/ronin/formatting/http.rb +5 -5
- data/lib/ronin/formatting/sql.rb +5 -5
- data/lib/ronin/formatting/text.rb +5 -5
- data/lib/ronin/fuzzing.rb +5 -5
- data/lib/ronin/fuzzing/extensions.rb +5 -5
- data/lib/ronin/fuzzing/extensions/string.rb +5 -5
- data/lib/ronin/fuzzing/fuzzer.rb +5 -5
- data/lib/ronin/fuzzing/fuzzing.rb +7 -7
- data/lib/ronin/fuzzing/mutator.rb +5 -5
- data/lib/ronin/fuzzing/repeater.rb +5 -5
- data/lib/ronin/fuzzing/template.rb +5 -5
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +5 -5
- data/lib/ronin/network/dns.rb +5 -5
- data/lib/ronin/network/esmtp.rb +5 -5
- data/lib/ronin/network/extensions.rb +5 -5
- data/lib/ronin/network/extensions/dns.rb +5 -5
- data/lib/ronin/network/extensions/dns/net.rb +5 -5
- data/lib/ronin/network/extensions/esmtp.rb +5 -5
- data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
- data/lib/ronin/network/extensions/http.rb +5 -5
- data/lib/ronin/network/extensions/http/net.rb +5 -5
- data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
- data/lib/ronin/network/extensions/imap.rb +5 -5
- data/lib/ronin/network/extensions/imap/net.rb +5 -5
- data/lib/ronin/network/extensions/pop3.rb +5 -5
- data/lib/ronin/network/extensions/pop3/net.rb +5 -5
- data/lib/ronin/network/extensions/smtp.rb +5 -5
- data/lib/ronin/network/extensions/smtp/net.rb +5 -5
- data/lib/ronin/network/extensions/ssl.rb +5 -5
- data/lib/ronin/network/extensions/ssl/net.rb +5 -5
- data/lib/ronin/network/extensions/tcp.rb +5 -5
- data/lib/ronin/network/extensions/tcp/net.rb +5 -5
- data/lib/ronin/network/extensions/telnet.rb +5 -5
- data/lib/ronin/network/extensions/telnet/net.rb +5 -5
- data/lib/ronin/network/extensions/udp.rb +5 -5
- data/lib/ronin/network/extensions/udp/net.rb +5 -5
- data/lib/ronin/network/ftp.rb +5 -5
- data/lib/ronin/network/http.rb +5 -5
- data/lib/ronin/network/http/exceptions.rb +5 -5
- data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
- data/lib/ronin/network/http/http.rb +52 -57
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +5 -5
- data/lib/ronin/network/mixins.rb +5 -5
- data/lib/ronin/network/mixins/dns.rb +5 -5
- data/lib/ronin/network/mixins/esmtp.rb +5 -5
- data/lib/ronin/network/mixins/ftp.rb +5 -5
- data/lib/ronin/network/mixins/http.rb +7 -7
- data/lib/ronin/network/mixins/imap.rb +5 -5
- data/lib/ronin/network/mixins/mixin.rb +5 -5
- data/lib/ronin/network/mixins/pop3.rb +5 -5
- data/lib/ronin/network/mixins/smtp.rb +5 -5
- data/lib/ronin/network/mixins/ssl.rb +5 -5
- data/lib/ronin/network/mixins/tcp.rb +5 -5
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +5 -5
- data/lib/ronin/network/mixins/unix.rb +5 -5
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +5 -5
- data/lib/ronin/network/proxy.rb +5 -5
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +5 -5
- data/lib/ronin/network/ssl.rb +7 -7
- data/lib/ronin/network/tcp.rb +5 -5
- data/lib/ronin/network/tcp/proxy.rb +5 -5
- data/lib/ronin/network/tcp/tcp.rb +32 -23
- data/lib/ronin/network/telnet.rb +7 -5
- data/lib/ronin/network/udp.rb +5 -5
- data/lib/ronin/network/udp/proxy.rb +5 -5
- data/lib/ronin/network/udp/udp.rb +28 -26
- data/lib/ronin/network/unix.rb +7 -7
- data/lib/ronin/path.rb +32 -36
- data/lib/ronin/spec/ui/output.rb +5 -5
- data/lib/ronin/support.rb +5 -5
- data/lib/ronin/support/inflector.rb +5 -5
- data/lib/ronin/support/support.rb +5 -5
- data/lib/ronin/support/version.rb +6 -6
- data/lib/ronin/templates.rb +5 -5
- data/lib/ronin/templates/erb.rb +5 -5
- data/lib/ronin/templates/template.rb +5 -5
- data/lib/ronin/ui/output.rb +5 -5
- data/lib/ronin/ui/output/helpers.rb +5 -5
- data/lib/ronin/ui/output/output.rb +17 -21
- data/lib/ronin/ui/output/terminal.rb +5 -5
- data/lib/ronin/ui/output/terminal/color.rb +5 -5
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +5 -5
- data/lib/ronin/wordlist.rb +7 -7
- data/ronin-support.gemspec +1 -0
- data/spec/binary/hexdump/parser_spec.rb +22 -22
- data/spec/binary/struct_spec.rb +56 -56
- data/spec/binary/template_spec.rb +106 -104
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +30 -30
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +69 -69
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +30 -29
- data/spec/formatting/binary/array_spec.rb +2 -2
- data/spec/formatting/binary/base64_spec.rb +8 -8
- data/spec/formatting/binary/float_spec.rb +6 -4
- data/spec/formatting/binary/integer_spec.rb +25 -25
- data/spec/formatting/binary/string_spec.rb +32 -30
- data/spec/formatting/digest/string_spec.rb +5 -5
- data/spec/formatting/html/integer_spec.rb +6 -6
- data/spec/formatting/html/string_spec.rb +10 -10
- data/spec/formatting/http/integer_spec.rb +3 -3
- data/spec/formatting/http/string_spec.rb +5 -5
- data/spec/formatting/sql/string_spec.rb +21 -19
- data/spec/formatting/text/array_spec.rb +15 -15
- data/spec/formatting/text/string_spec.rb +33 -33
- data/spec/fuzzing/extensions/string_spec.rb +11 -11
- data/spec/fuzzing/fuzzer_spec.rb +15 -15
- data/spec/fuzzing/fuzzing_spec.rb +5 -5
- data/spec/fuzzing/mutator_spec.rb +15 -15
- data/spec/fuzzing/repeater_spec.rb +7 -7
- data/spec/fuzzing/template_spec.rb +11 -11
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +34 -32
- data/spec/network/ftp_spec.rb +9 -9
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +1 -1
- data/spec/network/proxy_spec.rb +19 -19
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +9 -9
- data/spec/network/tcp/proxy_spec.rb +9 -7
- data/spec/network/tcp/tcp_spec.rb +161 -118
- data/spec/network/telnet_spec.rb +5 -5
- data/spec/network/udp/udp_spec.rb +123 -96
- data/spec/network/unix_spec.rb +24 -25
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +0 -1
- data/spec/support/inflector_spec.rb +4 -4
- data/spec/support_spec.rb +1 -1
- data/spec/templates/erb_spec.rb +3 -3
- data/spec/templates/template_spec.rb +10 -10
- data/spec/ui/shell_spec.rb +15 -15
- data/spec/wordlist_spec.rb +19 -19
- metadata +408 -366
- data/.gemtest +0 -0
data/spec/binary/struct_spec.rb
CHANGED
@@ -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.
|
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.
|
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.
|
33
|
-
subject.
|
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.
|
38
|
-
subject.
|
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).
|
52
|
-
subject.field?(:foo).
|
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.
|
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.
|
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.
|
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].
|
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].
|
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].
|
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].
|
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].
|
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].
|
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].
|
142
|
+
expect(subject[:char_array]).to eq('')
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should set strings to ''" do
|
146
|
-
subject[:string].
|
146
|
+
expect(subject[:string]).to eq('')
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should initialize nested structs" do
|
150
|
-
subject[:struct][:int].
|
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].
|
155
|
-
subject[:struct_array][1][:int].
|
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
|
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].
|
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.
|
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
|
-
|
185
|
+
expect {
|
186
186
|
subject[:foo]
|
187
|
-
}.
|
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
|
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').
|
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.
|
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
|
-
|
219
|
+
expect {
|
220
220
|
subject[:foo] = 20
|
221
|
-
}.
|
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
|
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.
|
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
|
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.
|
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
|
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.
|
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
|
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.
|
333
|
-
subject.y.
|
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.
|
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
|
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.
|
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
|
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.
|
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
|
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.
|
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.
|
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.
|
465
|
-
subject.struct.int.
|
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.
|
491
|
-
subject.struct[0].int.
|
492
|
-
subject.struct[1].int.
|
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")
|
9
|
-
it("uint16 => S")
|
10
|
-
it("uint32 => L")
|
11
|
-
it("uint64 => Q")
|
12
|
-
it("int8 => C")
|
13
|
-
it("int16 => S")
|
14
|
-
it("int32 => L")
|
15
|
-
it("int64 => 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")
|
18
|
-
it("uint32_le => V")
|
19
|
-
it("uint16_be => n")
|
20
|
-
it("uint32_be => N")
|
21
|
-
end
|
22
|
-
it("uchar => Z") { subject[:uchar].
|
23
|
-
it("ushort => S!") { subject[:ushort].
|
24
|
-
it("uint => I!") { subject[:uint].
|
25
|
-
it("ulong => L!") { subject[:ulong].
|
26
|
-
it("ulong_long => Q") { subject[:ulong_long].
|
27
|
-
it("char => Z") { subject[:char].
|
28
|
-
it("short => s!") { subject[:short].
|
29
|
-
it("int => i!") { subject[:int].
|
30
|
-
it("long => l!") { subject[:long].
|
31
|
-
it("long_long => q") { subject[:long_long].
|
32
|
-
it("utf8 => U") { subject[:utf8].
|
33
|
-
it("float => F")
|
34
|
-
it("double => D")
|
35
|
-
it("float_le => e")
|
36
|
-
it("double_le => E")
|
37
|
-
it("float_be => g")
|
38
|
-
it("double_ge => G")
|
39
|
-
it("ubyte => C")
|
40
|
-
it("byte => c")
|
41
|
-
it("string => Z*") { subject[:string].
|
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].
|
46
|
-
it("uint32_le => L<") { subject[:uint32_le].
|
47
|
-
it("uint64_le => Q<") { subject[:uint64_le].
|
48
|
-
it("int16_le => S<") { subject[:int16_le].
|
49
|
-
it("int32_le => L<") { subject[:int32_le].
|
50
|
-
it("int64_le => Q<") { subject[:int64_le].
|
51
|
-
it("uint16_be => S>") { subject[:uint16_be].
|
52
|
-
it("uint32_be => L>") { subject[:uint32_be].
|
53
|
-
it("uint64_be => Q>") { subject[:uint64_be].
|
54
|
-
it("int16_be => S>") { subject[:int16_be].
|
55
|
-
it("int32_be => L>") { subject[:int32_be].
|
56
|
-
it("int64_be => Q>") { subject[:int64_be].
|
57
|
-
it("ushort_le => S!<") { subject[:ushort_le].
|
58
|
-
it("uint_le => I!<") { subject[:uint_le].
|
59
|
-
it("ulong_le => L!<") { subject[:ulong_le].
|
60
|
-
it("ulong_long_le => L!<") { subject[:ulong_long_le].
|
61
|
-
it("short_le => S!<") { subject[:short_le].
|
62
|
-
it("int_le => I!<") { subject[:int_le].
|
63
|
-
it("long_le => L!<") { subject[:long_le].
|
64
|
-
it("long_long_le => L!<") { subject[:long_long_le].
|
65
|
-
it("ushort_be => S!>") { subject[:ushort_be].
|
66
|
-
it("uint_be => I!>") { subject[:uint_be].
|
67
|
-
it("ulong_be => L!>") { subject[:ulong_be].
|
68
|
-
it("ulong_long_be => L!>") { subject[:ulong_long_be].
|
69
|
-
it("short_be => S!>") { subject[:short_be].
|
70
|
-
it("int_be => I!>") { subject[:int_be].
|
71
|
-
it("long_be => L!>") { subject[:long_be].
|
72
|
-
it("long_long_be => L!>") { subject[:long_long_be].
|
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).
|
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).
|
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
|
-
|
92
|
+
expect {
|
91
93
|
subject.translate(:uint, :endian => :foo)
|
92
|
-
}.
|
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]).
|
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]]).
|
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
|
-
|
114
|
+
expect {
|
113
115
|
subject.compile([:foo])
|
114
|
-
}.
|
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.
|
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
|
-
|
131
|
+
expect {
|
130
132
|
described_class.new [:foo]
|
131
|
-
}.
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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)).
|
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").
|
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").
|
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").
|
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").
|
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").
|
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").
|
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").
|
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").
|
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").
|
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.
|
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.
|
409
|
+
expect(subject).to include(described_class.name)
|
408
410
|
end
|
409
411
|
|
410
412
|
it "should inspect the template" do
|
411
|
-
subject.
|
413
|
+
expect(subject).to include(template.fields.inspect)
|
412
414
|
end
|
413
415
|
end
|
414
416
|
end
|