packetfu 1.1.13 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/ISSUE_TEMPLATE.md +29 -0
  4. data/.github/workflows/verify.yml +72 -0
  5. data/.travis.yml +10 -6
  6. data/LICENSE.txt +1 -1
  7. data/README.md +8 -8
  8. data/certs/todb.pem +25 -0
  9. data/examples/100kpackets.rb +2 -2
  10. data/examples/ackscan.rb +7 -6
  11. data/examples/pcap2pcapng.rb +2 -2
  12. data/examples/readpcap.rb +28 -0
  13. data/lib/packetfu/capture.rb +1 -1
  14. data/lib/packetfu/config.rb +2 -2
  15. data/lib/packetfu/inject.rb +1 -1
  16. data/lib/packetfu/packet.rb +6 -3
  17. data/lib/packetfu/pcap.rb +25 -25
  18. data/lib/packetfu/pcapng/file.rb +1 -1
  19. data/lib/packetfu/protos/arp.rb +1 -8
  20. data/lib/packetfu/protos/eth.rb +0 -7
  21. data/lib/packetfu/protos/hsrp.rb +0 -7
  22. data/lib/packetfu/protos/icmp/header.rb +7 -10
  23. data/lib/packetfu/protos/icmp.rb +0 -7
  24. data/lib/packetfu/protos/icmpv6.rb +4 -17
  25. data/lib/packetfu/protos/ip/header.rb +2 -2
  26. data/lib/packetfu/protos/ip/mixin.rb +9 -0
  27. data/lib/packetfu/protos/ip.rb +0 -8
  28. data/lib/packetfu/protos/ipv6/mixin.rb +12 -0
  29. data/lib/packetfu/protos/ipv6.rb +0 -7
  30. data/lib/packetfu/protos/lldp.rb +1 -8
  31. data/lib/packetfu/protos/tcp.rb +73 -30
  32. data/lib/packetfu/protos/udp/header.rb +4 -5
  33. data/lib/packetfu/protos/udp.rb +6 -18
  34. data/lib/packetfu/structfu.rb +1 -1
  35. data/lib/packetfu/version.rb +1 -1
  36. data/packetfu.gemspec +10 -18
  37. data/spec/arp_spec.rb +1 -1
  38. data/spec/capture_spec.rb +137 -0
  39. data/spec/eth_spec.rb +1 -1
  40. data/spec/icmp_spec.rb +1 -1
  41. data/spec/icmpv6_spec.rb +1 -1
  42. data/spec/inject_spec.rb +95 -0
  43. data/spec/ip_spec.rb +23 -1
  44. data/spec/packetfu_spec.rb +1 -1
  45. data/spec/pcap_spec.rb +3 -3
  46. data/spec/pcapng/file_spec.rb +1 -1
  47. data/spec/spec_helper.rb +4 -2
  48. data/spec/structfu_spec.rb +86 -82
  49. data/spec/tcp_spec.rb +155 -53
  50. data/test/sample-ipv6.pcap +0 -0
  51. data.tar.gz.sig +0 -0
  52. metadata +64 -37
  53. metadata.gz.sig +0 -0
  54. data/test/test_capture.rb +0 -58
  55. data/test/test_inject.rb +0 -31
  56. data/test/test_structfu.rb +0 -114
@@ -0,0 +1,95 @@
1
+ # -*- coding: binary -*-
2
+ require 'spec_helper'
3
+ require 'packetfu/protos/eth'
4
+ require 'packetfu/protos/ip'
5
+ require 'packetfu/protos/ipv6'
6
+ require 'packetfu/protos/tcp'
7
+ require 'packetfu/protos/udp'
8
+ require 'packetfu/protos/icmp'
9
+ require 'packetfu/config'
10
+ require 'packetfu/pcap'
11
+ require 'packetfu/utils'
12
+ require 'tempfile'
13
+
14
+ include PacketFu
15
+
16
+ describe Inject do
17
+ context "when creating an object from scratch" do
18
+ before :each do
19
+ @inject = PacketFu::Inject.new
20
+ end
21
+
22
+ it "should have sane defaults" do
23
+ expect(@inject.array).to be_kind_of(Array)
24
+ expect(@inject.stream).to be_kind_of(Array)
25
+ expect(@inject.iface).to be_kind_of(String)
26
+ expect(@inject.snaplen).to eql(65535)
27
+ expect(@inject.promisc).to eql(false)
28
+ expect(@inject.timeout).to eql(1)
29
+ end
30
+
31
+ it "should allow creating an inject object with non-std attributes" do
32
+ # Can only run this if we're root
33
+ if Process.uid == 0
34
+ options = {
35
+ :iface => PacketFu::Utils::default_int,
36
+ :snaplen => 0xfffe,
37
+ :promisc => true,
38
+ :timeout => 5,
39
+ }
40
+ @inject = PacketFu::Capture.new(options)
41
+
42
+ expect(@inject.array).to be_kind_of(Array)
43
+ expect(@inject.stream).to be_kind_of(Array)
44
+ expect(@inject.iface).to eql(options[:iface])
45
+ expect(@inject.snaplen).to eql(options[:snaplen])
46
+ expect(@inject.promisc).to eql(options[:promisc])
47
+ expect(@inject.timeout).to eql(options[:timeout])
48
+ end
49
+ end
50
+ end
51
+
52
+ context "when injecting on the wire" do
53
+ before :each do
54
+ @inject = PacketFu::Inject.new
55
+ end
56
+
57
+ it "should have sane defaults" do
58
+ expect(@inject.array).to be_kind_of(Array)
59
+ expect(@inject.stream).to be_kind_of(Array)
60
+ expect(@inject.iface).to be_kind_of(String)
61
+ expect(@inject.snaplen).to eql(65535)
62
+ expect(@inject.promisc).to eql(false)
63
+ expect(@inject.timeout).to eql(1)
64
+ end
65
+
66
+ # Can only run these if we're root
67
+ if Process.uid == 0
68
+ it "should allow creating an inject object with non-std attributes" do
69
+ udp_packet = PacketFu::UDPPacket.new(:iface => PacketFu::Utils::default_int)
70
+ udp_packet.ip_dst = PacketFu::Utils.rand_routable_daddr.to_s
71
+ udp_packet.udp_dport = 12345
72
+ udp_packet.udp_sport = 12345
73
+ udp_packet.payload = "PacketFu test packet"
74
+ udp_packet.recalc
75
+
76
+ expect(udp_packet.to_w).to eql([1, 1, 62])
77
+ end
78
+
79
+ it "should allow creating an inject object with non-std attributes" do
80
+ packet_array = []
81
+
82
+ udp_packet = PacketFu::UDPPacket.new(:iface => PacketFu::Utils::default_int)
83
+ udp_packet.ip_dst = PacketFu::Utils.rand_routable_daddr.to_s
84
+ udp_packet.udp_dport = 12345
85
+ udp_packet.udp_sport = 12345
86
+ udp_packet.payload = "PacketFu test packet"
87
+ udp_packet.recalc
88
+ 3.times { packet_array << udp_packet.to_s}
89
+
90
+ inject = PacketFu::Inject.new(:iface => PacketFu::Utils::default_int)
91
+ expect(inject.array_to_wire(:array => packet_array)).to eql([3, 3, 186])
92
+ end
93
+ end
94
+ end
95
+ end
data/spec/ip_spec.rb CHANGED
@@ -23,8 +23,30 @@ describe IPHeader do
23
23
  expect(@ip_header.ip_sum).to eql(65535)
24
24
  expect(@ip_header.ip_src).to eql(0)
25
25
  expect(@ip_header.ip_dst).to eql(0)
26
+ expect(@ip_header.ip_src).to be_a(Integer)
27
+ expect(@ip_header.ip_dst).to be_a(Integer)
26
28
  expect(@ip_header.body).to eql("")
27
29
  end
30
+
31
+ it "should parse a raw IPHeader" do
32
+ raw_header = "\x45\x10\x00\x4f\x16\xa9\x40\x00\x40\x06\xa2\x9c\xc0\xa8\x00\x02\xc0\xa8\x00\x01"
33
+ @ip_header.read(raw_header)
34
+
35
+ expect(@ip_header.ip_v).to eql(4)
36
+ expect(@ip_header.ip_hl).to eql(5)
37
+ expect(@ip_header.ip_tos).to eql(16)
38
+ expect(@ip_header.ip_len).to eql(79)
39
+ expect(@ip_header.ip_id).to be_kind_of(Integer)
40
+ expect(@ip_header.ip_frag).to eql(16384)
41
+ expect(@ip_header.ip_proto).to eql(6)
42
+ expect(@ip_header.ip_sum).to eql(41628)
43
+ expect(@ip_header.ip_src).to eql(3232235522)
44
+ expect(@ip_header.ip_dst).to eql(3232235521)
45
+ expect(@ip_header.ip_src).to be_a(Integer)
46
+ expect(@ip_header.ip_dst).to be_a(Integer)
47
+ expect(@ip_header.body).to eql("")
48
+ end
49
+
28
50
  end
29
51
  end
30
52
 
@@ -76,7 +98,7 @@ describe IPPacket do
76
98
  expect(@temp_file.read).to eql("")
77
99
 
78
100
  @ip_packet.to_f(@temp_file.path, 'a')
79
- expect(File.exists?(@temp_file.path))
101
+ expect(File.exist?(@temp_file.path))
80
102
  expect(@temp_file.read.size).to be >= 49
81
103
  end
82
104
  end
@@ -7,7 +7,7 @@ require 'fake_packets'
7
7
 
8
8
  describe PacketFu, "version information" do
9
9
  it "reports a version number" do
10
- PacketFu::VERSION.should match /^1\.[0-9]+\.[0-9]+(.pre)?$/
10
+ PacketFu::VERSION.should match /^[0123]\.[0-9]+\.[0-9]+(.pre)?$/
11
11
  end
12
12
  its(:version) {should eq PacketFu::VERSION}
13
13
 
data/spec/pcap_spec.rb CHANGED
@@ -194,7 +194,7 @@ describe PcapFile do
194
194
 
195
195
  it "should read via #file_to_array and write via #to_f" do
196
196
  # TODO: Figure out why this is failing to write properly when converted to a Tempfile
197
- File.unlink('out.pcap') if File.exists? 'out.pcap'
197
+ File.unlink('out.pcap') if File.exist? 'out.pcap'
198
198
  pcaps = PcapFile.new.file_to_array(:filename => 'test/sample.pcap')
199
199
  pcaps.each {|pkt|
200
200
  packet = Packet.parse pkt
@@ -279,8 +279,8 @@ describe Write do
279
279
  Write.array_to_file(:array => pkts, :file => @temp_file.path)
280
280
 
281
281
  pkts_new = Read.file_to_array(:file => @temp_file.path)
282
- expect(pkts).to be_kind_of(Array)
283
- expect(pkts.size).to eql(11)
282
+ expect(pkts_new).to be_kind_of(Array)
283
+ expect(pkts_new.size).to eql(11)
284
284
  end
285
285
  end
286
286
  end
@@ -45,7 +45,7 @@ module PacketFu
45
45
  it 'yields xPB object per read packet' do
46
46
  idx = 0
47
47
  @pcapng.readfile(@file) do |pkt|
48
- expect(pkt).to be_a(@Pcapng::EPB)
48
+ expect(pkt).to be_a(PcapNG::EPB)
49
49
  idx += 1
50
50
  end
51
51
  expect(idx).to eq(11)
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ unless ENV['SKIP_COVERALLS']
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ end
3
5
 
4
6
  puts "rspec #{RSpec::Core::Version::STRING}"
5
7
  if RSpec::Core::Version::STRING[0] == '3'
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe StructFu, "mixin methods" do
4
-
5
4
  before :each do
6
5
  class StructClass
7
6
  include StructFu
@@ -10,42 +9,40 @@ describe StructFu, "mixin methods" do
10
9
  end
11
10
 
12
11
  it "should provide the basic StructFu methods" do
13
- @sc.respond_to?(:sz).should be true
14
- @sc.respond_to?(:len).should be true
15
- @sc.respond_to?(:typecast).should be true
16
- @sc.respond_to?(:body=).should be true
12
+ expect(@sc).to respond_to(:sz)
13
+ expect(@sc).to respond_to(:len)
14
+ expect(@sc).to respond_to(:typecast)
15
+ expect(@sc).to respond_to(:body=)
17
16
  end
18
17
  end
19
18
 
20
19
  describe StructFu::Int, "basic Int class" do
21
-
22
20
  before :each do
23
21
  @int = StructFu::Int.new(8)
24
22
  end
25
23
 
26
24
  it "should have an initial state" do
27
25
  new_int = StructFu::Int.new
28
- new_int.value.should be_nil
29
- new_int.endian.should be_nil
30
- new_int.width.should be_nil
31
- new_int.default.should == 0
26
+ expect(new_int.value).to be_nil
27
+ expect(new_int.endian).to be_nil
28
+ expect(new_int.width).to be_nil
29
+ expect(new_int.default).to eql(0)
32
30
  end
33
31
 
34
32
  it "should raise when to_s'ed directly" do
35
- expect { @int.to_s}.to raise_error(StandardError, "StructFu::Int#to_s accessed, must be redefined.")
33
+ expect{ @int.to_s}.to raise_error(StandardError, "StructFu::Int#to_s accessed, must be redefined.")
36
34
  end
37
35
 
38
36
  it "should have a value of 8" do
39
- @int.value.should == 8
40
- @int.to_i.should == 8
41
- @int.to_f.to_s.should == "8.0"
37
+ expect(@int.value).to eql(8)
38
+ expect(@int.to_i).to eql(8)
39
+ expect(@int.to_f.to_s).to eql("8.0")
42
40
  end
43
41
 
44
42
  it "should read an integer" do
45
43
  @int.read(7)
46
- @int.to_i.should == 7
44
+ expect(@int.to_i).to eql(7)
47
45
  end
48
-
49
46
  end
50
47
 
51
48
  describe StructFu::Int8, "one byte value" do
@@ -56,82 +53,85 @@ describe StructFu::Int8, "one byte value" do
56
53
 
57
54
  it "should have an initial state" do
58
55
  new_int = StructFu::Int8.new
59
- new_int.value.should be_nil
60
- new_int.endian.should be_nil
61
- new_int.width.should == 1
62
- new_int.default.should == 0
56
+ expect(new_int.value).to be_nil
57
+ expect(new_int.endian).to be_nil
58
+ expect(new_int.width).to eql(1)
59
+ expect(new_int.default).to eql(0)
63
60
  end
64
61
 
65
62
  it "should print a one character packed string" do
66
- @int.to_s.should == "\x0b"
63
+ expect(@int.to_s).to eql("\x0b")
67
64
  end
68
65
 
69
66
  it "should have a value of 11" do
70
- @int.value.should == 11
71
- @int.to_i.should == 11
72
- @int.to_f.to_s.should == "11.0"
67
+ expect(@int.value).to eql(11)
68
+ expect(@int.to_i).to eql(11)
69
+ expect(@int.to_f.to_s).to eql("11.0")
73
70
  end
74
71
 
75
72
  it "should reset with a new integer" do
76
73
  @int.read(2)
77
- @int.to_i.should == 2
78
- @int.to_s.should == "\x02"
74
+ expect(@int.to_i).to eql(2)
75
+ expect(@int.to_s).to eql("\x02")
76
+
79
77
  @int.read(254)
80
- @int.to_i.should == 254
81
- @int.to_s.should == "\xfe".force_encoding("binary")
78
+ expect(@int.to_i).to eql(254)
79
+ expect(@int.to_s).to eql("\xfe".force_encoding("binary"))
82
80
  end
83
81
 
84
82
  end
85
83
 
86
84
  describe StructFu::Int16, "two byte value" do
87
-
88
85
  before :each do
89
86
  @int = StructFu::Int16.new(11)
90
87
  end
91
88
 
92
89
  it "should have an initial state" do
93
90
  new_int = StructFu::Int16.new
94
- new_int.value.should be_nil
95
- new_int.endian.should == :big
96
- new_int.width.should == 2
97
- new_int.default.should == 0
91
+ expect(new_int.value).to be_nil
92
+ expect(new_int.endian).to eql(:big)
93
+ expect(new_int.width).to eql(2)
94
+ expect(new_int.default).to eql(0)
98
95
  end
99
96
 
100
97
  it "should print a two character packed string" do
101
- @int.to_s.should == "\x00\x0b".force_encoding("binary")
98
+ expect(@int.to_s).to eql("\x00\x0b".force_encoding("binary"))
102
99
  end
103
100
 
104
101
  it "should have a value of 11" do
105
- @int.value.should == 11
106
- @int.to_i.should == 11
107
- @int.to_f.to_s.should == "11.0"
102
+ expect(@int.value).to eql(11)
103
+ expect(@int.to_i).to eql(11)
104
+ expect(@int.to_f.to_s).to eql("11.0")
108
105
  end
109
106
 
110
107
  it "should reset with a new integer" do
111
108
  @int.read(2)
112
- @int.to_i.should == 2
113
- @int.to_s.should == "\x00\x02"
109
+ expect(@int.to_i).to eql(2)
110
+ expect(@int.to_s).to eql("\x00\x02")
111
+
114
112
  @int.read(254)
115
- @int.to_i.should == 254
116
- @int.to_s.should == "\x00\xfe".force_encoding("binary")
113
+ expect(@int.to_i).to eql(254)
114
+ expect(@int.to_s).to eql("\x00\xfe".force_encoding("binary"))
117
115
  end
118
116
 
119
117
  it "should be able to set endianness" do
120
118
  int_be = StructFu::Int16.new(11,:big)
121
- int_be.to_s.should == "\x00\x0b"
119
+ expect(int_be.to_s).to eql("\x00\x0b")
120
+
122
121
  int_le = StructFu::Int16.new(11,:little)
123
- int_le.to_s.should == "\x0b\x00"
122
+ expect(int_le.to_s).to eql("\x0b\x00")
124
123
  end
125
124
 
126
125
  it "should be able to switch endianness" do
127
126
  @int.endian.should == :big
128
- @int.to_s.should == "\x00\x0b"
127
+ expect(@int.to_s).to eql("\x00\x0b")
128
+
129
129
  @int.endian = :little
130
- @int.endian.should == :little
130
+ expect(@int.endian).to eql(:little)
131
+
131
132
  @int.read(11)
132
- @int.to_s.should == "\x0b\x00"
133
+ expect(@int.to_s).to eql("\x0b\x00")
133
134
  end
134
-
135
135
  end
136
136
 
137
137
  describe StructFu::Int16le, "2 byte little-endian value" do
@@ -141,7 +141,7 @@ describe StructFu::Int16le, "2 byte little-endian value" do
141
141
  end
142
142
 
143
143
  it "should behave pretty much like any other 16 bit int" do
144
- @int.to_s.should == "\x0b\x00"
144
+ expect(@int.to_s).to eql("\x0b\x00")
145
145
  end
146
146
 
147
147
  it "should raise when you try to change endianness" do
@@ -158,7 +158,7 @@ describe StructFu::Int16be, "2 byte big-endian value" do
158
158
  end
159
159
 
160
160
  it "should behave pretty much like any other 16 bit int" do
161
- @int.to_s.should == "\x00\x0b"
161
+ expect(@int.to_s).to eql("\x00\x0b")
162
162
  end
163
163
 
164
164
  it "should raise when you try to change endianness" do
@@ -176,45 +176,49 @@ describe StructFu::Int32, "four byte value" do
176
176
 
177
177
  it "should have an initial state" do
178
178
  new_int = StructFu::Int32.new
179
- new_int.value.should be_nil
180
- new_int.endian.should == :big
181
- new_int.width.should == 4
182
- new_int.default.should == 0
179
+ expect(new_int.value).to be_nil
180
+ expect(new_int.endian).to eql(:big)
181
+ expect(new_int.width).to eql(4)
182
+ expect(new_int.default).to eql(0)
183
183
  end
184
184
 
185
185
  it "should print a four character packed string" do
186
- @int.to_s.should == "\x00\x00\x00\x0b"
186
+ expect(@int.to_s).to eql("\x00\x00\x00\x0b")
187
187
  end
188
188
 
189
189
  it "should have a value of 11" do
190
- @int.value.should == 11
191
- @int.to_i.should == 11
192
- @int.to_f.to_s.should == "11.0"
190
+ expect(@int.value).to eql(11)
191
+ expect(@int.to_i).to eql(11)
192
+ expect(@int.to_f.to_s).to eql("11.0")
193
193
  end
194
194
 
195
195
  it "should reset with a new integer" do
196
196
  @int.read(2)
197
- @int.to_i.should == 2
198
- @int.to_s.should == "\x00\x00\x00\x02"
197
+ expect(@int.to_i).to eql(2)
198
+ expect(@int.to_s).to eql("\x00\x00\x00\x02")
199
+
199
200
  @int.read(254)
200
- @int.to_i.should == 254
201
- @int.to_s.should == "\x00\x00\x00\xfe".force_encoding("binary")
201
+ expect(@int.to_i).to eql(254)
202
+ expect(@int.to_s).to eql("\x00\x00\x00\xfe".force_encoding("binary"))
202
203
  end
203
204
 
204
205
  it "should be able to set endianness" do
205
206
  int_be = StructFu::Int32.new(11,:big)
206
- int_be.to_s.should == "\x00\x00\x00\x0b"
207
+ expect(int_be.to_s).to eql("\x00\x00\x00\x0b")
208
+
207
209
  int_le = StructFu::Int32.new(11,:little)
208
- int_le.to_s.should == "\x0b\x00\x00\x00"
210
+ expect(int_le.to_s).to eql("\x0b\x00\x00\x00")
209
211
  end
210
212
 
211
213
  it "should be able to switch endianness" do
212
214
  @int.endian.should == :big
213
- @int.to_s.should == "\x00\x00\x00\x0b"
215
+ expect(@int.to_s).to eql("\x00\x00\x00\x0b")
216
+
214
217
  @int.endian = :little
215
- @int.endian.should == :little
218
+ expect(@int.endian).to eql(:little)
219
+
216
220
  @int.read(11)
217
- @int.to_s.should == "\x0b\x00\x00\x00"
221
+ expect(@int.to_s).to eql("\x0b\x00\x00\x00")
218
222
  end
219
223
 
220
224
  end
@@ -226,7 +230,7 @@ describe StructFu::Int32le, "4 byte little-endian value" do
226
230
  end
227
231
 
228
232
  it "should behave pretty much like any other 32 bit int" do
229
- @int.to_s.should == "\x0b\x00\x00\x00"
233
+ expect(@int.to_s).to eql("\x0b\x00\x00\x00")
230
234
  end
231
235
 
232
236
  it "should raise when you try to change endianness" do
@@ -243,7 +247,7 @@ describe StructFu::Int32be, "4 byte big-endian value" do
243
247
  end
244
248
 
245
249
  it "should behave pretty much like any other 32 bit int" do
246
- @int.to_s.should == "\x00\x00\x00\x0b"
250
+ expect(@int.to_s).to eql("\x00\x00\x00\x0b")
247
251
  end
248
252
 
249
253
  it "should raise when you try to change endianness" do
@@ -260,16 +264,16 @@ describe StructFu::String, "a sligtly more special String" do
260
264
  end
261
265
 
262
266
  it "should behave pretty much like a string" do
263
- @str.should be_kind_of(String)
267
+ expect(@str).to be_kind_of(String)
264
268
  end
265
269
 
266
270
  it "should have a read method" do
267
- @str.should respond_to(:read)
271
+ expect(@str).to respond_to(:read)
268
272
  end
269
273
 
270
274
  it "should read data like other StructFu things" do
271
275
  @str.read("hello")
272
- @str.should == "hello"
276
+ expect(@str).to eql("hello")
273
277
  end
274
278
 
275
279
  end
@@ -282,17 +286,17 @@ describe StructFu::IntString do
282
286
 
283
287
  it "should have a length and value" do
284
288
  istr = StructFu::IntString.new("Avast!")
285
- istr.to_s.should == "\x06Avast!"
289
+ expect(istr.to_s).to eql("\x06Avast!")
286
290
  end
287
291
 
288
292
  it "should have a 16-bit length and a value" do
289
293
  istr = StructFu::IntString.new("Avast!",StructFu::Int16)
290
- istr.to_s.should == "\x00\x06Avast!"
294
+ expect(istr.to_s).to eql("\x00\x06Avast!")
291
295
  end
292
296
 
293
297
  it "should have a 32-bit length and a value" do
294
298
  istr = StructFu::IntString.new("Avast!",StructFu::Int32)
295
- istr.to_s.should == "\x00\x00\x00\x06Avast!"
299
+ expect(istr.to_s).to eql("\x00\x00\x00\x06Avast!")
296
300
  end
297
301
 
298
302
  before :each do
@@ -300,35 +304,35 @@ describe StructFu::IntString do
300
304
  end
301
305
 
302
306
  it "should report the correct length with a new string" do
303
- @istr.to_s.should == "\x00\x00\x00\x06Avast!"
307
+ expect(@istr.to_s).to eql("\x00\x00\x00\x06Avast!")
308
+
304
309
  @istr.string = "Ahoy!"
305
- @istr.to_s.should == "\x00\x00\x00\x05Ahoy!"
310
+ expect(@istr.to_s).to eql("\x00\x00\x00\x05Ahoy!")
306
311
  end
307
312
 
308
313
  it "should report the correct length with a new string" do
309
314
  @istr.string = "Ahoy!"
310
- @istr.to_s.should == "\x00\x00\x00\x05Ahoy!"
315
+ expect(@istr.to_s).to eql("\x00\x00\x00\x05Ahoy!")
311
316
  end
312
317
 
313
318
  it "should keep the old length with a new string" do
314
319
  @istr[:string] = "Ahoy!"
315
- @istr.to_s.should == "\x00\x00\x00\x06Ahoy!"
320
+ expect(@istr.to_s).to eql("\x00\x00\x00\x06Ahoy!")
316
321
  end
317
322
 
318
323
  it "should allow for adjusting the length manually" do
319
324
  @istr.len = 16
320
- @istr.to_s.should == "\x00\x00\x00\x10Avast!"
325
+ expect(@istr.to_s).to eql("\x00\x00\x00\x10Avast!")
321
326
  end
322
327
 
323
328
  it "should read in an expected string" do
324
329
  data = "\x00\x00\x00\x09Yo ho ho!"
325
330
  @istr.read(data)
326
- @istr.to_s.should == data
331
+ expect(@istr.to_s).to eql(data)
327
332
  end
328
333
 
329
334
  it "should raise when a string is too short" do
330
335
  data = "\x01A"
331
- expect { @istr.read(data) }.to raise_error(StandardError, "String is too short for type StructFu::Int32")
336
+ expect{ @istr.read(data) }.to raise_error(StandardError, "String is too short for type StructFu::Int32")
332
337
  end
333
-
334
338
  end