bindata 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bindata might be problematic. Click here for more details.

Files changed (61) hide show
  1. data/ChangeLog.rdoc +7 -0
  2. data/NEWS.rdoc +11 -0
  3. data/Rakefile +6 -1
  4. data/bindata.gemspec +2 -1
  5. data/doc/manual.md +17 -9
  6. data/examples/gzip.rb +2 -2
  7. data/examples/list.rb +2 -2
  8. data/lib/bindata/alignment.rb +4 -9
  9. data/lib/bindata/array.rb +57 -51
  10. data/lib/bindata/base.rb +13 -110
  11. data/lib/bindata/base_primitive.rb +130 -75
  12. data/lib/bindata/bits.rb +5 -7
  13. data/lib/bindata/choice.rb +24 -32
  14. data/lib/bindata/dsl.rb +1 -6
  15. data/lib/bindata/framework.rb +81 -0
  16. data/lib/bindata/int.rb +5 -7
  17. data/lib/bindata/name.rb +28 -0
  18. data/lib/bindata/offset.rb +42 -53
  19. data/lib/bindata/params.rb +33 -38
  20. data/lib/bindata/struct.rb +2 -6
  21. data/lib/bindata/trace.rb +16 -16
  22. data/lib/bindata/version.rb +1 -1
  23. data/lib/bindata/virtual.rb +3 -3
  24. data/{spec/alignment_spec.rb → test/alignment_test.rb} +17 -16
  25. data/test/array_test.rb +371 -0
  26. data/test/base_primitive_test.rb +312 -0
  27. data/test/base_test.rb +183 -0
  28. data/{spec/bits_spec.rb → test/bits_test.rb} +59 -59
  29. data/test/choice_test.rb +260 -0
  30. data/{spec/spec_common.rb → test/common.rb} +33 -18
  31. data/test/count_bytes_remaining_test.rb +41 -0
  32. data/{spec/deprecated_spec.rb → test/deprecated_test.rb} +5 -7
  33. data/test/float_test.rb +72 -0
  34. data/{spec/int_spec.rb → test/int_test.rb} +34 -43
  35. data/{spec/io_spec.rb → test/io_test.rb} +70 -71
  36. data/{spec/lazy_spec.rb → test/lazy_test.rb} +38 -39
  37. data/test/offset_test.rb +93 -0
  38. data/test/params_test.rb +144 -0
  39. data/{spec/primitive_spec.rb → test/primitive_test.rb} +42 -54
  40. data/{spec/record_spec.rb → test/record_test.rb} +133 -154
  41. data/test/registry_test.rb +104 -0
  42. data/test/rest_test.rb +29 -0
  43. data/test/skip_test.rb +28 -0
  44. data/{spec/string_spec.rb → test/string_test.rb} +96 -97
  45. data/test/stringz_test.rb +127 -0
  46. data/{spec/struct_spec.rb → test/struct_test.rb} +119 -120
  47. data/{spec/system_spec.rb → test/system_test.rb} +66 -106
  48. metadata +39 -38
  49. data/lib/a.rb +0 -24
  50. data/spec/array_spec.rb +0 -331
  51. data/spec/base_primitive_spec.rb +0 -238
  52. data/spec/base_spec.rb +0 -376
  53. data/spec/choice_spec.rb +0 -263
  54. data/spec/count_bytes_remaining_spec.rb +0 -38
  55. data/spec/example.rb +0 -21
  56. data/spec/float_spec.rb +0 -37
  57. data/spec/registry_spec.rb +0 -108
  58. data/spec/rest_spec.rb +0 -26
  59. data/spec/skip_spec.rb +0 -27
  60. data/spec/stringz_spec.rb +0 -118
  61. data/tasks/rspec.rake +0 -17
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "common"))
4
+
5
+ describe BinData::Registry do
6
+ A = Class.new
7
+ B = Class.new
8
+ C = Class.new
9
+ D = Class.new
10
+
11
+ let(:r) { BinData::Registry.new }
12
+
13
+ it "lookups registered names" do
14
+ r.register('ASubClass', A)
15
+ r.register('AnotherSubClass', B)
16
+
17
+ r.lookup('ASubClass').must_equal A
18
+ r.lookup('a_sub_class').must_equal A
19
+ r.lookup('AnotherSubClass').must_equal B
20
+ r.lookup('another_sub_class').must_equal B
21
+ end
22
+
23
+ it "does not lookup unregistered names" do
24
+ lambda {
25
+ r.lookup('a_non_existent_sub_class')
26
+ }.must_raise BinData::UnRegisteredTypeError
27
+ end
28
+
29
+ it "unregisters names" do
30
+ r.register('ASubClass', A)
31
+ r.unregister('ASubClass')
32
+
33
+ lambda {
34
+ r.lookup('ASubClass')
35
+ }.must_raise BinData::UnRegisteredTypeError
36
+ end
37
+
38
+ it "allows overriding of registered classes" do
39
+ r.register('A', A)
40
+ r.register('A', B)
41
+
42
+ r.lookup('a').must_equal B
43
+ end
44
+
45
+ it "converts CamelCase to underscores" do
46
+ r.underscore_name('CamelCase').must_equal 'camel_case'
47
+ end
48
+
49
+ it "converts adjacent caps camelCase to underscores" do
50
+ r.underscore_name('XYZCamelCase').must_equal 'xyz_camel_case'
51
+ end
52
+
53
+ it "ignores the outer nestings of classes" do
54
+ r.underscore_name('A::B::C').must_equal 'c'
55
+ end
56
+ end
57
+
58
+ describe BinData::Registry, "with numerics" do
59
+ let(:r) { BinData::RegisteredClasses }
60
+
61
+ it "lookup integers with endian" do
62
+ r.lookup("int24", :big).to_s.must_equal "BinData::Int24be"
63
+ r.lookup("int24", :little).to_s.must_equal "BinData::Int24le"
64
+ r.lookup("uint24", :big).to_s.must_equal "BinData::Uint24be"
65
+ r.lookup("uint24", :little).to_s.must_equal "BinData::Uint24le"
66
+ end
67
+
68
+ it "does not lookup integers without endian" do
69
+ lambda {
70
+ r.lookup("int24")
71
+ }.must_raise BinData::UnRegisteredTypeError
72
+ end
73
+
74
+ it "does not lookup non byte based integers" do
75
+ lambda {
76
+ r.lookup("int3")
77
+ }.must_raise BinData::UnRegisteredTypeError
78
+ lambda {
79
+ r.lookup("int3", :big)
80
+ }.must_raise BinData::UnRegisteredTypeError
81
+ lambda {
82
+ r.lookup("int3", :little)
83
+ }.must_raise BinData::UnRegisteredTypeError
84
+ end
85
+
86
+ it "lookup floats with endian" do
87
+ r.lookup("float", :big).to_s.must_equal "BinData::FloatBe"
88
+ r.lookup("float", :little).to_s.must_equal "BinData::FloatLe"
89
+ r.lookup("double", :big).to_s.must_equal "BinData::DoubleBe"
90
+ r.lookup("double", :little).to_s.must_equal "BinData::DoubleLe"
91
+ end
92
+
93
+ it "lookup bits" do
94
+ r.lookup("bit5").to_s.must_equal "BinData::Bit5"
95
+ r.lookup("bit6le").to_s.must_equal "BinData::Bit6le"
96
+ end
97
+
98
+ it "lookup bits by ignoring endian" do
99
+ r.lookup("bit2", :big).to_s.must_equal "BinData::Bit2"
100
+ r.lookup("bit3le", :big).to_s.must_equal "BinData::Bit3le"
101
+ r.lookup("bit2", :little).to_s.must_equal "BinData::Bit2"
102
+ r.lookup("bit3le", :little).to_s.must_equal "BinData::Bit3le"
103
+ end
104
+ end
data/test/rest_test.rb ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "common"))
4
+
5
+ describe BinData::Rest do
6
+ let(:obj) { BinData::Rest.new }
7
+
8
+ it "initial state" do
9
+ obj.must_equal ""
10
+ end
11
+
12
+ it "reads till end of stream" do
13
+ data = "abcdefghij"
14
+ obj.read(data).must_equal data
15
+ end
16
+
17
+ it "allows setting value for completeness" do
18
+ obj.assign("123")
19
+ obj.must_equal "123"
20
+ obj.to_binary_s.must_equal "123"
21
+ end
22
+
23
+ it "accepts BinData::BasePrimitive parameters" do
24
+ rest = BinData::Rest.new(:assert => "abc")
25
+ lambda {
26
+ rest.read("xyz")
27
+ }.must_raise BinData::ValidityError
28
+ end
29
+ end
data/test/skip_test.rb ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "common"))
4
+
5
+ describe BinData::Skip do
6
+ let(:obj) { BinData::Skip.new(:length => 5) }
7
+ let(:io) { StringIO.new("abcdefghij") }
8
+
9
+ it "initial state" do
10
+ obj.must_equal ""
11
+ obj.to_binary_s.must_equal "\000" * 5
12
+ end
13
+
14
+ it "skips bytes" do
15
+ obj.read(io)
16
+ io.pos.must_equal 5
17
+ end
18
+
19
+ it "has expected binary representation after setting value" do
20
+ obj.assign("123")
21
+ obj.to_binary_s.must_equal "\000" * 5
22
+ end
23
+
24
+ it "has expected binary representation after reading" do
25
+ obj.read(io)
26
+ obj.to_binary_s.must_equal "\000" * 5
27
+ end
28
+ end
@@ -1,23 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
4
- require 'bindata/io'
5
- require 'bindata/string'
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "common"))
6
4
 
7
5
  describe BinData::String, "with mutually exclusive parameters" do
8
6
  it ":value and :initial_value" do
9
7
  params = {:value => "", :initial_value => ""}
10
- expect { BinData::String.new(params) }.to raise_error(ArgumentError)
8
+ lambda { BinData::String.new(params) }.must_raise ArgumentError
11
9
  end
12
10
 
13
11
  it ":length and :read_length" do
14
12
  params = {:length => 5, :read_length => 5}
15
- expect { BinData::String.new(params) }.to raise_error(ArgumentError)
13
+ lambda { BinData::String.new(params) }.must_raise ArgumentError
16
14
  end
17
15
 
18
16
  it ":value and :length" do
19
17
  params = {:value => "", :length => 5}
20
- expect { BinData::String.new(params) }.to raise_error(ArgumentError)
18
+ lambda { BinData::String.new(params) }.must_raise ArgumentError
21
19
  end
22
20
  end
23
21
 
@@ -27,140 +25,141 @@ describe BinData::String, "when assigning" do
27
25
 
28
26
  it "copies data from small to large" do
29
27
  large.assign(small)
30
- large.should == "AAABB"
28
+ large.must_equal "AAABB"
31
29
  end
32
30
 
33
31
  it "copies data from large to small" do
34
32
  small.assign(large)
35
- small.should == "BBB"
33
+ small.must_equal "BBB"
36
34
  end
37
35
  end
38
36
 
39
37
  describe BinData::String do
40
- subject { BinData::String.new("testing") }
38
+ let(:obj) { BinData::String.new("testing") }
41
39
 
42
40
  it "compares with regexp" do
43
- (/es/ =~ subject).should == 1
41
+ (/es/ =~ obj).must_equal 1
44
42
  end
45
43
 
46
44
  it "compares with regexp" do
47
- (subject =~ /es/).should == 1
45
+ (obj =~ /es/).must_equal 1
48
46
  end
49
47
  end
50
48
 
51
49
  describe BinData::String, "with :read_length" do
52
- subject { BinData::String.new(:read_length => 5) }
50
+ let(:obj) { BinData::String.new(:read_length => 5) }
53
51
 
54
- its(:num_bytes) { should == 0 }
55
- its(:value) { should == "" }
52
+ specify { obj.num_bytes.must_equal 0 }
53
+ specify { obj.value.must_equal "" }
56
54
 
57
55
  it "reads :read_length bytes" do
58
- subject.read("abcdefghij")
59
- subject.should == "abcde"
56
+ obj.read("abcdefghij")
57
+ obj.must_equal "abcde"
60
58
  end
61
59
 
62
60
  it "remembers :read_length after value is cleared" do
63
- subject.assign("abc")
64
- subject.num_bytes.should == 3
65
- subject.clear
61
+ obj.assign("abc")
62
+ obj.num_bytes.must_equal 3
63
+ obj.clear
66
64
 
67
- subject.read("abcdefghij")
68
- subject.should == "abcde"
65
+ obj.read("abcdefghij")
66
+ obj.must_equal "abcde"
69
67
  end
70
68
  end
71
69
 
72
70
  describe BinData::String, "with :length" do
73
- subject { BinData::String.new(:length => 5) }
71
+ let(:obj) { BinData::String.new(:length => 5) }
74
72
 
75
- its(:num_bytes) { should == 5 }
76
- its(:value) { should == "\0\0\0\0\0" }
73
+ specify { obj.num_bytes.must_equal 5 }
74
+ specify { obj.value.must_equal "\0\0\0\0\0" }
77
75
 
78
76
  it "retains :length after value is set" do
79
- subject.assign("abcdefghij")
80
- subject.num_bytes.should == 5
77
+ obj.assign("abcdefghij")
78
+ obj.num_bytes.must_equal 5
81
79
  end
82
80
 
83
81
  it "reads :length bytes" do
84
- subject.read("abcdefghij")
85
- subject.should == "abcde"
82
+ obj.read("abcdefghij")
83
+ obj.must_equal "abcde"
86
84
  end
87
85
 
88
86
  it "pads values less than :length" do
89
- subject.assign("abc")
90
- subject.should == "abc\0\0"
87
+ obj.assign("abc")
88
+ obj.must_equal "abc\0\0"
91
89
  end
92
90
 
93
91
  it "accepts values exactly :length" do
94
- subject.assign("abcde")
95
- subject.should == "abcde"
92
+ obj.assign("abcde")
93
+ obj.must_equal "abcde"
96
94
  end
97
95
 
98
96
  it "truncates values greater than :length" do
99
- subject.assign("abcdefghij")
100
- subject.should == "abcde"
97
+ obj.assign("abcdefghij")
98
+ obj.must_equal "abcde"
101
99
  end
102
100
  end
103
101
 
104
102
  describe BinData::String, "with :read_length and :initial_value" do
105
- subject { BinData::String.new(:read_length => 5, :initial_value => "abcdefghij") }
103
+ let(:obj) { BinData::String.new(:read_length => 5, :initial_value => "abcdefghij") }
106
104
 
107
- its(:num_bytes) { should == 10 }
108
- its(:value) { should == "abcdefghij" }
105
+ specify { obj.num_bytes.must_equal 10 }
106
+ specify { obj.value.must_equal "abcdefghij" }
109
107
 
110
108
  it "uses :read_length for reading" do
111
109
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
112
- subject.read(io)
113
- io.pos.should == 5
110
+ obj.read(io)
111
+ io.pos.must_equal 5
114
112
  end
115
113
 
116
114
  it "forgets :initial_value after reading" do
117
- subject.read("ABCDEFGHIJKLMNOPQRST")
118
- subject.num_bytes.should == 5
119
- subject.should == "ABCDE"
115
+ obj.read("ABCDEFGHIJKLMNOPQRST")
116
+ obj.num_bytes.must_equal 5
117
+ obj.must_equal "ABCDE"
120
118
  end
121
119
  end
122
120
 
123
121
  describe BinData::String, "with :read_length and :value" do
124
- subject { BinData::String.new(:read_length => 5, :value => "abcdefghij") }
122
+ let(:obj) { BinData::String.new(:read_length => 5, :value => "abcdefghij") }
125
123
 
126
- its(:num_bytes) { should == 10 }
127
- its(:value) { should == "abcdefghij" }
124
+ specify { obj.num_bytes.must_equal 10 }
125
+ specify { obj.value.must_equal "abcdefghij" }
128
126
 
129
127
  it "uses :read_length for reading" do
130
128
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
131
- subject.read(io)
132
- io.pos.should == 5
129
+ obj.read(io)
130
+ io.pos.must_equal 5
133
131
  end
134
132
 
135
- context "after reading" do
133
+ describe "after reading" do
136
134
  before(:each) do
137
- subject.read("ABCDEFGHIJKLMNOPQRST")
135
+ obj.read("ABCDEFGHIJKLMNOPQRST")
138
136
  end
139
137
 
140
138
  it "is not affected by :read_length after reading" do
141
- subject.num_bytes.should == 10
142
- subject.should == "abcdefghij"
139
+ obj.num_bytes.must_equal 10
140
+ obj.must_equal "abcdefghij"
143
141
  end
144
142
 
145
143
  it "returns read value while reading" do
146
- subject.stub(:reading?).and_return(true)
147
- subject.should == "ABCDE"
144
+ obj.stub :reading?, true do
145
+ obj.must_equal "ABCDE"
146
+ end
148
147
  end
149
148
  end
150
149
  end
151
150
 
152
151
  describe BinData::String, "with :length and :initial_value" do
153
- subject { BinData::String.new(:length => 5, :initial_value => "abcdefghij") }
152
+ let(:obj) { BinData::String.new(:length => 5, :initial_value => "abcdefghij") }
154
153
 
155
- its(:num_bytes) { should == 5 }
156
- its(:value) { should == "abcde" }
154
+ specify { obj.num_bytes.must_equal 5 }
155
+ specify { obj.value.must_equal "abcde" }
157
156
 
158
157
  it "forgets :initial_value after reading" do
159
158
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
160
- subject.read(io)
161
- io.pos.should == 5
162
- subject.num_bytes.should == 5
163
- subject.should == "ABCDE"
159
+ obj.read(io)
160
+ io.pos.must_equal 5
161
+ obj.num_bytes.must_equal 5
162
+ obj.must_equal "ABCDE"
164
163
  end
165
164
  end
166
165
 
@@ -168,18 +167,18 @@ describe BinData::String, "with :pad_byte" do
168
167
  it "accepts a numeric value for :pad_byte" do
169
168
  str = BinData::String.new(:length => 5, :pad_byte => 6)
170
169
  str.assign("abc")
171
- str.should == "abc\x06\x06"
170
+ str.must_equal "abc\x06\x06"
172
171
  end
173
172
 
174
173
  it "accepts a character for :pad_byte" do
175
174
  str = BinData::String.new(:length => 5, :pad_byte => "R")
176
175
  str.assign("abc")
177
- str.should == "abcRR"
176
+ str.must_equal "abcRR"
178
177
  end
179
178
 
180
179
  it "does not accept a string for :pad_byte" do
181
180
  params = {:length => 5, :pad_byte => "RR"}
182
- lambda { BinData::String.new(params) }.should raise_error(ArgumentError)
181
+ lambda { BinData::String.new(params) }.must_raise ArgumentError
183
182
  end
184
183
  end
185
184
 
@@ -189,31 +188,31 @@ describe BinData::String, "with :trim_padding" do
189
188
  str2 = BinData::String.new(:length => 5, :trim_padding => false)
190
189
  str1.assign("abc")
191
190
  str2.assign("abc")
192
- str1.should == "abc\0\0"
193
- str2.should == "abc\0\0"
191
+ str1.must_equal "abc\0\0"
192
+ str2.must_equal "abc\0\0"
194
193
  end
195
194
 
196
- context "trim padding set" do
197
- subject { BinData::String.new(:pad_byte => 'R', :trim_padding => true) }
195
+ describe "trim padding set" do
196
+ let(:obj) { BinData::String.new(:pad_byte => 'R', :trim_padding => true) }
198
197
 
199
198
  it "trims the value" do
200
- subject.assign("abcRR")
201
- subject.should == "abc"
199
+ obj.assign("abcRR")
200
+ obj.must_equal "abc"
202
201
  end
203
202
 
204
203
  it "does not affect num_bytes" do
205
- subject.assign("abcRR")
206
- subject.num_bytes.should == 5
204
+ obj.assign("abcRR")
205
+ obj.num_bytes.must_equal 5
207
206
  end
208
207
 
209
208
  it "trims if last char is :pad_byte" do
210
- subject.assign("abcRR")
211
- subject.should == "abc"
209
+ obj.assign("abcRR")
210
+ obj.must_equal "abc"
212
211
  end
213
212
 
214
213
  it "does not trim if value contains :pad_byte not at the end" do
215
- subject.assign("abcRRde")
216
- subject.should == "abcRRde"
214
+ obj.assign("abcRRde")
215
+ obj.must_equal "abcRRde"
217
216
  end
218
217
  end
219
218
  end
@@ -224,38 +223,38 @@ describe BinData::String, "with :pad_front" do
224
223
  str2 = BinData::String.new(:length => 5, :pad_front => false)
225
224
  str1.assign("abc")
226
225
  str2.assign("abc")
227
- str1.should == "abc\0\0"
228
- str2.should == "abc\0\0"
226
+ str1.must_equal "abc\0\0"
227
+ str2.must_equal "abc\0\0"
229
228
  end
230
229
 
231
230
  it "pads to the front" do
232
231
  str = BinData::String.new(:length => 5, :pad_byte => 'R', :pad_front => true)
233
232
  str.assign("abc")
234
- str.should == "RRabc"
233
+ str.must_equal "RRabc"
235
234
  end
236
235
 
237
236
  it "can alternatively be accesses by :pad_left" do
238
237
  str = BinData::String.new(:length => 5, :pad_byte => 'R', :pad_left => true)
239
238
  str.assign("abc")
240
- str.should == "RRabc"
239
+ str.must_equal "RRabc"
241
240
  end
242
241
 
243
- context "and :trim_padding" do
244
- subject { BinData::String.new(:length => 5, :pad_byte => 'R', :pad_front => true, :trim_padding => true) }
242
+ describe "and :trim_padding" do
243
+ let(:obj) { BinData::String.new(:length => 5, :pad_byte => 'R', :pad_front => true, :trim_padding => true) }
245
244
 
246
245
  it "assigns" do
247
- subject.assign("abc")
248
- subject.should == "abc"
246
+ obj.assign("abc")
247
+ obj.must_equal "abc"
249
248
  end
250
249
 
251
250
  it "has to_binary_s" do
252
- subject.assign("abc")
253
- subject.to_binary_s.should == "RRabc"
251
+ obj.assign("abc")
252
+ obj.to_binary_s.must_equal "RRabc"
254
253
  end
255
254
 
256
255
  it "reads" do
257
- subject.read "RRabc"
258
- subject.should == "abc"
256
+ obj.read "RRabc"
257
+ obj.must_equal "abc"
259
258
  end
260
259
  end
261
260
  end
@@ -268,32 +267,32 @@ describe BinData::String, "with Ruby 1.9 encodings" do
268
267
  end
269
268
  end
270
269
 
271
- subject { UTF8String.new }
270
+ let(:obj) { UTF8String.new }
272
271
  let(:binary_str) { binary("\xC3\x85\xC3\x84\xC3\x96") }
273
272
  let(:utf8_str) { binary_str.dup.force_encoding('UTF-8') }
274
273
 
275
274
  it "stores assigned values as binary" do
276
- subject.assign(utf8_str)
277
- subject.to_binary_s.should == binary_str
275
+ obj.assign(utf8_str)
276
+ obj.to_binary_s.must_equal binary_str
278
277
  end
279
278
 
280
279
  it "stores read values as binary" do
281
- subject = UTF8String.new(:read_length => binary_str.length)
282
- subject.read(binary_str)
280
+ obj = UTF8String.new(:read_length => binary_str.length)
281
+ obj.read(binary_str)
283
282
 
284
- subject.to_binary_s.should == binary_str
283
+ obj.to_binary_s.must_equal binary_str
285
284
  end
286
285
 
287
286
  it "returns values in correct encoding" do
288
- subject.assign(utf8_str)
287
+ obj.assign(utf8_str)
289
288
 
290
- subject.snapshot.should == utf8_str
289
+ obj.snapshot.must_equal utf8_str
291
290
  end
292
291
 
293
292
  it "has correct num_bytes" do
294
- subject.assign(utf8_str)
293
+ obj.assign(utf8_str)
295
294
 
296
- subject.num_bytes.should == binary_str.length
295
+ obj.num_bytes.must_equal binary_str.length
297
296
  end
298
297
  end
299
298
  end