bindata 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bindata might be problematic. Click here for more details.
- data/BSDL +1 -1
 - data/ChangeLog +8 -0
 - data/NEWS +7 -0
 - data/lib/bindata.rb +3 -3
 - data/lib/bindata/base.rb +7 -0
 - data/lib/bindata/base_primitive.rb +2 -2
 - data/lib/bindata/choice.rb +4 -0
 - data/lib/bindata/io.rb +1 -1
 - data/lib/bindata/lazy.rb +2 -2
 - data/lib/bindata/sanitize.rb +9 -0
 - data/lib/bindata/string.rb +33 -16
 - data/manual.haml +55 -53
 - data/manual.md +346 -253
 - data/spec/alignment_spec.rb +7 -7
 - data/spec/array_spec.rb +67 -66
 - data/spec/base_primitive_spec.rb +47 -49
 - data/spec/base_spec.rb +70 -73
 - data/spec/bits_spec.rb +14 -14
 - data/spec/choice_spec.rb +44 -41
 - data/spec/count_bytes_remaining_spec.rb +8 -11
 - data/spec/deprecated_spec.rb +29 -29
 - data/spec/float_spec.rb +12 -12
 - data/spec/int_spec.rb +24 -24
 - data/spec/io_spec.rb +56 -56
 - data/spec/lazy_spec.rb +41 -39
 - data/spec/primitive_spec.rb +31 -33
 - data/spec/record_spec.rb +55 -57
 - data/spec/registry_spec.rb +25 -25
 - data/spec/rest_spec.rb +5 -5
 - data/spec/skip_spec.rb +3 -3
 - data/spec/spec_common.rb +2 -2
 - data/spec/string_spec.rb +38 -38
 - data/spec/stringz_spec.rb +18 -18
 - data/spec/struct_spec.rb +48 -48
 - data/spec/system_spec.rb +38 -37
 - data/spec/wrapper_spec.rb +21 -23
 - data/tasks/pkg.rake +3 -3
 - data/tasks/rdoc.rake +1 -1
 - data/tasks/rspec.rake +7 -7
 - metadata +51 -53
 
    
        data/spec/struct_spec.rb
    CHANGED
    
    | 
         @@ -4,40 +4,40 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_common")) 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'bindata'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            describe BinData::Struct, "when initializing" do
         
     | 
| 
       7 
     | 
    
         
            -
              it " 
     | 
| 
      
 7 
     | 
    
         
            +
              it "fails on non registered types" do
         
     | 
| 
       8 
8 
     | 
    
         
             
                params = {:fields => [[:non_registered_type, :a]]}
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                expect {
         
     | 
| 
       10 
10 
     | 
    
         
             
                  BinData::Struct.new(params)
         
     | 
| 
       11 
     | 
    
         
            -
                }. 
     | 
| 
      
 11 
     | 
    
         
            +
                }.to raise_error(BinData::UnRegisteredTypeError)
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
              it " 
     | 
| 
      
 14 
     | 
    
         
            +
              it "fails on duplicate names" do
         
     | 
| 
       15 
15 
     | 
    
         
             
                params = {:fields => [[:int8, :a], [:int8, :b], [:int8, :a]]}
         
     | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
      
 16 
     | 
    
         
            +
                expect {
         
     | 
| 
       17 
17 
     | 
    
         
             
                  BinData::Struct.new(params)
         
     | 
| 
       18 
     | 
    
         
            -
                }. 
     | 
| 
      
 18 
     | 
    
         
            +
                }.to raise_error(NameError)
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              it " 
     | 
| 
      
 21 
     | 
    
         
            +
              it "fails on reserved names" do
         
     | 
| 
       22 
22 
     | 
    
         
             
                # note that #invert is from Hash.instance_methods
         
     | 
| 
       23 
23 
     | 
    
         
             
                params = {:fields => [[:int8, :a], [:int8, :invert]]}
         
     | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
      
 24 
     | 
    
         
            +
                expect {
         
     | 
| 
       25 
25 
     | 
    
         
             
                  BinData::Struct.new(params)
         
     | 
| 
       26 
     | 
    
         
            -
                }. 
     | 
| 
      
 26 
     | 
    
         
            +
                }.to raise_error(NameError)
         
     | 
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
              it " 
     | 
| 
      
 29 
     | 
    
         
            +
              it "fails when field name shadows an existing method" do
         
     | 
| 
       30 
30 
     | 
    
         
             
                params = {:fields => [[:int8, :object_id]]}
         
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
      
 31 
     | 
    
         
            +
                expect {
         
     | 
| 
       32 
32 
     | 
    
         
             
                  BinData::Struct.new(params)
         
     | 
| 
       33 
     | 
    
         
            -
                }. 
     | 
| 
      
 33 
     | 
    
         
            +
                }.to raise_error(NameError)
         
     | 
| 
       34 
34 
     | 
    
         
             
              end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
              it " 
     | 
| 
      
 36 
     | 
    
         
            +
              it "fails on unknown endian" do
         
     | 
| 
       37 
37 
     | 
    
         
             
                params = {:endian => 'bad value', :fields => []}
         
     | 
| 
       38 
     | 
    
         
            -
                 
     | 
| 
      
 38 
     | 
    
         
            +
                expect {
         
     | 
| 
       39 
39 
     | 
    
         
             
                  BinData::Struct.new(params)
         
     | 
| 
       40 
     | 
    
         
            -
                }. 
     | 
| 
      
 40 
     | 
    
         
            +
                }.to raise_error(ArgumentError)
         
     | 
| 
       41 
41 
     | 
    
         
             
              end
         
     | 
| 
       42 
42 
     | 
    
         
             
            end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
         @@ -51,16 +51,16 @@ describe BinData::Struct, "with anonymous fields" do 
     | 
|
| 
       51 
51 
     | 
    
         
             
                BinData::Struct.new(params)
         
     | 
| 
       52 
52 
     | 
    
         
             
              }
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
              it " 
     | 
| 
      
 54 
     | 
    
         
            +
              it "only shows non anonymous fields" do
         
     | 
| 
       55 
55 
     | 
    
         
             
                subject.field_names.should == ["a"]
         
     | 
| 
       56 
56 
     | 
    
         
             
              end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
              it " 
     | 
| 
      
 58 
     | 
    
         
            +
              it "does not include anonymous fields in snapshot" do
         
     | 
| 
       59 
59 
     | 
    
         
             
                subject.a = 5
         
     | 
| 
       60 
60 
     | 
    
         
             
                subject.snapshot.should == {"a" => 5}
         
     | 
| 
       61 
61 
     | 
    
         
             
              end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
              it " 
     | 
| 
      
 63 
     | 
    
         
            +
              it "writes anonymous fields" do
         
     | 
| 
       64 
64 
     | 
    
         
             
                subject.read("\001\002\003")
         
     | 
| 
       65 
65 
     | 
    
         
             
                subject.a.clear
         
     | 
| 
       66 
66 
     | 
    
         
             
                subject.to_binary_s.should == "\005\002\005"
         
     | 
| 
         @@ -78,11 +78,11 @@ describe BinData::Struct, "with hidden fields" do 
     | 
|
| 
       78 
78 
     | 
    
         
             
                BinData::Struct.new(params)
         
     | 
| 
       79 
79 
     | 
    
         
             
              }
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
              it " 
     | 
| 
      
 81 
     | 
    
         
            +
              it "only shows fields that aren't hidden" do
         
     | 
| 
       82 
82 
     | 
    
         
             
                subject.field_names.should == ["a", "d"]
         
     | 
| 
       83 
83 
     | 
    
         
             
              end
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
              it " 
     | 
| 
      
 85 
     | 
    
         
            +
              it "accesses hidden fields directly" do
         
     | 
| 
       86 
86 
     | 
    
         
             
                subject.b.should == 5
         
     | 
| 
       87 
87 
     | 
    
         
             
                subject.c = 15
         
     | 
| 
       88 
88 
     | 
    
         
             
                subject.c.should == 15
         
     | 
| 
         @@ -90,12 +90,12 @@ describe BinData::Struct, "with hidden fields" do 
     | 
|
| 
       90 
90 
     | 
    
         
             
                subject.should respond_to(:b=)
         
     | 
| 
       91 
91 
     | 
    
         
             
              end
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
              it " 
     | 
| 
      
 93 
     | 
    
         
            +
              it "does not include hidden fields in snapshot" do
         
     | 
| 
       94 
94 
     | 
    
         
             
                subject.b = 7
         
     | 
| 
       95 
95 
     | 
    
         
             
                subject.snapshot.should == {"a" => 0, "d" => 7}
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
              it " 
     | 
| 
      
 98 
     | 
    
         
            +
              it "detects hidden fields with has_key?" do
         
     | 
| 
       99 
99 
     | 
    
         
             
                subject.should have_key("b")
         
     | 
| 
       100 
100 
     | 
    
         
             
              end
         
     | 
| 
       101 
101 
     | 
    
         
             
            end
         
     | 
| 
         @@ -107,25 +107,25 @@ describe BinData::Struct, "with multiple fields" do 
     | 
|
| 
       107 
107 
     | 
    
         
             
              its(:field_names) { should == ["a", "b"] }
         
     | 
| 
       108 
108 
     | 
    
         
             
              its(:to_binary_s) { should == "\x01\x02" }
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
              it " 
     | 
| 
      
 110 
     | 
    
         
            +
              it "returns num_bytes" do
         
     | 
| 
       111 
111 
     | 
    
         
             
                subject.a.num_bytes.should == 1
         
     | 
| 
       112 
112 
     | 
    
         
             
                subject.b.num_bytes.should == 1
         
     | 
| 
       113 
113 
     | 
    
         
             
                subject.num_bytes.should   == 2
         
     | 
| 
       114 
114 
     | 
    
         
             
              end
         
     | 
| 
       115 
115 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
              it " 
     | 
| 
      
 116 
     | 
    
         
            +
              it "identifies accepted parameters" do
         
     | 
| 
       117 
117 
     | 
    
         
             
                BinData::Struct.accepted_parameters.all.should include(:fields)
         
     | 
| 
       118 
118 
     | 
    
         
             
                BinData::Struct.accepted_parameters.all.should include(:hide)
         
     | 
| 
       119 
119 
     | 
    
         
             
                BinData::Struct.accepted_parameters.all.should include(:endian)
         
     | 
| 
       120 
120 
     | 
    
         
             
              end
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
              it " 
     | 
| 
      
 122 
     | 
    
         
            +
              it "clears" do
         
     | 
| 
       123 
123 
     | 
    
         
             
                subject.a = 6
         
     | 
| 
       124 
124 
     | 
    
         
             
                subject.clear
         
     | 
| 
       125 
125 
     | 
    
         
             
                subject.should be_clear
         
     | 
| 
       126 
126 
     | 
    
         
             
              end
         
     | 
| 
       127 
127 
     | 
    
         | 
| 
       128 
     | 
    
         
            -
              it " 
     | 
| 
      
 128 
     | 
    
         
            +
              it "clears individual elements" do
         
     | 
| 
       129 
129 
     | 
    
         
             
                subject.a = 6
         
     | 
| 
       130 
130 
     | 
    
         
             
                subject.b = 7
         
     | 
| 
       131 
131 
     | 
    
         
             
                subject.a.clear
         
     | 
| 
         @@ -133,51 +133,51 @@ describe BinData::Struct, "with multiple fields" do 
     | 
|
| 
       133 
133 
     | 
    
         
             
                subject.b.should_not be_clear
         
     | 
| 
       134 
134 
     | 
    
         
             
              end
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
              it " 
     | 
| 
      
 136 
     | 
    
         
            +
              it "reads elements dynamically" do
         
     | 
| 
       137 
137 
     | 
    
         
             
                subject[:a].should == 1
         
     | 
| 
       138 
138 
     | 
    
         
             
              end
         
     | 
| 
       139 
139 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
              it " 
     | 
| 
      
 140 
     | 
    
         
            +
              it "writes elements dynamically" do
         
     | 
| 
       141 
141 
     | 
    
         
             
                subject[:a] = 2
         
     | 
| 
       142 
142 
     | 
    
         
             
                subject.a.should == 2
         
     | 
| 
       143 
143 
     | 
    
         
             
              end
         
     | 
| 
       144 
144 
     | 
    
         | 
| 
       145 
     | 
    
         
            -
              it " 
     | 
| 
      
 145 
     | 
    
         
            +
              it "implements has_key?" do
         
     | 
| 
       146 
146 
     | 
    
         
             
                subject.should have_key("a")
         
     | 
| 
       147 
147 
     | 
    
         
             
              end
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
     | 
    
         
            -
              it " 
     | 
| 
      
 149 
     | 
    
         
            +
              it "reads ordered" do
         
     | 
| 
       150 
150 
     | 
    
         
             
                subject.read("\x03\x04")
         
     | 
| 
       151 
151 
     | 
    
         | 
| 
       152 
152 
     | 
    
         
             
                subject.a.should == 3
         
     | 
| 
       153 
153 
     | 
    
         
             
                subject.b.should == 4
         
     | 
| 
       154 
154 
     | 
    
         
             
              end
         
     | 
| 
       155 
155 
     | 
    
         | 
| 
       156 
     | 
    
         
            -
              it " 
     | 
| 
      
 156 
     | 
    
         
            +
              it "returns a snapshot" do
         
     | 
| 
       157 
157 
     | 
    
         
             
                snap = subject.snapshot
         
     | 
| 
       158 
158 
     | 
    
         
             
                snap.a.should == 1
         
     | 
| 
       159 
159 
     | 
    
         
             
                snap.b.should == 2
         
     | 
| 
       160 
160 
     | 
    
         
             
                snap.should == { "a" => 1, "b" => 2 }
         
     | 
| 
       161 
161 
     | 
    
         
             
              end
         
     | 
| 
       162 
162 
     | 
    
         | 
| 
       163 
     | 
    
         
            -
              it " 
     | 
| 
      
 163 
     | 
    
         
            +
              it "assigns from partial hash" do
         
     | 
| 
       164 
164 
     | 
    
         
             
                subject.assign("a" => 3)
         
     | 
| 
       165 
165 
     | 
    
         
             
                subject.a.should == 3
         
     | 
| 
       166 
166 
     | 
    
         
             
                subject.b.should == 0
         
     | 
| 
       167 
167 
     | 
    
         
             
              end
         
     | 
| 
       168 
168 
     | 
    
         | 
| 
       169 
     | 
    
         
            -
              it " 
     | 
| 
      
 169 
     | 
    
         
            +
              it "assigns from hash" do
         
     | 
| 
       170 
170 
     | 
    
         
             
                subject.assign("a" => 3, "b" => 4)
         
     | 
| 
       171 
171 
     | 
    
         
             
                subject.a.should == 3
         
     | 
| 
       172 
172 
     | 
    
         
             
                subject.b.should == 4
         
     | 
| 
       173 
173 
     | 
    
         
             
              end
         
     | 
| 
       174 
174 
     | 
    
         | 
| 
       175 
     | 
    
         
            -
              it " 
     | 
| 
      
 175 
     | 
    
         
            +
              it "assigns from nil" do
         
     | 
| 
       176 
176 
     | 
    
         
             
                subject.assign(nil)
         
     | 
| 
       177 
177 
     | 
    
         
             
                subject.should be_clear
         
     | 
| 
       178 
178 
     | 
    
         
             
              end
         
     | 
| 
       179 
179 
     | 
    
         | 
| 
       180 
     | 
    
         
            -
              it " 
     | 
| 
      
 180 
     | 
    
         
            +
              it "assigns from Struct" do
         
     | 
| 
       181 
181 
     | 
    
         
             
                src = BinData::Struct.new(params)
         
     | 
| 
       182 
182 
     | 
    
         
             
                src.a = 3
         
     | 
| 
       183 
183 
     | 
    
         
             
                src.b = 4
         
     | 
| 
         @@ -187,7 +187,7 @@ describe BinData::Struct, "with multiple fields" do 
     | 
|
| 
       187 
187 
     | 
    
         
             
                subject.b.should == 4
         
     | 
| 
       188 
188 
     | 
    
         
             
              end
         
     | 
| 
       189 
189 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
              it " 
     | 
| 
      
 190 
     | 
    
         
            +
              it "assigns from snapshot" do
         
     | 
| 
       191 
191 
     | 
    
         
             
                src = BinData::Struct.new(params)
         
     | 
| 
       192 
192 
     | 
    
         
             
                src.a = 3
         
     | 
| 
       193 
193 
     | 
    
         
             
                src.b = 4
         
     | 
| 
         @@ -197,22 +197,22 @@ describe BinData::Struct, "with multiple fields" do 
     | 
|
| 
       197 
197 
     | 
    
         
             
                subject.b.should == 4
         
     | 
| 
       198 
198 
     | 
    
         
             
              end
         
     | 
| 
       199 
199 
     | 
    
         | 
| 
       200 
     | 
    
         
            -
              it " 
     | 
| 
       201 
     | 
    
         
            -
                 
     | 
| 
      
 200 
     | 
    
         
            +
              it "fails on unknown method call" do
         
     | 
| 
      
 201 
     | 
    
         
            +
                expect { subject.does_not_exist }.to raise_error(NoMethodError)
         
     | 
| 
       202 
202 
     | 
    
         
             
              end
         
     | 
| 
       203 
203 
     | 
    
         | 
| 
       204 
204 
     | 
    
         
             
              context "#snapshot" do
         
     | 
| 
       205 
     | 
    
         
            -
                it " 
     | 
| 
      
 205 
     | 
    
         
            +
                it "has ordered #keys" do
         
     | 
| 
       206 
206 
     | 
    
         
             
                  subject.snapshot.keys.should == ["a", "b"]
         
     | 
| 
       207 
207 
     | 
    
         
             
                end
         
     | 
| 
       208 
208 
     | 
    
         | 
| 
       209 
     | 
    
         
            -
                it " 
     | 
| 
      
 209 
     | 
    
         
            +
                it "has ordered #each" do
         
     | 
| 
       210 
210 
     | 
    
         
             
                  keys = []
         
     | 
| 
       211 
211 
     | 
    
         
             
                  subject.snapshot.each { |el| keys << el[0] }
         
     | 
| 
       212 
212 
     | 
    
         
             
                  keys.should == ["a", "b"]
         
     | 
| 
       213 
213 
     | 
    
         
             
                end
         
     | 
| 
       214 
214 
     | 
    
         | 
| 
       215 
     | 
    
         
            -
                it " 
     | 
| 
      
 215 
     | 
    
         
            +
                it "has ordered #each_pair" do
         
     | 
| 
       216 
216 
     | 
    
         
             
                  keys = []
         
     | 
| 
       217 
217 
     | 
    
         
             
                  subject.snapshot.each_pair { |k, v| keys << k }
         
     | 
| 
       218 
218 
     | 
    
         
             
                  keys.should == ["a", "b"]
         
     | 
| 
         @@ -237,13 +237,13 @@ describe BinData::Struct, "with nested structs" do 
     | 
|
| 
       237 
237 
     | 
    
         | 
| 
       238 
238 
     | 
    
         
             
              its(:field_names) { should == ["a", "b", "c"] }
         
     | 
| 
       239 
239 
     | 
    
         | 
| 
       240 
     | 
    
         
            -
              it " 
     | 
| 
      
 240 
     | 
    
         
            +
              it "returns num_bytes" do
         
     | 
| 
       241 
241 
     | 
    
         
             
                subject.b.num_bytes.should == 2
         
     | 
| 
       242 
242 
     | 
    
         
             
                subject.c.num_bytes.should == 2
         
     | 
| 
       243 
243 
     | 
    
         
             
                subject.num_bytes.should == 5
         
     | 
| 
       244 
244 
     | 
    
         
             
              end
         
     | 
| 
       245 
245 
     | 
    
         | 
| 
       246 
     | 
    
         
            -
              it " 
     | 
| 
      
 246 
     | 
    
         
            +
              it "accesses nested fields" do
         
     | 
| 
       247 
247 
     | 
    
         
             
                subject.a.should   == 6
         
     | 
| 
       248 
248 
     | 
    
         
             
                subject.b.w.should == 3
         
     | 
| 
       249 
249 
     | 
    
         
             
                subject.b.x.should == 6
         
     | 
| 
         @@ -251,7 +251,7 @@ describe BinData::Struct, "with nested structs" do 
     | 
|
| 
       251 
251 
     | 
    
         
             
                subject.c.z.should == 0
         
     | 
| 
       252 
252 
     | 
    
         
             
              end
         
     | 
| 
       253 
253 
     | 
    
         | 
| 
       254 
     | 
    
         
            -
              it " 
     | 
| 
      
 254 
     | 
    
         
            +
              it "returns correct offset" do
         
     | 
| 
       255 
255 
     | 
    
         
             
                subject.b.offset.should == 1
         
     | 
| 
       256 
256 
     | 
    
         
             
                subject.b.w.offset.should == 1
         
     | 
| 
       257 
257 
     | 
    
         
             
                subject.c.offset.should == 3
         
     | 
| 
         @@ -279,7 +279,7 @@ describe BinData::Struct, "with an endian defined" do 
     | 
|
| 
       279 
279 
     | 
    
         
             
                                                       {:fields => [[:uint16, :j]]}]]}]])
         
     | 
| 
       280 
280 
     | 
    
         
             
              }
         
     | 
| 
       281 
281 
     | 
    
         | 
| 
       282 
     | 
    
         
            -
              it " 
     | 
| 
      
 282 
     | 
    
         
            +
              it "uses correct endian" do
         
     | 
| 
       283 
283 
     | 
    
         
             
                subject.a = 1
         
     | 
| 
       284 
284 
     | 
    
         
             
                subject.b = 2.0
         
     | 
| 
       285 
285 
     | 
    
         
             
                subject.c[0] = 3
         
     | 
| 
         @@ -304,7 +304,7 @@ describe BinData::Struct, "with bit fields" do 
     | 
|
| 
       304 
304 
     | 
    
         
             
              its(:num_bytes) { should == 3 }
         
     | 
| 
       305 
305 
     | 
    
         
             
              its(:to_binary_s) { should == [0b0000_0101, 3, 1].pack("C*") }
         
     | 
| 
       306 
306 
     | 
    
         | 
| 
       307 
     | 
    
         
            -
              it " 
     | 
| 
      
 307 
     | 
    
         
            +
              it "reads" do
         
     | 
| 
       308 
308 
     | 
    
         
             
                str = [0b0000_0110, 5, 0].pack("C*")
         
     | 
| 
       309 
309 
     | 
    
         
             
                subject.read(str)
         
     | 
| 
       310 
310 
     | 
    
         
             
                subject.a.should == 0
         
     | 
| 
         @@ -313,7 +313,7 @@ describe BinData::Struct, "with bit fields" do 
     | 
|
| 
       313 
313 
     | 
    
         
             
                subject.d.should == 0
         
     | 
| 
       314 
314 
     | 
    
         
             
              end
         
     | 
| 
       315 
315 
     | 
    
         | 
| 
       316 
     | 
    
         
            -
              it " 
     | 
| 
      
 316 
     | 
    
         
            +
              it "has correct offsets" do
         
     | 
| 
       317 
317 
     | 
    
         
             
                subject.a.offset.should == 0
         
     | 
| 
       318 
318 
     | 
    
         
             
                subject.b.offset.should == 0
         
     | 
| 
       319 
319 
     | 
    
         
             
                subject.c.offset.should == 1
         
     | 
| 
         @@ -322,7 +322,7 @@ describe BinData::Struct, "with bit fields" do 
     | 
|
| 
       322 
322 
     | 
    
         
             
            end
         
     | 
| 
       323 
323 
     | 
    
         | 
| 
       324 
324 
     | 
    
         
             
            describe BinData::Struct, "with nested endian" do
         
     | 
| 
       325 
     | 
    
         
            -
              it " 
     | 
| 
      
 325 
     | 
    
         
            +
              it "uses correct endian" do
         
     | 
| 
       326 
326 
     | 
    
         
             
                nested_params = { :endian => :little,
         
     | 
| 
       327 
327 
     | 
    
         
             
                                  :fields => [[:int16, :b], [:int16, :c]] }
         
     | 
| 
       328 
328 
     | 
    
         
             
                params = { :endian => :big, 
         
     | 
    
        data/spec/system_spec.rb
    CHANGED
    
    | 
         @@ -9,27 +9,27 @@ describe "lambdas with index" do 
     | 
|
| 
       9 
9 
     | 
    
         
             
                uint8 :a, :value => lambda { index * 10 }
         
     | 
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              it " 
     | 
| 
      
 12 
     | 
    
         
            +
              it "uses index of containing array" do
         
     | 
| 
       13 
13 
     | 
    
         
             
                arr = BinData::Array.new(:type =>
         
     | 
| 
       14 
14 
     | 
    
         
             
                                           [:uint8, { :value => lambda { index * 10 } }],
         
     | 
| 
       15 
15 
     | 
    
         
             
                                         :initial_length => 3)
         
     | 
| 
       16 
16 
     | 
    
         
             
                arr.snapshot.should == [0, 10, 20]
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              it " 
     | 
| 
      
 19 
     | 
    
         
            +
              it "uses index of nearest containing array" do
         
     | 
| 
       20 
20 
     | 
    
         
             
                arr = BinData::Array.new(:type => :nested_lambda_with_index,
         
     | 
| 
       21 
21 
     | 
    
         
             
                                         :initial_length => 3)
         
     | 
| 
       22 
22 
     | 
    
         
             
                arr.snapshot.should == [{"a" => 0}, {"a" => 10}, {"a" => 20}]
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              it " 
     | 
| 
      
 25 
     | 
    
         
            +
              it "fails if there is no containing array" do
         
     | 
| 
       26 
26 
     | 
    
         
             
                subject = NestedLambdaWithIndex.new
         
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
      
 27 
     | 
    
         
            +
                expect { subject.a.to_s }.to raise_error(NoMethodError)
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         
             
            end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
            describe "lambdas with parent" do
         
     | 
| 
       32 
     | 
    
         
            -
              it " 
     | 
| 
      
 32 
     | 
    
         
            +
              it "accesses immediate parent when no parent is specified" do
         
     | 
| 
       33 
33 
     | 
    
         
             
                class NestedLambdaWithoutParent < BinData::Record
         
     | 
| 
       34 
34 
     | 
    
         
             
                  int8 :a, :value => 5
         
     | 
| 
       35 
35 
     | 
    
         
             
                  int8 :b, :value => lambda { a }
         
     | 
| 
         @@ -44,7 +44,7 @@ describe "lambdas with parent" do 
     | 
|
| 
       44 
44 
     | 
    
         
             
                subject.x.b.should == 5
         
     | 
| 
       45 
45 
     | 
    
         
             
              end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
              it " 
     | 
| 
      
 47 
     | 
    
         
            +
              it "accesses parent's parent when parent is specified" do
         
     | 
| 
       48 
48 
     | 
    
         
             
                class NestedLambdaWithParent < BinData::Record
         
     | 
| 
       49 
49 
     | 
    
         
             
                  int8 :a, :value => 5
         
     | 
| 
       50 
50 
     | 
    
         
             
                  int8 :b, :value => lambda { parent.a }
         
     | 
| 
         @@ -73,35 +73,36 @@ describe BinData::Record, "with choice field" do 
     | 
|
| 
       73 
73 
     | 
    
         
             
              end
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
              class RecordWithNestedChoiceField < BinData::Record
         
     | 
| 
      
 76 
     | 
    
         
            +
                uint8  :sel, :value => 0
         
     | 
| 
       76 
77 
     | 
    
         
             
                choice :x, :selection => 0 do
         
     | 
| 
       77 
     | 
    
         
            -
                  choice :selection =>  
     | 
| 
      
 78 
     | 
    
         
            +
                  choice :selection => :sel do
         
     | 
| 
       78 
79 
     | 
    
         
             
                    tuple_record
         
     | 
| 
       79 
80 
     | 
    
         
             
                  end
         
     | 
| 
       80 
81 
     | 
    
         
             
                end
         
     | 
| 
       81 
82 
     | 
    
         
             
              end
         
     | 
| 
       82 
83 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
              it " 
     | 
| 
      
 84 
     | 
    
         
            +
              it "treats choice object transparently " do
         
     | 
| 
       84 
85 
     | 
    
         
             
                subject = RecordWithChoiceField.new
         
     | 
| 
       85 
86 
     | 
    
         | 
| 
       86 
87 
     | 
    
         
             
                subject.x.a.should == 3
         
     | 
| 
       87 
88 
     | 
    
         
             
              end
         
     | 
| 
       88 
89 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
              it " 
     | 
| 
      
 90 
     | 
    
         
            +
              it "treats nested choice object transparently " do
         
     | 
| 
       90 
91 
     | 
    
         
             
                subject = RecordWithNestedChoiceField.new
         
     | 
| 
       91 
92 
     | 
    
         | 
| 
       92 
93 
     | 
    
         
             
                subject.x.a.should == 3
         
     | 
| 
       93 
94 
     | 
    
         
             
              end
         
     | 
| 
       94 
95 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
              it " 
     | 
| 
      
 96 
     | 
    
         
            +
              it "has correct offset" do
         
     | 
| 
       96 
97 
     | 
    
         
             
                subject = RecordWithNestedChoiceField.new
         
     | 
| 
       97 
     | 
    
         
            -
                subject.x.b.offset.should ==  
     | 
| 
      
 98 
     | 
    
         
            +
                subject.x.b.offset.should == 2
         
     | 
| 
       98 
99 
     | 
    
         
             
              end
         
     | 
| 
       99 
100 
     | 
    
         
             
            end
         
     | 
| 
       100 
101 
     | 
    
         | 
| 
       101 
102 
     | 
    
         
             
            describe BinData::Array, "of bits" do
         
     | 
| 
       102 
103 
     | 
    
         
             
              let(:data) { BinData::Array.new(:type => :bit1, :initial_length => 15) }
         
     | 
| 
       103 
104 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
              it " 
     | 
| 
      
 105 
     | 
    
         
            +
              it "reads" do
         
     | 
| 
       105 
106 
     | 
    
         
             
                str = [0b0001_0100, 0b1000_1000].pack("CC")
         
     | 
| 
       106 
107 
     | 
    
         
             
                data.read(str)
         
     | 
| 
       107 
108 
     | 
    
         
             
                data[0].should  == 0
         
     | 
| 
         @@ -121,16 +122,16 @@ describe BinData::Array, "of bits" do 
     | 
|
| 
       121 
122 
     | 
    
         
             
                data[14].should == 0
         
     | 
| 
       122 
123 
     | 
    
         
             
              end
         
     | 
| 
       123 
124 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
              it " 
     | 
| 
      
 125 
     | 
    
         
            +
              it "writes" do
         
     | 
| 
       125 
126 
     | 
    
         
             
                data[3] = 1
         
     | 
| 
       126 
127 
     | 
    
         
             
                data.to_binary_s.should == [0b0001_0000, 0b0000_0000].pack("CC")
         
     | 
| 
       127 
128 
     | 
    
         
             
              end
         
     | 
| 
       128 
129 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
              it " 
     | 
| 
      
 130 
     | 
    
         
            +
              it "returns num_bytes" do
         
     | 
| 
       130 
131 
     | 
    
         
             
                data.num_bytes.should == 2
         
     | 
| 
       131 
132 
     | 
    
         
             
              end
         
     | 
| 
       132 
133 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
              it " 
     | 
| 
      
 134 
     | 
    
         
            +
              it "has correct offset" do
         
     | 
| 
       134 
135 
     | 
    
         
             
                data[7].offset.should == 0
         
     | 
| 
       135 
136 
     | 
    
         
             
                data[8].offset.should == 1
         
     | 
| 
       136 
137 
     | 
    
         
             
              end
         
     | 
| 
         @@ -170,11 +171,11 @@ describe BinData::Record, "containing bitfields" do 
     | 
|
| 
       170 
171 
     | 
    
         | 
| 
       171 
172 
     | 
    
         
             
              subject { BitfieldRecord.new }
         
     | 
| 
       172 
173 
     | 
    
         | 
| 
       173 
     | 
    
         
            -
              it " 
     | 
| 
      
 174 
     | 
    
         
            +
              it "has correct num_bytes" do
         
     | 
| 
       174 
175 
     | 
    
         
             
                subject.num_bytes.should == 5
         
     | 
| 
       175 
176 
     | 
    
         
             
              end
         
     | 
| 
       176 
177 
     | 
    
         | 
| 
       177 
     | 
    
         
            -
              it " 
     | 
| 
      
 178 
     | 
    
         
            +
              it "reads across bitfield boundaries" do
         
     | 
| 
       178 
179 
     | 
    
         
             
                subject.read [0b0111_0010, 0b0110_0101, 0b0010_1010, 0b1000_0101, 0b1000_0000].pack("CCCCC")
         
     | 
| 
       179 
180 
     | 
    
         | 
| 
       180 
181 
     | 
    
         
             
                subject.a.w.should == 7
         
     | 
| 
         @@ -184,7 +185,7 @@ describe BinData::Record, "containing bitfields" do 
     | 
|
| 
       184 
185 
     | 
    
         
             
                subject.e.should == 11
         
     | 
| 
       185 
186 
     | 
    
         
             
              end
         
     | 
| 
       186 
187 
     | 
    
         | 
| 
       187 
     | 
    
         
            -
              it " 
     | 
| 
      
 188 
     | 
    
         
            +
              it "writes across bitfield boundaries" do
         
     | 
| 
       188 
189 
     | 
    
         
             
                subject.a.w = 3
         
     | 
| 
       189 
190 
     | 
    
         
             
                subject.b[2] = 1
         
     | 
| 
       190 
191 
     | 
    
         
             
                subject.b[5] = 1
         
     | 
| 
         @@ -196,28 +197,28 @@ describe BinData::Record, "containing bitfields" do 
     | 
|
| 
       196 
197 
     | 
    
         
             
            end
         
     | 
| 
       197 
198 
     | 
    
         | 
| 
       198 
199 
     | 
    
         
             
            describe "Objects with debug_name" do
         
     | 
| 
       199 
     | 
    
         
            -
              it " 
     | 
| 
      
 200 
     | 
    
         
            +
              it "haves default name of obj" do
         
     | 
| 
       200 
201 
     | 
    
         
             
                el = ExampleSingle.new
         
     | 
| 
       201 
202 
     | 
    
         
             
                el.debug_name.should == "obj"
         
     | 
| 
       202 
203 
     | 
    
         
             
              end
         
     | 
| 
       203 
204 
     | 
    
         | 
| 
       204 
     | 
    
         
            -
              it " 
     | 
| 
      
 205 
     | 
    
         
            +
              it "includes array index" do
         
     | 
| 
       205 
206 
     | 
    
         
             
                arr = BinData::Array.new(:type => :example_single, :initial_length => 2)
         
     | 
| 
       206 
207 
     | 
    
         
             
                arr[2].debug_name.should == "obj[2]"
         
     | 
| 
       207 
208 
     | 
    
         
             
              end
         
     | 
| 
       208 
209 
     | 
    
         | 
| 
       209 
     | 
    
         
            -
              it " 
     | 
| 
      
 210 
     | 
    
         
            +
              it "includes field name" do
         
     | 
| 
       210 
211 
     | 
    
         
             
                s = BinData::Struct.new(:fields => [[:example_single, :a]])
         
     | 
| 
       211 
212 
     | 
    
         
             
                s.a.debug_name.should == "obj.a"
         
     | 
| 
       212 
213 
     | 
    
         
             
              end
         
     | 
| 
       213 
214 
     | 
    
         | 
| 
       214 
     | 
    
         
            -
              it " 
     | 
| 
      
 215 
     | 
    
         
            +
              it "delegates to choice" do
         
     | 
| 
       215 
216 
     | 
    
         
             
                choice_params = {:choices => [:example_single], :selection => 0}
         
     | 
| 
       216 
217 
     | 
    
         
             
                s = BinData::Struct.new(:fields => [[:choice, :a, choice_params]])
         
     | 
| 
       217 
218 
     | 
    
         
             
                s.a.debug_name.should == "obj.a"
         
     | 
| 
       218 
219 
     | 
    
         
             
              end
         
     | 
| 
       219 
220 
     | 
    
         | 
| 
       220 
     | 
    
         
            -
              it " 
     | 
| 
      
 221 
     | 
    
         
            +
              it "nests" do
         
     | 
| 
       221 
222 
     | 
    
         
             
                nested_struct_params = {:fields => [[:example_single, :c]]}
         
     | 
| 
       222 
223 
     | 
    
         
             
                struct_params = {:fields => [[:struct, :b, nested_struct_params]]}
         
     | 
| 
       223 
224 
     | 
    
         
             
                s = BinData::Struct.new(:fields => [[:struct, :a, struct_params]])
         
     | 
| 
         @@ -236,7 +237,7 @@ describe "Tracing"  do 
     | 
|
| 
       236 
237 
     | 
    
         
             
                io.value.should == expected
         
     | 
| 
       237 
238 
     | 
    
         
             
              end
         
     | 
| 
       238 
239 
     | 
    
         | 
| 
       239 
     | 
    
         
            -
              it " 
     | 
| 
      
 240 
     | 
    
         
            +
              it "traces custom single values" do
         
     | 
| 
       240 
241 
     | 
    
         
             
                class DebugNamePrimitive < BinData::Primitive
         
     | 
| 
       241 
242 
     | 
    
         
             
                  int8 :ex
         
     | 
| 
       242 
243 
     | 
    
         
             
                  def get;     self.ex; end
         
     | 
| 
         @@ -251,7 +252,7 @@ describe "Tracing"  do 
     | 
|
| 
       251 
252 
     | 
    
         
             
                io.value.should == ["obj-internal-.ex => 1\n", "obj => 1\n"].join("")
         
     | 
| 
       252 
253 
     | 
    
         
             
              end
         
     | 
| 
       253 
254 
     | 
    
         | 
| 
       254 
     | 
    
         
            -
              it " 
     | 
| 
      
 255 
     | 
    
         
            +
              it "traces choice selection" do
         
     | 
| 
       255 
256 
     | 
    
         
             
                subject = BinData::Choice.new(:choices => [:int8, :int16be], :selection => 0)
         
     | 
| 
       256 
257 
     | 
    
         | 
| 
       257 
258 
     | 
    
         
             
                io = StringIO.new
         
     | 
| 
         @@ -260,7 +261,7 @@ describe "Tracing"  do 
     | 
|
| 
       260 
261 
     | 
    
         
             
                io.value.should == ["obj-selection- => 0\n", "obj => 1\n"].join("")
         
     | 
| 
       261 
262 
     | 
    
         
             
              end
         
     | 
| 
       262 
263 
     | 
    
         | 
| 
       263 
     | 
    
         
            -
              it " 
     | 
| 
      
 264 
     | 
    
         
            +
              it "trims long trace values" do
         
     | 
| 
       264 
265 
     | 
    
         
             
                subject = BinData::String.new(:read_length => 40)
         
     | 
| 
       265 
266 
     | 
    
         | 
| 
       266 
267 
     | 
    
         
             
                io = StringIO.new
         
     | 
| 
         @@ -278,16 +279,16 @@ describe "Forward referencing with Primitive" do 
     | 
|
| 
       278 
279 
     | 
    
         | 
| 
       279 
280 
     | 
    
         
             
              subject { FRPrimitive.new }
         
     | 
| 
       280 
281 
     | 
    
         | 
| 
       281 
     | 
    
         
            -
              it " 
     | 
| 
      
 282 
     | 
    
         
            +
              it "initialises" do
         
     | 
| 
       282 
283 
     | 
    
         
             
                subject.snapshot.should == {"len" => 0, "data" => ""}
         
     | 
| 
       283 
284 
     | 
    
         
             
              end
         
     | 
| 
       284 
285 
     | 
    
         | 
| 
       285 
     | 
    
         
            -
              it " 
     | 
| 
      
 286 
     | 
    
         
            +
              it "reads" do
         
     | 
| 
       286 
287 
     | 
    
         
             
                subject.read("\x04test")
         
     | 
| 
       287 
288 
     | 
    
         
             
                subject.snapshot.should == {"len" => 4, "data" => "test"}
         
     | 
| 
       288 
289 
     | 
    
         
             
              end
         
     | 
| 
       289 
290 
     | 
    
         | 
| 
       290 
     | 
    
         
            -
              it " 
     | 
| 
      
 291 
     | 
    
         
            +
              it "sets value" do
         
     | 
| 
       291 
292 
     | 
    
         
             
                subject.data = "hello"
         
     | 
| 
       292 
293 
     | 
    
         
             
                subject.snapshot.should == {"len" => 5, "data" => "hello"}
         
     | 
| 
       293 
294 
     | 
    
         
             
              end
         
     | 
| 
         @@ -301,16 +302,16 @@ describe "Forward referencing with Array" do 
     | 
|
| 
       301 
302 
     | 
    
         | 
| 
       302 
303 
     | 
    
         
             
              subject { FRArray.new }
         
     | 
| 
       303 
304 
     | 
    
         | 
| 
       304 
     | 
    
         
            -
              it " 
     | 
| 
      
 305 
     | 
    
         
            +
              it "initialises" do
         
     | 
| 
       305 
306 
     | 
    
         
             
                subject.snapshot.should == {"len" => 0, "data" => []}
         
     | 
| 
       306 
307 
     | 
    
         
             
              end
         
     | 
| 
       307 
308 
     | 
    
         | 
| 
       308 
     | 
    
         
            -
              it " 
     | 
| 
      
 309 
     | 
    
         
            +
              it "reads" do
         
     | 
| 
       309 
310 
     | 
    
         
             
                subject.read("\x04\x01\x02\x03\x04")
         
     | 
| 
       310 
311 
     | 
    
         
             
                subject.snapshot.should == {"len" => 4, "data" => [1, 2, 3, 4]}
         
     | 
| 
       311 
312 
     | 
    
         
             
              end
         
     | 
| 
       312 
313 
     | 
    
         | 
| 
       313 
     | 
    
         
            -
              it " 
     | 
| 
      
 314 
     | 
    
         
            +
              it "sets value" do
         
     | 
| 
       314 
315 
     | 
    
         
             
                subject.data = [1, 2, 3]
         
     | 
| 
       315 
316 
     | 
    
         
             
                subject.snapshot.should == {"len" => 3, "data" => [1, 2, 3]}
         
     | 
| 
       316 
317 
     | 
    
         
             
              end
         
     | 
| 
         @@ -325,7 +326,7 @@ describe "Evaluating custom parameters" do 
     | 
|
| 
       325 
326 
     | 
    
         
             
                uint8 :c, :custom => :b
         
     | 
| 
       326 
327 
     | 
    
         
             
              end
         
     | 
| 
       327 
328 
     | 
    
         | 
| 
       328 
     | 
    
         
            -
              it " 
     | 
| 
      
 329 
     | 
    
         
            +
              it "recursively evaluates parameter" do
         
     | 
| 
       329 
330 
     | 
    
         
             
                subject = CustomParameterRecord.new(:zz => 5)
         
     | 
| 
       330 
331 
     | 
    
         
             
                subject.c.eval_parameter(:custom).should == 5
         
     | 
| 
       331 
332 
     | 
    
         
             
              end
         
     | 
| 
         @@ -336,7 +337,7 @@ describe BinData::Record, "with custom sized integers" do 
     | 
|
| 
       336 
337 
     | 
    
         
             
                int40be :a
         
     | 
| 
       337 
338 
     | 
    
         
             
              end
         
     | 
| 
       338 
339 
     | 
    
         | 
| 
       339 
     | 
    
         
            -
              it " 
     | 
| 
      
 340 
     | 
    
         
            +
              it "reads as expected" do
         
     | 
| 
       340 
341 
     | 
    
         
             
                str = "\x00\x00\x00\x00\x05"
         
     | 
| 
       341 
342 
     | 
    
         
             
                CustomIntRecord.read(str).should == {"a" => 5}
         
     | 
| 
       342 
343 
     | 
    
         
             
              end
         
     | 
| 
         @@ -350,7 +351,7 @@ describe BinData::Record, "with choice field" do 
     | 
|
| 
       350 
351 
     | 
    
         
             
                end
         
     | 
| 
       351 
352 
     | 
    
         
             
              end
         
     | 
| 
       352 
353 
     | 
    
         | 
| 
       353 
     | 
    
         
            -
              it " 
     | 
| 
      
 354 
     | 
    
         
            +
              it "assigns" do
         
     | 
| 
       354 
355 
     | 
    
         
             
                subject = BinData::Array.new(:type => :choice_field_record)
         
     | 
| 
       355 
356 
     | 
    
         
             
                obj = ChoiceFieldRecord.new(:a => 1, :b => {:v => 3})
         
     | 
| 
       356 
357 
     | 
    
         
             
                subject.assign([obj])
         
     | 
| 
         @@ -368,11 +369,11 @@ describe BinData::Primitive, "representing a string" do 
     | 
|
| 
       368 
369 
     | 
    
         | 
| 
       369 
370 
     | 
    
         
             
              subject { PascalStringPrimitive.new("testing") }
         
     | 
| 
       370 
371 
     | 
    
         | 
| 
       371 
     | 
    
         
            -
              it " 
     | 
| 
      
 372 
     | 
    
         
            +
              it "compares to regexp" do
         
     | 
| 
       372 
373 
     | 
    
         
             
                (subject =~ /es/).should == 1
         
     | 
| 
       373 
374 
     | 
    
         
             
              end
         
     | 
| 
       374 
375 
     | 
    
         | 
| 
       375 
     | 
    
         
            -
              it " 
     | 
| 
      
 376 
     | 
    
         
            +
              it "compares to regexp" do
         
     | 
| 
       376 
377 
     | 
    
         
             
                (/es/ =~ subject).should == 1
         
     | 
| 
       377 
378 
     | 
    
         
             
              end
         
     | 
| 
       378 
379 
     | 
    
         
             
            end
         
     |