bindata 1.4.3 → 1.4.4

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.

data/spec/lazy_spec.rb CHANGED
@@ -26,6 +26,8 @@ class MockBinDataObject
26
26
  def lazy_evaluator
27
27
  BinData::LazyEvaluator.new(self)
28
28
  end
29
+
30
+ alias_method :safe_respond_to?, :respond_to?
29
31
  end
30
32
 
31
33
  def lazy_eval(*rest)
@@ -39,34 +41,34 @@ describe BinData::LazyEvaluator, "with no parents" do
39
41
  MockBinDataObject.new(methods, params)
40
42
  }
41
43
 
42
- it "should evaluate raw value when instantiated" do
44
+ it "evaluates raw value when instantiated" do
43
45
  lazy_eval(5).should == 5
44
46
  end
45
47
 
46
- it "should evaluate raw value" do
48
+ it "evaluates raw value" do
47
49
  lazy_eval(5).should == 5
48
50
  end
49
51
 
50
- it "should evaluate value" do
52
+ it "evaluates value" do
51
53
  lazy_eval(lambda { 5 }).should == 5
52
54
  end
53
55
 
54
- it "should evaluate overrides" do
56
+ it "evaluates overrides" do
55
57
  lazy_eval(lambda { o1 }, :o1 => 'o1').should == 'o1'
56
58
  end
57
59
 
58
- it "should not resolve any unknown methods" do
59
- lambda { lazy_eval(lambda { unknown }) }.should raise_error(NameError)
60
- lambda { lazy_eval(lambda { m1 }) }.should raise_error(NameError)
61
- lambda { lazy_eval(lambda { p1 }) }.should raise_error(NameError)
60
+ it "does not resolve any unknown methods" do
61
+ expect { lazy_eval(lambda { unknown }) }.to raise_error(NameError)
62
+ expect { lazy_eval(lambda { m1 }) }.to raise_error(NameError)
63
+ expect { lazy_eval(lambda { p1 }) }.to raise_error(NameError)
62
64
  end
63
65
 
64
- it "should not have a parent" do
66
+ it "does not have a parent" do
65
67
  lazy_eval(lambda { parent }).should be_nil
66
68
  end
67
69
 
68
- it "should not resolve #index" do
69
- lambda { lazy_eval(lambda { index }) }.should raise_error(NoMethodError)
70
+ it "does not resolve #index" do
71
+ expect { lazy_eval(lambda { index }) }.to raise_error(NoMethodError)
70
72
  end
71
73
  end
72
74
 
@@ -85,48 +87,48 @@ describe BinData::LazyEvaluator, "with one parent" do
85
87
  MockBinDataObject.new(methods, params, parent_obj)
86
88
  }
87
89
 
88
- it "should evaluate raw value" do
90
+ it "evaluates raw value" do
89
91
  lazy_eval(5).should == 5
90
92
  end
91
93
 
92
- it "should evaluate value" do
94
+ it "evaluates value" do
93
95
  lazy_eval(lambda { 5 }).should == 5
94
96
  end
95
97
 
96
- it "should evaluate overrides before params" do
98
+ it "evaluates overrides before params" do
97
99
  lazy_eval(lambda { p1 }, :p1 => 'o1').should == 'o1'
98
100
  end
99
101
 
100
- it "should evaluate overrides before methods" do
102
+ it "evaluates overrides before methods" do
101
103
  lazy_eval(lambda { m1 }, :m1 => 'o1').should == 'o1'
102
104
  end
103
105
 
104
- it "should not resolve any unknown methods" do
105
- lambda { lazy_eval(lambda { unknown }) }.should raise_error(NameError)
106
+ it "does not resolve any unknown methods" do
107
+ expect { lazy_eval(lambda { unknown }) }.to raise_error(NameError)
106
108
  end
107
109
 
108
- it "should resolve parameters in the parent" do
110
+ it "resolves parameters in the parent" do
109
111
  lazy_eval(lambda { p1 }).should == 'Pp1'
110
112
  end
111
113
 
112
- it "should resolve methods in the parent" do
114
+ it "resolves methods in the parent" do
113
115
  lazy_eval(lambda { m1 }).should == 'Pm1'
114
116
  end
115
117
 
116
- it "should invoke methods in the parent" do
118
+ it "invokes methods in the parent" do
117
119
  lazy_eval(lambda { echo(p1, m1) }).should == ['Pp1', 'Pm1']
118
120
  end
119
121
 
120
- it "should resolve parameters in preference to methods in the parent" do
122
+ it "resolves parameters in preference to methods in the parent" do
121
123
  lazy_eval(lambda { com }).should == 'PpC'
122
124
  end
123
125
 
124
- it "should have a parent" do
126
+ it "has a parent" do
125
127
  lazy_eval(lambda { parent }).should_not be_nil
126
128
  end
127
129
 
128
- it "should not resolve #index" do
129
- lambda { lazy_eval(lambda { index }) }.should raise_error(NoMethodError)
130
+ it "does not resolve #index" do
131
+ expect { lazy_eval(lambda { index }) }.to raise_error(NoMethodError)
130
132
  end
131
133
  end
132
134
 
@@ -157,59 +159,59 @@ describe BinData::LazyEvaluator, "with nested parents" do
157
159
  MockBinDataObject.new(methods, params, parent_obj)
158
160
  }
159
161
 
160
- it "should accept symbols as a shortcut to lambdas" do
162
+ it "accepts symbols as a shortcut to lambdas" do
161
163
  lazy_eval(:p1).should == 'Pp1'
162
164
  lazy_eval(:p2).should == 'PPp2'
163
165
  lazy_eval(:m1).should == 'Pm1'
164
166
  lazy_eval(:m2).should == 'PPm2'
165
167
  end
166
168
 
167
- it "should not resolve any unknown methods" do
168
- lambda { lazy_eval(lambda { unknown }) }.should raise_error(NameError)
169
+ it "does not resolve any unknown methods" do
170
+ expect { lazy_eval(lambda { unknown }) }.to raise_error(NameError)
169
171
  end
170
172
 
171
- it "should resolve parameters in the parent" do
173
+ it "resolves parameters in the parent" do
172
174
  lazy_eval(lambda { p1 }).should == 'Pp1'
173
175
  end
174
176
 
175
- it "should resolve methods in the parent" do
177
+ it "resolves methods in the parent" do
176
178
  lazy_eval(lambda { m1 }).should == 'Pm1'
177
179
  end
178
180
 
179
- it "should resolve parameters in the parent's parent" do
181
+ it "resolves parameters in the parent's parent" do
180
182
  lazy_eval(lambda { p2 }).should == 'PPp2'
181
183
  end
182
184
 
183
- it "should resolve methods in the parent's parent" do
185
+ it "resolves methods in the parent's parent" do
184
186
  lazy_eval(lambda { m2 }).should == 'PPm2'
185
187
  end
186
188
 
187
- it "should invoke methods in the parent" do
189
+ it "invokes methods in the parent" do
188
190
  lazy_eval(lambda { echo(m1) }).should == ['P', 'Pm1']
189
191
  end
190
192
 
191
- it "should invoke methods in the parent's parent" do
193
+ it "invokes methods in the parent's parent" do
192
194
  lazy_eval(lambda { parent.echo(m1) }, { :m1 => 'o1'}).should == ['PP', 'o1']
193
195
  end
194
196
 
195
- it "should invoke methods in the parent's parent" do
197
+ it "invokes methods in the parent's parent" do
196
198
  lazy_eval(lambda { echo2(m1) }).should == ['PP2', 'Pm1']
197
199
  end
198
200
 
199
- it "should resolve parameters in preference to methods in the parent" do
201
+ it "resolves parameters in preference to methods in the parent" do
200
202
  lazy_eval(lambda { com }).should == 'PpC'
201
203
  end
202
204
 
203
- it "should resolve methods in the parent explicitly" do
205
+ it "resolves methods in the parent explicitly" do
204
206
  lazy_eval(lambda { parent.m1 }).should == 'PPm1'
205
207
  end
206
208
 
207
- it "should cascade lambdas " do
209
+ it "cascades lambdas " do
208
210
  lazy_eval(lambda { sym1 }).should == 'PPm2'
209
211
  lazy_eval(lambda { sym2 }).should == 'PPm2'
210
212
  end
211
213
 
212
- it "should not resolve #index" do
213
- lambda { lazy_eval(lambda { index }) }.should raise_error(NoMethodError)
214
+ it "does not resolve #index" do
215
+ expect { lazy_eval(lambda { index }) }.to raise_error(NoMethodError)
214
216
  end
215
217
  end
@@ -4,12 +4,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
4
4
  require 'bindata'
5
5
 
6
6
  describe BinData::Primitive do
7
- let(:r) { BinData::RegisteredClasses }
8
-
9
- it "should not be registered" do
10
- lambda {
11
- r.lookup("Primitive")
12
- }.should raise_error(BinData::UnRegisteredTypeError)
7
+ it "is not registered" do
8
+ expect {
9
+ BinData::RegisteredClasses.lookup("Primitive")
10
+ }.to raise_error(BinData::UnRegisteredTypeError)
13
11
  end
14
12
  end
15
13
 
@@ -20,14 +18,14 @@ describe BinData::Primitive, "all subclasses" do
20
18
 
21
19
  subject { SubClassOfPrimitive.new }
22
20
 
23
- it "should raise errors on unimplemented methods" do
24
- lambda { subject.set(nil) }.should raise_error(NotImplementedError)
25
- lambda { subject.get }.should raise_error(NotImplementedError)
21
+ it "raise errors on unimplemented methods" do
22
+ expect { subject.set(nil) }.to raise_error(NotImplementedError)
23
+ expect { subject.get }.to raise_error(NotImplementedError)
26
24
  end
27
25
  end
28
26
 
29
27
  describe BinData::Primitive, "when defining with errors" do
30
- it "should fail on non registered types" do
28
+ it "fails on non registered types" do
31
29
  lambda {
32
30
  class BadTypePrimitive < BinData::Primitive
33
31
  non_registered_type :a
@@ -37,7 +35,7 @@ describe BinData::Primitive, "when defining with errors" do
37
35
  }
38
36
  end
39
37
 
40
- it "should fail on duplicate names" do
38
+ it "fails on duplicate names" do
41
39
  lambda {
42
40
  class DuplicateNamePrimitive < BinData::Primitive
43
41
  int8 :a
@@ -49,7 +47,7 @@ describe BinData::Primitive, "when defining with errors" do
49
47
  }
50
48
  end
51
49
 
52
- it "should fail when field name shadows an existing method" do
50
+ it "fails when field name shadows an existing method" do
53
51
  lambda {
54
52
  class ExistingNamePrimitive < BinData::Primitive
55
53
  int8 :object_id
@@ -59,7 +57,7 @@ describe BinData::Primitive, "when defining with errors" do
59
57
  }
60
58
  end
61
59
 
62
- it "should fail on unknown endian" do
60
+ it "fails on unknown endian" do
63
61
  lambda {
64
62
  class BadEndianPrimitive < BinData::Primitive
65
63
  endian 'a bad value'
@@ -80,37 +78,37 @@ describe BinData::Primitive do
80
78
 
81
79
  subject { PrimitiveWithEndian.new }
82
80
 
83
- it "should assign value" do
81
+ it "assigns value" do
84
82
  subject.value = 5
85
83
  subject.value.should == 5
86
84
  end
87
85
 
88
- it "should produce binary string" do
86
+ it "produces binary string" do
89
87
  subject.assign(5)
90
88
  subject.to_binary_s.should == "\x05\x00"
91
89
  end
92
90
 
93
- it "should read value" do
91
+ it "reads value" do
94
92
  subject.read("\x00\x01")
95
93
  subject.should == 0x100
96
94
  end
97
95
 
98
- it "should accept standard parameters" do
96
+ it "accepts standard parameters" do
99
97
  subject = PrimitiveWithEndian.new(:initial_value => 2)
100
98
  subject.to_binary_s.should == "\x02\x00"
101
99
  end
102
100
 
103
- it "should return num_bytes" do
101
+ it "returns num_bytes" do
104
102
  subject.num_bytes.should == 2
105
103
  end
106
104
 
107
- it "should raise error on missing methods" do
108
- lambda {
105
+ it "raises error on missing methods" do
106
+ expect {
109
107
  subject.does_not_exist
110
- }.should raise_error(NoMethodError)
108
+ }.to raise_error(NoMethodError)
111
109
  end
112
110
 
113
- it "should use read value whilst reading" do
111
+ it "uses read value whilst reading" do
114
112
  subject = PrimitiveWithEndian.new(:value => 2)
115
113
  subject.read "\x05\x00"
116
114
  subject.should == 2
@@ -119,7 +117,7 @@ describe BinData::Primitive do
119
117
  subject.should == 5
120
118
  end
121
119
 
122
- it "should behave as primitive" do
120
+ it "behaves as primitive" do
123
121
  subject.assign(5)
124
122
  (2 + subject).should == 7
125
123
  end
@@ -132,7 +130,7 @@ describe BinData::Primitive, "requiring custom parameters" do
132
130
  def set(v); self.a = v; end
133
131
  end
134
132
 
135
- it "should pass parameters correctly" do
133
+ it "passes parameters correctly" do
136
134
  subject = PrimitiveWithCustom.new(:iv => 5)
137
135
  subject.should == 5
138
136
  end
@@ -147,11 +145,11 @@ describe BinData::Primitive, "with custom mandatory parameters" do
147
145
  def set(v); self.a = v; end
148
146
  end
149
147
 
150
- it "should raise error if mandatory parameter is not supplied" do
151
- lambda { MandatoryPrimitive.new }.should raise_error(ArgumentError)
148
+ it "raises error if mandatory parameter is not supplied" do
149
+ expect { MandatoryPrimitive.new }.to raise_error(ArgumentError)
152
150
  end
153
151
 
154
- it "should use mandatory parameter" do
152
+ it "uses mandatory parameter" do
155
153
  subject = MandatoryPrimitive.new(:arg1 => 5)
156
154
  subject.should == 5
157
155
  end
@@ -166,16 +164,16 @@ describe BinData::Primitive, "with custom default parameters" do
166
164
  def set(v); self.a = v; end
167
165
  end
168
166
 
169
- it "should not raise error if default parameter is not supplied" do
170
- lambda { DefaultPrimitive.new }.should_not raise_error(ArgumentError)
167
+ it "does not raise error if default parameter is not supplied" do
168
+ expect { DefaultPrimitive.new }.not_to raise_error(ArgumentError)
171
169
  end
172
170
 
173
- it "should use default parameter" do
171
+ it "uses default parameter" do
174
172
  subject = DefaultPrimitive.new
175
173
  subject.should == 5
176
174
  end
177
175
 
178
- it "should be able to override default parameter" do
176
+ it "overrides default parameter" do
179
177
  subject = DefaultPrimitive.new(:arg1 => 7)
180
178
  subject.should == 7
181
179
  end
@@ -192,12 +190,12 @@ describe BinData::Primitive, "subclassed with default parameter" do
192
190
  default_parameter :initial_value => 5
193
191
  end
194
192
 
195
- it "should override initial_value" do
193
+ it "overrides initial_value" do
196
194
  a = ChildDerivedPrimitive.new(:initial_value => 7)
197
195
  a.to_binary_s.should == "\000\007"
198
196
  end
199
197
 
200
- it "should use default parameter" do
198
+ it "uses default parameter" do
201
199
  a = ChildDerivedPrimitive.new
202
200
  a.to_binary_s.should == "\000\005"
203
201
  end
data/spec/record_spec.rb CHANGED
@@ -4,17 +4,15 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
4
4
  require 'bindata'
5
5
 
6
6
  describe BinData::Record do
7
- let(:r) { BinData::RegisteredClasses }
8
-
9
- it "should not be registered" do
10
- lambda {
11
- r.lookup("Record")
12
- }.should raise_error(BinData::UnRegisteredTypeError)
7
+ it "is not registered" do
8
+ expect {
9
+ BinData::RegisteredClasses.lookup("Record")
10
+ }.to raise_error(BinData::UnRegisteredTypeError)
13
11
  end
14
12
  end
15
13
 
16
14
  describe BinData::Record, "when defining with errors" do
17
- it "should fail on non registered types" do
15
+ it "fails on non registered types" do
18
16
  lambda {
19
17
  class BadTypeRecord < BinData::Record
20
18
  non_registered_type :a
@@ -24,7 +22,7 @@ describe BinData::Record, "when defining with errors" do
24
22
  }
25
23
  end
26
24
 
27
- it "should give correct error message for non registered nested types" do
25
+ it "gives correct error message for non registered nested types" do
28
26
  lambda {
29
27
  class BadNestedTypeRecord < BinData::Record
30
28
  array :a, :type => :non_registered_type
@@ -34,7 +32,7 @@ describe BinData::Record, "when defining with errors" do
34
32
  }
35
33
  end
36
34
 
37
- it "should give correct error message for non registered nested types in blocks" do
35
+ it "gives correct error message for non registered nested types in blocks" do
38
36
  lambda {
39
37
  class BadNestedTypeInBlockRecord < BinData::Record
40
38
  array :a do
@@ -46,7 +44,7 @@ describe BinData::Record, "when defining with errors" do
46
44
  }
47
45
  end
48
46
 
49
- it "should fail on nested choice when missing names" do
47
+ it "fails on nested choice when missing names" do
50
48
  lambda {
51
49
  class MissingChoiceNamesRecord < BinData::Record
52
50
  choice do
@@ -59,7 +57,7 @@ describe BinData::Record, "when defining with errors" do
59
57
  }
60
58
  end
61
59
 
62
- it "should fail on malformed names" do
60
+ it "fails on malformed names" do
63
61
  lambda {
64
62
  class MalformedNameRecord < BinData::Record
65
63
  int8 :a
@@ -70,7 +68,7 @@ describe BinData::Record, "when defining with errors" do
70
68
  }
71
69
  end
72
70
 
73
- it "should fail on duplicate names" do
71
+ it "fails on duplicate names" do
74
72
  lambda {
75
73
  class DuplicateNameRecord < BinData::Record
76
74
  int8 :a
@@ -82,7 +80,7 @@ describe BinData::Record, "when defining with errors" do
82
80
  }
83
81
  end
84
82
 
85
- it "should fail on reserved names" do
83
+ it "fails on reserved names" do
86
84
  lambda {
87
85
  class ReservedNameRecord < BinData::Record
88
86
  int8 :a
@@ -93,7 +91,7 @@ describe BinData::Record, "when defining with errors" do
93
91
  }
94
92
  end
95
93
 
96
- it "should fail when field name shadows an existing method" do
94
+ it "fails when field name shadows an existing method" do
97
95
  lambda {
98
96
  class ExistingNameRecord < BinData::Record
99
97
  int8 :object_id
@@ -103,7 +101,7 @@ describe BinData::Record, "when defining with errors" do
103
101
  }
104
102
  end
105
103
 
106
- it "should fail on unknown endian" do
104
+ it "fails on unknown endian" do
107
105
  lambda {
108
106
  class BadEndianRecord < BinData::Record
109
107
  endian 'a bad value'
@@ -125,16 +123,16 @@ describe BinData::Record, "with anonymous fields" do
125
123
 
126
124
  subject { AnonymousRecord.new }
127
125
 
128
- it "should only show non anonymous fields" do
126
+ it "only shows non anonymous fields" do
129
127
  subject.field_names.should == ["a"]
130
128
  end
131
129
 
132
- it "should not include anonymous fields in snapshot" do
130
+ it "does not include anonymous fields in snapshot" do
133
131
  subject.a = 5
134
132
  subject.snapshot.should == {"a" => 5}
135
133
  end
136
134
 
137
- it "should write anonymous fields" do
135
+ it "writes anonymous fields" do
138
136
  str = "\001\002\003\004\005"
139
137
  subject.read(str)
140
138
  subject.a.clear
@@ -153,11 +151,11 @@ describe BinData::Record, "with hidden fields" do
153
151
 
154
152
  subject { HiddenRecord.new }
155
153
 
156
- it "should only show fields that aren't hidden" do
154
+ it "only shows fields that aren't hidden" do
157
155
  subject.field_names.should == ["a", "d"]
158
156
  end
159
157
 
160
- it "should be able to access hidden fields directly" do
158
+ it "accesses hidden fields directly" do
161
159
  subject.b.should == 10
162
160
  subject.c = 15
163
161
  subject.c.should == 15
@@ -165,7 +163,7 @@ describe BinData::Record, "with hidden fields" do
165
163
  subject.should respond_to(:b=)
166
164
  end
167
165
 
168
- it "should not include hidden fields in snapshot" do
166
+ it "does not include hidden fields in snapshot" do
169
167
  subject.b = 5
170
168
  subject.snapshot.should == {"a" => 0, "d" => 5}
171
169
  end
@@ -179,24 +177,24 @@ describe BinData::Record, "with multiple fields" do
179
177
 
180
178
  subject { MultiFieldRecord.new(:a => 1, :b => 2) }
181
179
 
182
- it "should return num_bytes" do
180
+ it "returns num_bytes" do
183
181
  subject.a.num_bytes.should == 1
184
182
  subject.b.num_bytes.should == 1
185
183
  subject.num_bytes.should == 2
186
184
  end
187
185
 
188
- it "should identify accepted parameters" do
186
+ it "identifies accepted parameters" do
189
187
  BinData::Record.accepted_parameters.all.should include(:hide)
190
188
  BinData::Record.accepted_parameters.all.should include(:endian)
191
189
  end
192
190
 
193
- it "should clear" do
191
+ it "clears" do
194
192
  subject.a = 6
195
193
  subject.clear
196
194
  subject.should be_clear
197
195
  end
198
196
 
199
- it "should clear individual elements" do
197
+ it "clears individual elements" do
200
198
  subject.a = 6
201
199
  subject.b = 7
202
200
  subject.a.clear
@@ -204,30 +202,30 @@ describe BinData::Record, "with multiple fields" do
204
202
  subject.b.should_not be_clear
205
203
  end
206
204
 
207
- it "should write ordered" do
205
+ it "writes ordered" do
208
206
  subject.to_binary_s.should == "\x01\x02"
209
207
  end
210
208
 
211
- it "should read ordered" do
209
+ it "reads ordered" do
212
210
  subject.read("\x03\x04")
213
211
 
214
212
  subject.a.should == 3
215
213
  subject.b.should == 4
216
214
  end
217
215
 
218
- it "should return a snapshot" do
216
+ it "returns a snapshot" do
219
217
  snap = subject.snapshot
220
218
  snap.a.should == 1
221
219
  snap.b.should == 2
222
220
  snap.should == { "a" => 1, "b" => 2 }
223
221
  end
224
222
 
225
- it "should return field_names" do
223
+ it "returns field_names" do
226
224
  subject.field_names.should == ["a", "b"]
227
225
  end
228
226
 
229
- it "should fail on unknown method call" do
230
- lambda { subject.does_not_exist }.should raise_error(NoMethodError)
227
+ it "fails on unknown method call" do
228
+ expect { subject.does_not_exist }.to raise_error(NoMethodError)
231
229
  end
232
230
  end
233
231
 
@@ -247,22 +245,22 @@ describe BinData::Record, "with nested structs" do
247
245
 
248
246
  subject { NestedStructRecord.new }
249
247
 
250
- it "should included nested field names" do
248
+ it "includes nested field names" do
251
249
  subject.field_names.should == ["a", "b", "c"]
252
250
  end
253
251
 
254
- it "should hide nested field names" do
252
+ it "hides nested field names" do
255
253
  subject.b.field_names.should == ["x"]
256
254
  end
257
255
 
258
- it "should access nested fields" do
256
+ it "accesses nested fields" do
259
257
  subject.a.should == 6
260
258
  subject.b.w.should == 3
261
259
  subject.b.x.should == 6
262
260
  subject.c.y.should == 3
263
261
  end
264
262
 
265
- it "should return correct offset" do
263
+ it "returns correct offset" do
266
264
  subject.offset.should == 0
267
265
  subject.b.offset.should == 1
268
266
  subject.b.w.offset.should == 1
@@ -270,7 +268,7 @@ describe BinData::Record, "with nested structs" do
270
268
  subject.c.z.offset.should == 4
271
269
  end
272
270
 
273
- it "should return correct rel_offset" do
271
+ it "returns correct rel_offset" do
274
272
  subject.rel_offset.should == 0
275
273
  subject.b.rel_offset.should == 1
276
274
  subject.b.w.rel_offset.should == 0
@@ -278,7 +276,7 @@ describe BinData::Record, "with nested structs" do
278
276
  subject.c.z.rel_offset.should == 1
279
277
  end
280
278
 
281
- it "should assign nested fields" do
279
+ it "assigns nested fields" do
282
280
  subject.assign(:a => 2, :b => {:w => 4})
283
281
  subject.a.should == 2
284
282
  subject.b.w.should == 4
@@ -296,7 +294,7 @@ describe BinData::Record, "with nested array of primitives" do
296
294
 
297
295
  subject { NestedPrimitiveArrayRecord.new }
298
296
 
299
- it "should use block as :type" do
297
+ it "uses block as :type" do
300
298
  subject.snapshot.should == {"a" => [0, 1, 2]}
301
299
  end
302
300
  end
@@ -311,7 +309,7 @@ describe BinData::Record, "with nested array of structs" do
311
309
 
312
310
  subject { NestedStructArrayRecord.new }
313
311
 
314
- it "should use block as struct for :type" do
312
+ it "uses block as struct for :type" do
315
313
  subject.a[0].b = 2
316
314
  subject.snapshot.should == {"a" => [{"b" => 2, "c" => 0}]}
317
315
  end
@@ -383,7 +381,7 @@ describe BinData::Record, "with an endian defined" do
383
381
 
384
382
  subject { RecordWithEndian.new }
385
383
 
386
- it "should use correct endian" do
384
+ it "uses correct endian" do
387
385
  subject.a = 1
388
386
  subject.b = 2.0
389
387
  subject.c[0] = 3
@@ -407,11 +405,11 @@ describe BinData::Record, "defined recursively" do
407
405
  recursive_record :nxt, :onlyif => lambda { has_nxt > 0 }
408
406
  end
409
407
 
410
- it "should be able to be created" do
408
+ it "can be created" do
411
409
  subject = RecursiveRecord.new
412
410
  end
413
411
 
414
- it "should read" do
412
+ it "reads" do
415
413
  str = "\x00\x01\x01\x00\x02\x01\x00\x03\x00"
416
414
  subject = RecursiveRecord.read(str)
417
415
  subject.val.should == 1
@@ -419,14 +417,14 @@ describe BinData::Record, "defined recursively" do
419
417
  subject.nxt.nxt.val.should == 3
420
418
  end
421
419
 
422
- it "should be assignable on demand" do
420
+ it "is assignable on demand" do
423
421
  subject = RecursiveRecord.new
424
422
  subject.val = 13
425
423
  subject.nxt.val = 14
426
424
  subject.nxt.nxt.val = 15
427
425
  end
428
426
 
429
- it "should write" do
427
+ it "writes" do
430
428
  subject = RecursiveRecord.new
431
429
  subject.val = 5
432
430
  subject.nxt.val = 6
@@ -442,11 +440,11 @@ describe BinData::Record, "with custom mandatory parameters" do
442
440
  uint8 :a, :value => :arg1
443
441
  end
444
442
 
445
- it "should raise error if mandatory parameter is not supplied" do
446
- lambda { MandatoryRecord.new }.should raise_error(ArgumentError)
443
+ it "raises error if mandatory parameter is not supplied" do
444
+ expect { MandatoryRecord.new }.to raise_error(ArgumentError)
447
445
  end
448
446
 
449
- it "should use mandatory parameter" do
447
+ it "uses mandatory parameter" do
450
448
  subject = MandatoryRecord.new(:arg1 => 5)
451
449
  subject.a.should == 5
452
450
  end
@@ -460,26 +458,26 @@ describe BinData::Record, "with custom default parameters" do
460
458
  uint8 :b
461
459
  end
462
460
 
463
- it "should not raise error if default parameter is not supplied" do
464
- lambda { DefaultRecord.new }.should_not raise_error(ArgumentError)
461
+ it "does not raise error if default parameter is not supplied" do
462
+ expect { DefaultRecord.new }.not_to raise_error(ArgumentError)
465
463
  end
466
464
 
467
- it "should use default parameter" do
465
+ it "uses default parameter" do
468
466
  subject = DefaultRecord.new
469
467
  subject.a.should == 5
470
468
  end
471
469
 
472
- it "should be able to override default parameter" do
470
+ it "overrides default parameter" do
473
471
  subject = DefaultRecord.new(:arg1 => 7)
474
472
  subject.a.should == 7
475
473
  end
476
474
 
477
- it "should accept values" do
475
+ it "accepts values" do
478
476
  subject = DefaultRecord.new(:b => 2)
479
477
  subject.b.should == 2
480
478
  end
481
479
 
482
- it "should accept values and parameters" do
480
+ it "accepts values and parameters" do
483
481
  subject = DefaultRecord.new({:b => 2}, :arg1 => 3)
484
482
  subject.a.should == 3
485
483
  subject.b.should == 2
@@ -499,7 +497,7 @@ describe BinData::Record, "with :onlyif" do
499
497
  its(:snapshot) { should == {"a" => 3, "b" => 5} }
500
498
  its(:to_binary_s) { should == "\x03\x05" }
501
499
 
502
- it "should read as expected" do
500
+ it "reads as expected" do
503
501
  subject.read("\x01\x02")
504
502
  subject.snapshot.should == {"a" => 1, "c" => 2}
505
503
  end
@@ -518,15 +516,15 @@ describe BinData::Record, "derived classes" do
518
516
  uint8 :c
519
517
  end
520
518
 
521
- it "should not affect parent" do
519
+ it "does not affect parent" do
522
520
  ParentRecord.new.field_names.should == ["a"]
523
521
  end
524
522
 
525
- it "should inherit fields for first child" do
523
+ it "inherits fields for first child" do
526
524
  Child1Record.new.field_names.should == ["a", "b"]
527
525
  end
528
526
 
529
- it "should inherit fields for second child" do
527
+ it "inherits fields for second child" do
530
528
  Child2Record.new.field_names.should == ["a", "b", "c"]
531
529
  end
532
530
  end