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.

@@ -12,14 +12,14 @@ describe BinData::ResumeByteAlignment do
12
12
 
13
13
  subject { ResumeAlignmentRecord.new }
14
14
 
15
- it "should reset read alignment" do
15
+ it "resets read alignment" do
16
16
  subject.read "\x12\x34"
17
17
 
18
18
  subject.a.should == 1
19
19
  subject.b.should == 3
20
20
  end
21
21
 
22
- it "should reset write alignment" do
22
+ it "resets write alignment" do
23
23
  subject.assign(:a => 2, :b => 7)
24
24
 
25
25
  subject.to_binary_s.should == "\x20\x70"
@@ -27,12 +27,12 @@ describe BinData::ResumeByteAlignment do
27
27
  end
28
28
 
29
29
  describe BinData::BitAligned do
30
- it "should not apply to BinData::Primitives" do
31
- lambda {
30
+ it "does not apply to BinData::Primitives" do
31
+ expect {
32
32
  class BitAlignedPrimitive < BinData::Primitive
33
33
  bit_aligned
34
34
  end
35
- }.should raise_error
35
+ }.to raise_error
36
36
  end
37
37
 
38
38
  class BitString < BinData::String
@@ -49,12 +49,12 @@ describe BinData::BitAligned do
49
49
 
50
50
  its(:num_bytes) { should == 3 }
51
51
 
52
- it "should read" do
52
+ it "reads as expected" do
53
53
  subject.read("\x56\x36\x42")
54
54
  subject.should == {"preamble" => 5, "str" => "cd", "afterward" => 2}
55
55
  end
56
56
 
57
- it "should write" do
57
+ it "writes as expected" do
58
58
  subject.assign(:preamble => 5, :str => "ab", :afterward => 1)
59
59
  subject.to_binary_s.should == "\x56\x16\x21"
60
60
  end
data/spec/array_spec.rb CHANGED
@@ -4,23 +4,31 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_common"))
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "example"))
5
5
  require 'bindata/array'
6
6
  require 'bindata/int'
7
+ require 'bindata/string'
7
8
 
8
9
  describe BinData::Array, "when instantiating" do
9
- it "should ensure mandatory parameters are supplied" do
10
- args = {}
11
- lambda { BinData::Array.new(args) }.should raise_error(ArgumentError)
12
- args = {:initial_length => 3}
13
- lambda { BinData::Array.new(args) }.should raise_error(ArgumentError)
10
+ context "with no mandatory parameters supplied" do
11
+ it "raises an error" do
12
+ args = {}
13
+ expect { BinData::Array.new(args) }.to raise_error(ArgumentError)
14
+ end
15
+ end
16
+
17
+ context "with some but not all mandatory parameters supplied" do
18
+ it "raises an error" do
19
+ args = {:initial_length => 3}
20
+ expect { BinData::Array.new(args) }.to raise_error(ArgumentError)
21
+ end
14
22
  end
15
23
 
16
- it "should fail if a given type is unknown" do
24
+ it "fails if a given type is unknown" do
17
25
  args = {:type => :does_not_exist, :initial_length => 3}
18
- lambda { BinData::Array.new(args) }.should raise_error(BinData::UnRegisteredTypeError)
26
+ expect { BinData::Array.new(args) }.to raise_error(BinData::UnRegisteredTypeError)
19
27
  end
20
28
 
21
- it "should not allow both :initial_length and :read_until" do
29
+ it "does not allow both :initial_length and :read_until" do
22
30
  args = {:initial_length => 3, :read_until => lambda { false } }
23
- lambda { BinData::Array.new(args) }.should raise_error(ArgumentError)
31
+ expect { BinData::Array.new(args) }.to raise_error(ArgumentError)
24
32
  end
25
33
  end
26
34
 
@@ -30,20 +38,14 @@ describe BinData::Array, "with no elements" do
30
38
  it { should be_clear }
31
39
  it { should be_empty }
32
40
  its(:length) { should be_zero }
41
+ its(:first) { should be_nil }
42
+ its(:last) { should be_nil }
33
43
 
34
- it "should return nil for the first element" do
35
- subject.first.should be_nil
36
- end
37
-
38
- it "should return [] for the first n elements" do
44
+ it "returns [] for the first n elements" do
39
45
  subject.first(3).should == []
40
46
  end
41
47
 
42
- it "should return nil for the last element" do
43
- subject.last.should be_nil
44
- end
45
-
46
- it "should return [] for the last n elements" do
48
+ it "returns [] for the last n elements" do
47
49
  subject.last(3).should == []
48
50
  end
49
51
  end
@@ -61,83 +63,82 @@ describe BinData::Array, "with several elements" do
61
63
  its(:snapshot) { should == [1, 2, 3, 4, 5] }
62
64
  its(:inspect) { should == "[1, 2, 3, 4, 5]" }
63
65
 
64
- it "should coerce to ::Array if required" do
66
+ it "coerces to ::Array if required" do
65
67
  [0].concat(subject).should == [0, 1, 2, 3, 4, 5]
66
68
  end
67
69
 
68
- it "should be able to use methods from Enumerable" do
70
+ it "uses methods from Enumerable" do
69
71
  subject.select { |x| (x % 2) == 0 }.should == [2, 4]
70
72
  end
71
73
 
72
- it "should assign primitive values" do
74
+ it "assigns primitive values" do
73
75
  subject.assign([4, 5, 6])
74
76
  subject.should == [4, 5, 6]
75
77
  end
76
78
 
77
- it "should assign bindata objects" do
79
+ it "assigns bindata objects" do
78
80
  subject.assign([ExampleSingle.new(4), ExampleSingle.new(5), ExampleSingle.new(6)])
79
81
  subject.should == [4, 5, 6]
80
82
  end
81
83
 
82
- it "should assign bindata array" do
83
- array = BinData::Array.new(:type => :example_single)
84
- array.push(4, 5, 6)
84
+ it "assigns a bindata array" do
85
+ array = BinData::Array.new([4, 5, 6], :type => :example_single)
85
86
  subject.assign(array)
86
87
  subject.should == [4, 5, 6]
87
88
  end
88
89
 
89
- it "should return the first element" do
90
+ it "returns the first element" do
90
91
  subject.first.should == 1
91
92
  end
92
93
 
93
- it "should return the first n elements" do
94
+ it "returns the first n elements" do
94
95
  subject[0...3].should == [1, 2, 3]
95
96
  subject.first(3).should == [1, 2, 3]
96
97
  subject.first(99).should == [1, 2, 3, 4, 5]
97
98
  end
98
99
 
99
- it "should return the last element" do
100
+ it "returns the last element" do
100
101
  subject.last.should == 5
101
102
  subject[-1].should == 5
102
103
  end
103
104
 
104
- it "should return the last n elements" do
105
+ it "returns the last n elements" do
105
106
  subject.last(3).should == [3, 4, 5]
106
107
  subject.last(99).should == [1, 2, 3, 4, 5]
107
108
 
108
109
  subject[-3, 100].should == [3, 4, 5]
109
110
  end
110
111
 
111
- it "should clear" do
112
+ it "clears all" do
112
113
  subject[1] = 8
113
114
  subject.clear
114
115
  subject.should == [1, 2, 3, 4, 5]
115
116
  end
116
117
 
117
- it "should clear a single element" do
118
+ it "clears a single element" do
118
119
  subject[1] = 8
119
120
  subject[1].clear
120
121
  subject[1].should == 2
121
122
  end
122
123
 
123
- it "should be clear if all elements are clear" do
124
+ it "is clear if all elements are clear" do
124
125
  subject[1] = 8
125
126
  subject[1].clear
126
127
  subject.should be_clear
127
128
  end
128
129
 
129
- it "should test clear status of individual elements" do
130
+ it "tests clear status of individual elements" do
130
131
  subject[1] = 8
131
132
  subject[0].should be_clear
132
133
  subject[1].should_not be_clear
133
134
  end
134
135
 
135
- it "should be able to directly access elements" do
136
+ it "directly accesses elements" do
136
137
  subject[1] = 8
137
138
  subject[1].should == 8
138
139
  end
139
140
 
140
- it "should symmetrically read and write" do
141
+ it "symmetrically reads and writes" do
141
142
  subject[1] = 8
142
143
  str = subject.to_binary_s
143
144
 
@@ -148,27 +149,27 @@ describe BinData::Array, "with several elements" do
148
149
  subject[1].should == 8
149
150
  end
150
151
 
151
- it "should identify index of elements" do
152
+ it "identifies index of elements" do
152
153
  subject.index(3).should == 2
153
154
  end
154
155
 
155
- it "should return nil for index of non existent element" do
156
+ it "returns nil for index of non existent element" do
156
157
  subject.index(42).should be_nil
157
158
  end
158
159
 
159
- it "should have correct debug name" do
160
+ it "has correct debug name" do
160
161
  subject[2].debug_name.should == "obj[2]"
161
162
  end
162
163
 
163
- it "should have correct offset" do
164
+ it "has correct offset" do
164
165
  subject[2].offset.should == ExampleSingle.new.num_bytes * 2
165
166
  end
166
167
 
167
- it "should have correct num_bytes" do
168
+ it "has correct num_bytes" do
168
169
  subject.num_bytes.should == 5 * ExampleSingle.new.num_bytes
169
170
  end
170
171
 
171
- it "should have correct num_bytes for individual elements" do
172
+ it "has correct num_bytes for individual elements" do
172
173
  subject[0].num_bytes.should == ExampleSingle.new.num_bytes
173
174
  end
174
175
  end
@@ -181,71 +182,71 @@ describe BinData::Array, "when accessing elements" do
181
182
  data
182
183
  }
183
184
 
184
- it "should insert with positive indexes" do
185
+ it "inserts with positive indexes" do
185
186
  subject.insert(2, 30, 40)
186
187
  subject.snapshot.should == [1, 2, 30, 40, 3, 4, 5]
187
188
  end
188
189
 
189
- it "should insert with negative indexes" do
190
+ it "inserts with negative indexes" do
190
191
  subject.insert(-2, 30, 40)
191
192
  subject.snapshot.should == [1, 2, 3, 4, 30, 40, 5]
192
193
  end
193
194
 
194
- it "should push" do
195
+ it "pushes" do
195
196
  subject.push(30, 40)
196
197
  subject.snapshot.should == [1, 2, 3, 4, 5, 30, 40]
197
198
  end
198
199
 
199
- it "should concat" do
200
+ it "concats" do
200
201
  subject.concat([30, 40])
201
202
  subject.snapshot.should == [1, 2, 3, 4, 5, 30, 40]
202
203
  end
203
204
 
204
- it "should unshift" do
205
+ it "unshifts" do
205
206
  subject.unshift(30, 40)
206
207
  subject.snapshot.should == [30, 40, 1, 2, 3, 4, 5]
207
208
  end
208
209
 
209
- it "should automatically extend on [index]" do
210
+ it "automatically extends on [index]" do
210
211
  subject[9].should == 10
211
212
  subject.snapshot.should == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
212
213
  end
213
214
 
214
- it "should automatically extend on []=" do
215
+ it "automatically extends on []=" do
215
216
  subject[9] = 30
216
217
  subject.snapshot.should == [1, 2, 3, 4, 5, 6, 7, 8, 9, 30]
217
218
  end
218
219
 
219
- it "should automatically extend on insert" do
220
+ it "automatically extends on insert" do
220
221
  subject.insert(7, 30, 40)
221
222
  subject.snapshot.should == [1, 2, 3, 4, 5, 6, 7, 30, 40]
222
223
  end
223
224
 
224
- it "should not extend on at" do
225
+ it "does not extend on at" do
225
226
  subject.at(9).should be_nil
226
227
  subject.length.should == 5
227
228
  end
228
229
 
229
- it "should not extend on [start, length]" do
230
+ it "does not extend on [start, length]" do
230
231
  subject[9, 2].should be_nil
231
232
  subject.length.should == 5
232
233
  end
233
234
 
234
- it "should not extend on [range]" do
235
+ it "does not extend on [range]" do
235
236
  subject[9 .. 10].should be_nil
236
237
  subject.length.should == 5
237
238
  end
238
239
 
239
- it "should raise error on bad input to []" do
240
- lambda { subject["a"] }.should raise_error(TypeError)
241
- lambda { subject[1, "a"] }.should raise_error(TypeError)
240
+ it "raises error on bad input to []" do
241
+ expect { subject["a"] }.to raise_error(TypeError)
242
+ expect { subject[1, "a"] }.to raise_error(TypeError)
242
243
  end
243
244
  end
244
245
 
245
246
  describe BinData::Array, "with :read_until" do
246
247
 
247
248
  context "containing +element+" do
248
- it "should read until the sentinel is reached" do
249
+ it "reads until the sentinel is reached" do
249
250
  read_until = lambda { element == 5 }
250
251
  subject = BinData::Array.new(:type => :int8, :read_until => read_until)
251
252
 
@@ -255,7 +256,7 @@ describe BinData::Array, "with :read_until" do
255
256
  end
256
257
 
257
258
  context "containing +array+ and +index+" do
258
- it "should read until the sentinel is reached" do
259
+ it "reads until the sentinel is reached" do
259
260
  read_until = lambda { index >= 2 and array[index - 2] == 5 }
260
261
  subject = BinData::Array.new(:type => :int8, :read_until => read_until)
261
262
 
@@ -264,25 +265,25 @@ describe BinData::Array, "with :read_until" do
264
265
  end
265
266
  end
266
267
 
267
- context "== :eof" do
268
- it "should read records until eof" do
268
+ context ":eof" do
269
+ it "reads records until eof" do
269
270
  subject = BinData::Array.new(:type => :int8, :read_until => :eof)
270
271
 
271
272
  subject.read "\x01\x02\x03"
272
273
  subject.should == [1, 2, 3]
273
274
  end
274
275
 
275
- it "should read records until eof, ignoring partial records" do
276
+ it "reads records until eof, ignoring partial records" do
276
277
  subject = BinData::Array.new(:type => :int16be, :read_until => :eof)
277
278
 
278
279
  subject.read "\x00\x01\x00\x02\x03"
279
280
  subject.should == [1, 2]
280
281
  end
281
282
 
282
- it "should report exceptions" do
283
+ it "reports exceptions" do
283
284
  array_type = [:string, {:read_length => lambda { unknown_variable }}]
284
285
  subject = BinData::Array.new(:type => array_type, :read_until => :eof)
285
- lambda { subject.read "\x00\x01\x00\x02\x03" }.should raise_error
286
+ expect { subject.read "\x00\x01\x00\x02\x03" }.to raise_error
286
287
  end
287
288
  end
288
289
  end
@@ -297,7 +298,7 @@ describe BinData::Array, "nested within an Array" do
297
298
 
298
299
  its(:snapshot) { should == [ [0], [0, 1], [0, 1, 2] ] }
299
300
 
300
- it "should maintain structure when reading" do
301
+ it "maintains structure when reading" do
301
302
  subject.read "\x04\x05\x06\x07\x08\x09"
302
303
  subject.should == [ [4], [5, 6], [7, 8, 9] ]
303
304
  end
@@ -311,12 +312,12 @@ describe BinData::Array, "subclassed" do
311
312
  uint16 :initial_value => :initial_element_value
312
313
  end
313
314
 
314
- it "should forward parameters" do
315
+ it "forwards parameters" do
315
316
  subject = IntArray.new(:initial_length => 7)
316
317
  subject.length.should == 7
317
318
  end
318
319
 
319
- it "should be able to override default parameters" do
320
+ it "overrides default parameters" do
320
321
  subject = IntArray.new(:initial_length => 3, :initial_element_value => 5)
321
322
  subject.to_binary_s.should == "\x00\x05\x00\x05\x00\x05"
322
323
  end
@@ -6,12 +6,10 @@ require 'bindata/base_primitive'
6
6
  require 'bindata/io'
7
7
 
8
8
  describe BinData::BasePrimitive do
9
- let(:r) { BinData::RegisteredClasses }
10
-
11
- it "should not be registered" do
12
- lambda {
13
- r.lookup("BasePrimitive")
14
- }.should raise_error(BinData::UnRegisteredTypeError)
9
+ it "is not registered" do
10
+ expect {
11
+ BinData::RegisteredClasses.lookup("BasePrimitive")
12
+ }.to raise_error(BinData::UnRegisteredTypeError)
15
13
  end
16
14
  end
17
15
 
@@ -22,20 +20,20 @@ describe BinData::BasePrimitive, "all subclasses" do
22
20
 
23
21
  subject { SubClassOfBasePrimitive.new }
24
22
 
25
- it "should raise errors on unimplemented methods" do
26
- lambda { subject.value_to_binary_string(nil) }.should raise_error(NotImplementedError)
27
- lambda { subject.read_and_return_value(nil) }.should raise_error(NotImplementedError)
28
- lambda { subject.sensible_default }.should raise_error(NotImplementedError)
23
+ it "raise errors on unimplemented methods" do
24
+ expect { subject.value_to_binary_string(nil) }.to raise_error(NotImplementedError)
25
+ expect { subject.read_and_return_value(nil) }.to raise_error(NotImplementedError)
26
+ expect { subject.sensible_default }.to raise_error(NotImplementedError)
29
27
  end
30
28
  end
31
29
 
32
30
  describe BinData::BasePrimitive do
33
- it "should conform to rule 1 for returning a value" do
31
+ it "conforms to rule 1 for returning a value" do
34
32
  data = ExampleSingle.new(:value => 5)
35
33
  data.should == 5
36
34
  end
37
35
 
38
- it "should conform to rule 2 for returning a value" do
36
+ it "conforms to rule 2 for returning a value" do
39
37
  io = ExampleSingle.io_with_value(42)
40
38
  data = ExampleSingle.new(:value => 5)
41
39
  data.read(io)
@@ -44,26 +42,26 @@ describe BinData::BasePrimitive do
44
42
  data.should == 42
45
43
  end
46
44
 
47
- it "should conform to rule 3 for returning a value" do
45
+ it "conforms to rule 3 for returning a value" do
48
46
  data = ExampleSingle.new(:initial_value => 5)
49
47
  data.should be_clear
50
48
  data.should == 5
51
49
  end
52
50
 
53
- it "should conform to rule 4 for returning a value" do
51
+ it "conforms to rule 4 for returning a value" do
54
52
  data = ExampleSingle.new(:initial_value => 5)
55
53
  data.assign(17)
56
54
  data.should_not be_clear
57
55
  data.should == 17
58
56
  end
59
57
 
60
- it "should conform to rule 5 for returning a value" do
58
+ it "conforms to rule 5 for returning a value" do
61
59
  data = ExampleSingle.new
62
60
  data.should be_clear
63
61
  data.should == 0
64
62
  end
65
63
 
66
- it "should conform to rule 6 for returning a value" do
64
+ it "conforms to rule 6 for returning a value" do
67
65
  data = ExampleSingle.new
68
66
  data.assign(8)
69
67
  data.should_not be_clear
@@ -74,53 +72,53 @@ end
74
72
  describe ExampleSingle do
75
73
  subject { ExampleSingle.new(5) }
76
74
 
77
- it "should fail when assigning nil values" do
78
- lambda { subject.assign(nil) }.should raise_error(ArgumentError)
75
+ it "fails when assigning nil values" do
76
+ expect { subject.assign(nil) }.to raise_error(ArgumentError)
79
77
  end
80
78
 
81
- it "should allowing setting and retrieving value" do
79
+ it "sets and retrieves values" do
82
80
  subject.assign(7)
83
81
  subject.should == 7
84
82
  end
85
83
 
86
- it "should allowing setting and retrieving BinData::BasePrimitives" do
84
+ it "sets and retrieves BinData::BasePrimitives" do
87
85
  subject.assign(ExampleSingle.new(7))
88
86
  subject.should == 7
89
87
  end
90
88
 
91
- it "should respond to known methods" do
89
+ it "responds to known methods" do
92
90
  subject.should respond_to(:num_bytes)
93
91
  end
94
92
 
95
- it "should respond to known methods in #snapshot" do
93
+ it "responds to known methods in #snapshot" do
96
94
  subject.should respond_to(:div)
97
95
  end
98
96
 
99
- it "should not respond to unknown methods in self or #snapshot" do
97
+ it "does not respond to unknown methods in self or #snapshot" do
100
98
  subject.should_not respond_to(:does_not_exist)
101
99
  end
102
100
 
103
- it "should behave as #snapshot" do
101
+ it "behaves as #snapshot" do
104
102
  (subject + 1).should == 6
105
103
  (1 + subject).should == 6
106
104
  end
107
105
 
108
- it "should be equal to other ExampleSingle" do
106
+ it "is equal to other ExampleSingle" do
109
107
  subject.should == ExampleSingle.new(5)
110
108
  end
111
109
 
112
- it "should be equal to raw values" do
110
+ it "is equal to raw values" do
113
111
  subject.should == 5
114
112
  5.should == subject
115
113
  end
116
114
 
117
- it "should work as hash keys" do
115
+ it "can be used as a hash key" do
118
116
  hash = {5 => 17}
119
117
 
120
118
  hash[subject].should == 17
121
119
  end
122
120
 
123
- it "should be able to sort" do
121
+ it "is sortable" do
124
122
  [ExampleSingle.new(5), ExampleSingle.new(3)].sort.should == [3, 5]
125
123
  end
126
124
  end
@@ -128,38 +126,38 @@ end
128
126
  describe BinData::BasePrimitive, "after initialisation" do
129
127
  subject { ExampleSingle.new }
130
128
 
131
- it "should not allow both :initial_value and :value" do
129
+ it "does not allow both :initial_value and :value" do
132
130
  params = {:initial_value => 1, :value => 2}
133
- lambda { ExampleSingle.new(params) }.should raise_error(ArgumentError)
131
+ expect { ExampleSingle.new(params) }.to raise_error(ArgumentError)
134
132
  end
135
133
 
136
134
  it { should be_clear }
137
135
  its(:value) { should == 0 }
138
136
  its(:num_bytes) { should == 4 }
139
137
 
140
- it "should have symmetric IO" do
138
+ it "has symmetric IO" do
141
139
  subject.assign(42)
142
140
  written = subject.to_binary_s
143
141
 
144
142
  ExampleSingle.read(written).should == 42
145
143
  end
146
144
 
147
- it "should allowing setting and retrieving value" do
145
+ it "sets and retrieves values" do
148
146
  subject.value = 5
149
147
  subject.value.should == 5
150
148
  end
151
149
 
152
- it "should not be clear after setting value" do
150
+ it "is not clear after setting value" do
153
151
  subject.assign(5)
154
152
  subject.should_not be_clear
155
153
  end
156
154
 
157
- it "should not be clear after reading" do
155
+ it "is not clear after reading" do
158
156
  subject.read("\x11\x22\x33\x44")
159
157
  subject.should_not be_clear
160
158
  end
161
159
 
162
- it "should return a snapshot" do
160
+ it "returns a snapshot" do
163
161
  subject.assign(5)
164
162
  subject.snapshot.should == 5
165
163
  end
@@ -170,17 +168,17 @@ describe BinData::BasePrimitive, "with :initial_value" do
170
168
 
171
169
  its(:value) { should == 5 }
172
170
 
173
- it "should forget :initial_value after being set" do
171
+ it "forgets :initial_value after being set" do
174
172
  subject.assign(17)
175
173
  subject.should_not == 5
176
174
  end
177
175
 
178
- it "should forget :initial_value after reading" do
176
+ it "forgets :initial_value after reading" do
179
177
  subject.read("\x11\x22\x33\x44")
180
178
  subject.should_not == 5
181
179
  end
182
180
 
183
- it "should remember :initial_value after being cleared" do
181
+ it "remembers :initial_value after being cleared" do
184
182
  subject.assign(17)
185
183
  subject.clear
186
184
  subject.should == 5
@@ -194,18 +192,18 @@ describe BinData::BasePrimitive, "with :value" do
194
192
 
195
193
  let(:io) { ExampleSingle.io_with_value(56) }
196
194
 
197
- it "should change during reading" do
195
+ it "changes during reading" do
198
196
  subject.read(io)
199
197
  subject.stub(:reading?).and_return(true)
200
198
  subject.should == 56
201
199
  end
202
200
 
203
- it "should not change after reading" do
201
+ it "does not change after reading" do
204
202
  subject.read(io)
205
203
  subject.should == 5
206
204
  end
207
205
 
208
- it "should not be able to change the value" do
206
+ it "is unaffected by assigning" do
209
207
  subject.assign(17)
210
208
  subject.should == 5
211
209
  end
@@ -215,26 +213,26 @@ describe BinData::BasePrimitive, "checking read value" do
215
213
  let(:io) { ExampleSingle.io_with_value(12) }
216
214
 
217
215
  context ":check_value is non boolean" do
218
- it "should succeed when check_value and correct" do
216
+ it "succeeds when check_value is correct" do
219
217
  data = ExampleSingle.new(:check_value => 12)
220
- lambda { data.read(io) }.should_not raise_error
218
+ expect { data.read(io) }.not_to raise_error
221
219
  end
222
220
 
223
- it "should fail when check_value is incorrect" do
221
+ it "fails when check_value is incorrect" do
224
222
  data = ExampleSingle.new(:check_value => lambda { 99 })
225
- lambda { data.read(io) }.should raise_error(BinData::ValidityError)
223
+ expect { data.read(io) }.to raise_error(BinData::ValidityError)
226
224
  end
227
225
  end
228
226
 
229
227
  context ":check_value is boolean" do
230
- it "should succeed when check_value is true" do
228
+ it "succeeds when check_value is true" do
231
229
  data = ExampleSingle.new(:check_value => lambda { value < 20 })
232
- lambda { data.read(io) }.should_not raise_error
230
+ expect { data.read(io) }.not_to raise_error
233
231
  end
234
232
 
235
- it "should fail when check_value is false" do
233
+ it "fails when check_value is false" do
236
234
  data = ExampleSingle.new(:check_value => lambda { value > 20 })
237
- lambda { data.read(io) }.should raise_error(BinData::ValidityError)
235
+ expect { data.read(io) }.to raise_error(BinData::ValidityError)
238
236
  end
239
237
  end
240
238
  end