ronin-support 0.5.1 → 0.5.2

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.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -1
  6. data/ChangeLog.md +28 -0
  7. data/Gemfile +6 -7
  8. data/README.md +53 -32
  9. data/Rakefile +1 -2
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +5 -5
  12. data/lib/ronin/binary/hexdump.rb +5 -5
  13. data/lib/ronin/binary/hexdump/parser.rb +5 -5
  14. data/lib/ronin/binary/struct.rb +5 -5
  15. data/lib/ronin/binary/template.rb +7 -7
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +37 -31
  19. data/lib/ronin/extensions/ip_addr.rb +6 -7
  20. data/lib/ronin/extensions/kernel.rb +5 -5
  21. data/lib/ronin/extensions/meta.rb +5 -5
  22. data/lib/ronin/extensions/regexp.rb +5 -5
  23. data/lib/ronin/extensions/resolv.rb +5 -5
  24. data/lib/ronin/extensions/string.rb +5 -5
  25. data/lib/ronin/formatting.rb +5 -5
  26. data/lib/ronin/formatting/binary.rb +5 -5
  27. data/lib/ronin/formatting/digest.rb +5 -5
  28. data/lib/ronin/formatting/extensions.rb +5 -5
  29. data/lib/ronin/formatting/extensions/binary.rb +5 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
  32. data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
  33. data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
  35. data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
  36. data/lib/ronin/formatting/extensions/digest.rb +5 -5
  37. data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
  38. data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
  39. data/lib/ronin/formatting/extensions/html.rb +5 -5
  40. data/lib/ronin/formatting/extensions/html/integer.rb +5 -5
  41. data/lib/ronin/formatting/extensions/html/string.rb +7 -7
  42. data/lib/ronin/formatting/extensions/http.rb +5 -5
  43. data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
  44. data/lib/ronin/formatting/extensions/http/string.rb +7 -7
  45. data/lib/ronin/formatting/extensions/sql.rb +5 -5
  46. data/lib/ronin/formatting/extensions/sql/string.rb +15 -13
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +5 -5
  49. data/lib/ronin/formatting/extensions/text/string.rb +5 -5
  50. data/lib/ronin/formatting/html.rb +5 -5
  51. data/lib/ronin/formatting/http.rb +5 -5
  52. data/lib/ronin/formatting/sql.rb +5 -5
  53. data/lib/ronin/formatting/text.rb +5 -5
  54. data/lib/ronin/fuzzing.rb +5 -5
  55. data/lib/ronin/fuzzing/extensions.rb +5 -5
  56. data/lib/ronin/fuzzing/extensions/string.rb +5 -5
  57. data/lib/ronin/fuzzing/fuzzer.rb +5 -5
  58. data/lib/ronin/fuzzing/fuzzing.rb +7 -7
  59. data/lib/ronin/fuzzing/mutator.rb +5 -5
  60. data/lib/ronin/fuzzing/repeater.rb +5 -5
  61. data/lib/ronin/fuzzing/template.rb +5 -5
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +5 -5
  64. data/lib/ronin/network/dns.rb +5 -5
  65. data/lib/ronin/network/esmtp.rb +5 -5
  66. data/lib/ronin/network/extensions.rb +5 -5
  67. data/lib/ronin/network/extensions/dns.rb +5 -5
  68. data/lib/ronin/network/extensions/dns/net.rb +5 -5
  69. data/lib/ronin/network/extensions/esmtp.rb +5 -5
  70. data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
  71. data/lib/ronin/network/extensions/http.rb +5 -5
  72. data/lib/ronin/network/extensions/http/net.rb +5 -5
  73. data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
  74. data/lib/ronin/network/extensions/imap.rb +5 -5
  75. data/lib/ronin/network/extensions/imap/net.rb +5 -5
  76. data/lib/ronin/network/extensions/pop3.rb +5 -5
  77. data/lib/ronin/network/extensions/pop3/net.rb +5 -5
  78. data/lib/ronin/network/extensions/smtp.rb +5 -5
  79. data/lib/ronin/network/extensions/smtp/net.rb +5 -5
  80. data/lib/ronin/network/extensions/ssl.rb +5 -5
  81. data/lib/ronin/network/extensions/ssl/net.rb +5 -5
  82. data/lib/ronin/network/extensions/tcp.rb +5 -5
  83. data/lib/ronin/network/extensions/tcp/net.rb +5 -5
  84. data/lib/ronin/network/extensions/telnet.rb +5 -5
  85. data/lib/ronin/network/extensions/telnet/net.rb +5 -5
  86. data/lib/ronin/network/extensions/udp.rb +5 -5
  87. data/lib/ronin/network/extensions/udp/net.rb +5 -5
  88. data/lib/ronin/network/ftp.rb +5 -5
  89. data/lib/ronin/network/http.rb +5 -5
  90. data/lib/ronin/network/http/exceptions.rb +5 -5
  91. data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
  92. data/lib/ronin/network/http/http.rb +52 -57
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +5 -5
  95. data/lib/ronin/network/mixins.rb +5 -5
  96. data/lib/ronin/network/mixins/dns.rb +5 -5
  97. data/lib/ronin/network/mixins/esmtp.rb +5 -5
  98. data/lib/ronin/network/mixins/ftp.rb +5 -5
  99. data/lib/ronin/network/mixins/http.rb +7 -7
  100. data/lib/ronin/network/mixins/imap.rb +5 -5
  101. data/lib/ronin/network/mixins/mixin.rb +5 -5
  102. data/lib/ronin/network/mixins/pop3.rb +5 -5
  103. data/lib/ronin/network/mixins/smtp.rb +5 -5
  104. data/lib/ronin/network/mixins/ssl.rb +5 -5
  105. data/lib/ronin/network/mixins/tcp.rb +5 -5
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +5 -5
  108. data/lib/ronin/network/mixins/unix.rb +5 -5
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +5 -5
  111. data/lib/ronin/network/proxy.rb +5 -5
  112. data/lib/ronin/network/smtp.rb +5 -5
  113. data/lib/ronin/network/smtp/email.rb +6 -6
  114. data/lib/ronin/network/smtp/smtp.rb +5 -5
  115. data/lib/ronin/network/ssl.rb +7 -7
  116. data/lib/ronin/network/tcp.rb +5 -5
  117. data/lib/ronin/network/tcp/proxy.rb +5 -5
  118. data/lib/ronin/network/tcp/tcp.rb +32 -23
  119. data/lib/ronin/network/telnet.rb +7 -5
  120. data/lib/ronin/network/udp.rb +5 -5
  121. data/lib/ronin/network/udp/proxy.rb +5 -5
  122. data/lib/ronin/network/udp/udp.rb +28 -26
  123. data/lib/ronin/network/unix.rb +7 -7
  124. data/lib/ronin/path.rb +32 -36
  125. data/lib/ronin/spec/ui/output.rb +5 -5
  126. data/lib/ronin/support.rb +5 -5
  127. data/lib/ronin/support/inflector.rb +5 -5
  128. data/lib/ronin/support/support.rb +5 -5
  129. data/lib/ronin/support/version.rb +6 -6
  130. data/lib/ronin/templates.rb +5 -5
  131. data/lib/ronin/templates/erb.rb +5 -5
  132. data/lib/ronin/templates/template.rb +5 -5
  133. data/lib/ronin/ui/output.rb +5 -5
  134. data/lib/ronin/ui/output/helpers.rb +5 -5
  135. data/lib/ronin/ui/output/output.rb +17 -21
  136. data/lib/ronin/ui/output/terminal.rb +5 -5
  137. data/lib/ronin/ui/output/terminal/color.rb +5 -5
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +5 -5
  140. data/lib/ronin/wordlist.rb +7 -7
  141. data/ronin-support.gemspec +1 -0
  142. data/spec/binary/hexdump/parser_spec.rb +22 -22
  143. data/spec/binary/struct_spec.rb +56 -56
  144. data/spec/binary/template_spec.rb +106 -104
  145. data/spec/extensions/enumerable_spec.rb +4 -4
  146. data/spec/extensions/file_spec.rb +12 -14
  147. data/spec/extensions/ip_addr_spec.rb +30 -30
  148. data/spec/extensions/kernel_spec.rb +7 -7
  149. data/spec/extensions/regexp_spec.rb +69 -69
  150. data/spec/extensions/resolv_spec.rb +2 -2
  151. data/spec/extensions/string_spec.rb +30 -29
  152. data/spec/formatting/binary/array_spec.rb +2 -2
  153. data/spec/formatting/binary/base64_spec.rb +8 -8
  154. data/spec/formatting/binary/float_spec.rb +6 -4
  155. data/spec/formatting/binary/integer_spec.rb +25 -25
  156. data/spec/formatting/binary/string_spec.rb +32 -30
  157. data/spec/formatting/digest/string_spec.rb +5 -5
  158. data/spec/formatting/html/integer_spec.rb +6 -6
  159. data/spec/formatting/html/string_spec.rb +10 -10
  160. data/spec/formatting/http/integer_spec.rb +3 -3
  161. data/spec/formatting/http/string_spec.rb +5 -5
  162. data/spec/formatting/sql/string_spec.rb +21 -19
  163. data/spec/formatting/text/array_spec.rb +15 -15
  164. data/spec/formatting/text/string_spec.rb +33 -33
  165. data/spec/fuzzing/extensions/string_spec.rb +11 -11
  166. data/spec/fuzzing/fuzzer_spec.rb +15 -15
  167. data/spec/fuzzing/fuzzing_spec.rb +5 -5
  168. data/spec/fuzzing/mutator_spec.rb +15 -15
  169. data/spec/fuzzing/repeater_spec.rb +7 -7
  170. data/spec/fuzzing/template_spec.rb +11 -11
  171. data/spec/mixin_spec.rb +10 -12
  172. data/spec/network/dns_spec.rb +34 -32
  173. data/spec/network/ftp_spec.rb +9 -9
  174. data/spec/network/http/http_spec.rb +237 -144
  175. data/spec/network/http/proxy_spec.rb +37 -37
  176. data/spec/network/network_spec.rb +1 -1
  177. data/spec/network/proxy_spec.rb +19 -19
  178. data/spec/network/smtp/email_spec.rb +14 -14
  179. data/spec/network/ssl_spec.rb +9 -9
  180. data/spec/network/tcp/proxy_spec.rb +9 -7
  181. data/spec/network/tcp/tcp_spec.rb +161 -118
  182. data/spec/network/telnet_spec.rb +5 -5
  183. data/spec/network/udp/udp_spec.rb +123 -96
  184. data/spec/network/unix_spec.rb +24 -25
  185. data/spec/path_spec.rb +43 -18
  186. data/spec/spec_helper.rb +0 -1
  187. data/spec/support/inflector_spec.rb +4 -4
  188. data/spec/support_spec.rb +1 -1
  189. data/spec/templates/erb_spec.rb +3 -3
  190. data/spec/templates/template_spec.rb +10 -10
  191. data/spec/ui/shell_spec.rb +15 -15
  192. data/spec/wordlist_spec.rb +19 -19
  193. metadata +408 -366
  194. data/.gemtest +0 -0
@@ -8,11 +8,11 @@ describe Resolv do
8
8
  subject { Resolv }
9
9
 
10
10
  it "should create a new Resolv::DNS object if a nameserver is given" do
11
- subject.resolver(nameserver).should be_kind_of(Resolv::DNS)
11
+ expect(subject.resolver(nameserver)).to be_kind_of(Resolv::DNS)
12
12
  end
13
13
 
14
14
  it "should return the default resolver otherwise" do
15
- subject.resolver.should == Resolv
15
+ expect(subject.resolver).to eq(Resolv)
16
16
  end
17
17
  end
18
18
  end
@@ -7,32 +7,32 @@ describe String do
7
7
 
8
8
  it "should enumerate over each sub-string within the String" do
9
9
  subject.each_substring do |sub_string|
10
- should include(sub_string)
10
+ expect(subject).to include(sub_string)
11
11
  end
12
12
  end
13
13
 
14
14
  it "should allow passing the string index back" do
15
15
  subject.each_substring do |sub_string,index|
16
- subject[index,sub_string.length].should == sub_string
16
+ expect(subject[index,sub_string.length]).to eq(sub_string)
17
17
 
18
- should include(sub_string)
18
+ expect(subject).to include(sub_string)
19
19
  end
20
20
  end
21
21
 
22
22
  it "should enumerate over each sub-string of a minimum length" do
23
23
  subject.each_substring(2) do |sub_string|
24
- sub_string.length.should >= 2
24
+ expect(sub_string.length).to be >= 2
25
25
 
26
- should include(sub_string)
26
+ expect(subject).to include(sub_string)
27
27
  end
28
28
  end
29
29
 
30
30
  it "should return an Enumerator when no block is given" do
31
31
  substrings = subject.each_substring
32
32
 
33
- substrings.all? { |sub_string|
33
+ expect(substrings.all? { |sub_string|
34
34
  subject.include?(sub_string)
35
- }.should == true
35
+ }).to be(true)
36
36
  end
37
37
  end
38
38
 
@@ -43,8 +43,8 @@ describe String do
43
43
  seen = []
44
44
 
45
45
  subject.each_unique_substring do |sub_string|
46
- should include(sub_string)
47
- seen.should_not include(sub_string)
46
+ expect(subject).to include(sub_string)
47
+ expect(seen).to_not include(sub_string)
48
48
 
49
49
  seen << sub_string
50
50
  end
@@ -54,10 +54,10 @@ describe String do
54
54
  seen = []
55
55
 
56
56
  subject.each_unique_substring(2) do |sub_string|
57
- sub_string.length.should >= 2
57
+ expect(sub_string.length).to be >= 2
58
58
 
59
- should include(sub_string)
60
- seen.should_not include(sub_string)
59
+ expect(subject).to include(sub_string)
60
+ expect(seen).to_not include(sub_string)
61
61
 
62
62
  seen << sub_string
63
63
  end
@@ -66,12 +66,13 @@ describe String do
66
66
  it "should return an Enumerator when no block is given" do
67
67
  seen = subject.each_unique_substring
68
68
 
69
- seen.all? { |sub_string|
69
+ expect(seen.all? { |sub_string|
70
70
  subject.include?(sub_string)
71
- }.should == true
71
+ }).to be(true)
72
72
 
73
73
  seen = seen.to_a
74
- seen.uniq.should == seen
74
+
75
+ expect(seen.uniq).to eq(seen)
75
76
  end
76
77
  end
77
78
 
@@ -81,7 +82,7 @@ describe String do
81
82
  two = 'What is puzzling you is the nature of my name'
82
83
  common = 'What is puzzling you is the nature of my '
83
84
 
84
- one.common_prefix(two).should == common
85
+ expect(one.common_prefix(two)).to eq(common)
85
86
  end
86
87
 
87
88
  it "should return the common prefix between two Strings with no uncommon postfix" do
@@ -89,21 +90,21 @@ describe String do
89
90
  two = "12345"
90
91
  common = "1234"
91
92
 
92
- one.common_prefix(two).should == common
93
+ expect(one.common_prefix(two)).to eq(common)
93
94
  end
94
95
 
95
96
  it "should return an empty String if there is no common prefix" do
96
97
  one = 'Tell me people'
97
98
  two = 'Whats my name'
98
99
 
99
- one.common_prefix(two).should == ''
100
+ expect(one.common_prefix(two)).to eq('')
100
101
  end
101
102
 
102
103
  it "should return an empty String if one of the strings is also empty" do
103
104
  one = 'Haha'
104
105
  two = ''
105
106
 
106
- one.common_prefix(two).should == ''
107
+ expect(one.common_prefix(two)).to eq('')
107
108
  end
108
109
  end
109
110
 
@@ -113,21 +114,21 @@ describe String do
113
114
  two = "Can't you guess my name"
114
115
  common = 's my name'
115
116
 
116
- one.common_suffix(two).should == common
117
+ expect(one.common_suffix(two)).to eq(common)
117
118
  end
118
119
 
119
120
  it "should return an empty String if there is no common postfix" do
120
121
  one = 'You got to right up, stand up'
121
122
  two = 'stand up for your rights'
122
123
 
123
- one.common_suffix(two).should == ''
124
+ expect(one.common_suffix(two)).to eq('')
124
125
  end
125
126
 
126
127
  it "should return an empty String if one of the strings is also empty" do
127
128
  one = 'You and I must fight for our rights'
128
129
  two = ''
129
130
 
130
- one.common_suffix(two).should == ''
131
+ expect(one.common_suffix(two)).to eq('')
131
132
  end
132
133
  end
133
134
 
@@ -137,7 +138,7 @@ describe String do
137
138
  two = "Tell me honey whats my name"
138
139
  uncommon = 'bab'
139
140
 
140
- one.uncommon_substring(two).should == uncommon
141
+ expect(one.uncommon_substring(two)).to eq(uncommon)
141
142
  end
142
143
 
143
144
  it "should find the uncommon substring between two Strings with a common prefix" do
@@ -145,7 +146,7 @@ describe String do
145
146
  two = 'You and I must fight to survive'
146
147
  uncommon = 'for our rights'
147
148
 
148
- one.uncommon_substring(two).should == uncommon
149
+ expect(one.uncommon_substring(two)).to eq(uncommon)
149
150
  end
150
151
 
151
152
  it "should find the uncommon substring between two Strings with a common postfix" do
@@ -153,26 +154,26 @@ describe String do
153
154
  two = "Can't you guess my name"
154
155
  uncommon = 'Tell me baby what'
155
156
 
156
- one.uncommon_substring(two).should == uncommon
157
+ expect(one.uncommon_substring(two)).to eq(uncommon)
157
158
  end
158
159
  end
159
160
 
160
161
  if RUBY_VERSION < '1.9.'
161
162
  describe "#dump" do
162
163
  it "should dump printable strings" do
163
- "hello".dump.should == '"hello"'
164
+ expect("hello".dump).to eq('"hello"')
164
165
  end
165
166
 
166
167
  it "should dump strings containing control characters" do
167
- "hello\n\b\a".dump.should == '"hello\n\b\a"'
168
+ expect("hello\n\b\a".dump).to eq('"hello\n\b\a"')
168
169
  end
169
170
 
170
171
  it "should dump strings containing non-printable characters" do
171
- "hello\x90\x05\xEF".dump.should == '"hello\x90\x05\xEF"'
172
+ expect("hello\x90\x05\xEF".dump).to eq('"hello\x90\x05\xEF"')
172
173
  end
173
174
 
174
175
  it "should dump the string when calling the inspect method" do
175
- "hello\x90\x05\xEF".inspect.should == '"hello\x90\x05\xEF"'
176
+ expect("hello\x90\x05\xEF".inspect).to eq('"hello\x90\x05\xEF"')
176
177
  end
177
178
  end
178
179
  end
@@ -13,13 +13,13 @@ describe Array do
13
13
 
14
14
  context "when only given a String" do
15
15
  it "should pack elements using Array#pack codes" do
16
- subject.pack('vZ*').should == packed
16
+ expect(subject.pack('vZ*')).to eq(packed)
17
17
  end
18
18
  end
19
19
 
20
20
  context "otherwise" do
21
21
  it "should pack fields using Binary::Template" do
22
- subject.pack(:uint16_le, :string).should == packed
22
+ expect(subject.pack(:uint16_le, :string)).to eq(packed)
23
23
  end
24
24
  end
25
25
  end
@@ -13,37 +13,37 @@ describe Base64 do
13
13
 
14
14
  describe "strict_encode64" do
15
15
  it "should strictly encode a String" do
16
- subject.strict_encode64(string).should == strict_base64
16
+ expect(subject.strict_encode64(string)).to eq(strict_base64)
17
17
  end
18
18
  end
19
19
 
20
20
  describe "strict_decode64" do
21
21
  it "should strict decode an encoded Base64 String" do
22
- subject.strict_decode64(strict_base64).should == string
22
+ expect(subject.strict_decode64(strict_base64)).to eq(string)
23
23
  end
24
24
 
25
25
  it "should raise an ArgumentError for non-strictly encoded Base64" do
26
- lambda {
26
+ expect {
27
27
  subject.strict_decode64(base64)
28
- }.should raise_error(ArgumentError)
28
+ }.to raise_error(ArgumentError)
29
29
  end
30
30
  end
31
31
 
32
32
  describe "urlsafe_encode64" do
33
33
  it "should encode URL-safe Base64 Strings" do
34
- subject.urlsafe_encode64(string).should == urlsafe_base64
34
+ expect(subject.urlsafe_encode64(string)).to eq(urlsafe_base64)
35
35
  end
36
36
  end
37
37
 
38
38
  describe "urlsafe_decode64" do
39
39
  it "should decode URL-safe Base64 String" do
40
- subject.urlsafe_decode64(urlsafe_base64).should == string
40
+ expect(subject.urlsafe_decode64(urlsafe_base64)).to eq(string)
41
41
  end
42
42
 
43
43
  it "should raise an ArgumentError for non-strictly encoded Base64" do
44
- lambda {
44
+ expect {
45
45
  subject.urlsafe_decode64(base64)
46
- }.should raise_error(ArgumentError)
46
+ }.to raise_error(ArgumentError)
47
47
  end
48
48
  end
49
49
  end
@@ -1,3 +1,5 @@
1
+ # encoding: US-ASCII
2
+
1
3
  require 'spec_helper'
2
4
  require 'ronin/formatting/extensions/binary/float'
3
5
 
@@ -13,21 +15,21 @@ describe Float do
13
15
 
14
16
  context "when only given a String" do
15
17
  it "should unpack Strings using String#unpack template Strings" do
16
- subject.pack('E').should == packed
18
+ expect(subject.pack('E')).to eq(packed)
17
19
  end
18
20
  end
19
21
 
20
22
  context "when given a Binary::Template Float type" do
21
23
  it "should unpack Strings using Binary::Template" do
22
- subject.pack(:double_le).should == packed
24
+ expect(subject.pack(:double_le)).to eq(packed)
23
25
  end
24
26
  end
25
27
 
26
28
  context "when given non-Float Binary::Template types" do
27
29
  it "should raise an ArgumentError" do
28
- lambda {
30
+ expect {
29
31
  subject.pack(:int)
30
- }.should raise_error(ArgumentError)
32
+ }.to raise_error(ArgumentError)
31
33
  end
32
34
  end
33
35
  end
@@ -19,14 +19,14 @@ describe Integer do
19
19
  end
20
20
 
21
21
  it "should alias char to the #chr method" do
22
- subject.char.should == subject.chr
22
+ expect(subject.char).to eq(subject.chr)
23
23
  end
24
24
 
25
25
  describe "#hex_escape" do
26
26
  subject { 42 }
27
27
 
28
28
  it "should hex escape an Integer" do
29
- subject.hex_escape.should == "\\x2a"
29
+ expect(subject.hex_escape).to eq("\\x2a")
30
30
  end
31
31
  end
32
32
 
@@ -44,39 +44,39 @@ describe Integer do
44
44
  subject { 0x1337 }
45
45
 
46
46
  it "should return the bytes in little endian ordering by default" do
47
- subject.bytes(4).should == little_endian_long
47
+ expect(subject.bytes(4)).to eq(little_endian_long)
48
48
  end
49
49
 
50
50
  it "should return the bytes for a char in little endian ordering" do
51
- subject.bytes(1, :little).should == little_endian_char
51
+ expect(subject.bytes(1, :little)).to eq(little_endian_char)
52
52
  end
53
53
 
54
54
  it "should return the bytes for a short in little endian ordering" do
55
- subject.bytes(2, :little).should == little_endian_short
55
+ expect(subject.bytes(2, :little)).to eq(little_endian_short)
56
56
  end
57
57
 
58
58
  it "should return the bytes for a long in little endian ordering" do
59
- subject.bytes(4, :little).should == little_endian_long
59
+ expect(subject.bytes(4, :little)).to eq(little_endian_long)
60
60
  end
61
61
 
62
62
  it "should return the bytes for a quad in little endian ordering" do
63
- subject.bytes(8, :little).should == little_endian_quad
63
+ expect(subject.bytes(8, :little)).to eq(little_endian_quad)
64
64
  end
65
65
 
66
66
  it "should return the bytes for a char in big endian ordering" do
67
- subject.bytes(1, :big).should == big_endian_char
67
+ expect(subject.bytes(1, :big)).to eq(big_endian_char)
68
68
  end
69
69
 
70
70
  it "should return the bytes for a short in big endian ordering" do
71
- subject.bytes(2, :big).should == big_endian_short
71
+ expect(subject.bytes(2, :big)).to eq(big_endian_short)
72
72
  end
73
73
 
74
74
  it "should return the bytes for a long in big endian ordering" do
75
- subject.bytes(4, :big).should == big_endian_long
75
+ expect(subject.bytes(4, :big)).to eq(big_endian_long)
76
76
  end
77
77
 
78
78
  it "should return the bytes for a quad in big endian ordering" do
79
- subject.bytes(8, :big).should == big_endian_quad
79
+ expect(subject.bytes(8, :big)).to eq(big_endian_quad)
80
80
  end
81
81
  end
82
82
 
@@ -87,21 +87,21 @@ describe Integer do
87
87
 
88
88
  context "when only given a String" do
89
89
  it "should pack Integers using Array#pack codes" do
90
- subject.pack('V').should == packed
90
+ expect(subject.pack('V')).to eq(packed)
91
91
  end
92
92
  end
93
93
 
94
94
  context "when given a Binary::Template Integer type" do
95
95
  it "should pack Integers using Binary::Template" do
96
- subject.pack(:uint32_le).should == packed
96
+ expect(subject.pack(:uint32_le)).to eq(packed)
97
97
  end
98
98
  end
99
99
 
100
100
  context "when given non-Integer Binary::Template types" do
101
101
  it "should raise an ArgumentError" do
102
- lambda {
102
+ expect {
103
103
  subject.pack(:float)
104
- }.should raise_error(ArgumentError)
104
+ }.to raise_error(ArgumentError)
105
105
  end
106
106
  end
107
107
 
@@ -123,43 +123,43 @@ describe Integer do
123
123
  end
124
124
 
125
125
  it "should pack itself for a little-endian architecture by default" do
126
- subject.pack(i386).should == uint32_le
126
+ expect(subject.pack(i386)).to eq(uint32_le)
127
127
  end
128
128
 
129
129
  it "should pack itself as a short for a little-endian architecture" do
130
- subject.pack(i386,2).should == uint16_le
130
+ expect(subject.pack(i386,2)).to eq(uint16_le)
131
131
  end
132
132
 
133
133
  it "should pack itself as a long for a little-endian architecture" do
134
- subject.pack(i386,4).should == uint32_le
134
+ expect(subject.pack(i386,4)).to eq(uint32_le)
135
135
  end
136
136
 
137
137
  it "should pack itself as a quad for a little-endian architecture" do
138
- subject.pack(i386,8).should == uint64_le
138
+ expect(subject.pack(i386,8)).to eq(uint64_le)
139
139
  end
140
140
 
141
141
  it "should pack itself for a big-endian architecture" do
142
- subject.pack(ppc).should == uint32_be
142
+ expect(subject.pack(ppc)).to eq(uint32_be)
143
143
  end
144
144
 
145
145
  it "should pack itself as a short for a big-endian architecture" do
146
- subject.pack(ppc,2).should == uint16_be
146
+ expect(subject.pack(ppc,2)).to eq(uint16_be)
147
147
  end
148
148
 
149
149
  it "should pack itself as a long for a big-endian architecture" do
150
- subject.pack(ppc,4).should == uint32_be
150
+ expect(subject.pack(ppc,4)).to eq(uint32_be)
151
151
  end
152
152
 
153
153
  it "should pack itself as a quad for a big-endian architecture" do
154
- subject.pack(ppc,8).should == uint64_be
154
+ expect(subject.pack(ppc,8)).to eq(uint64_be)
155
155
  end
156
156
  end
157
157
 
158
158
  context "when given more than 1 or 2 arguments" do
159
159
  it "should raise an ArgumentError" do
160
- lambda {
160
+ expect {
161
161
  subject.pack(1,2,3)
162
- }.should raise_error(ArgumentError)
162
+ }.to raise_error(ArgumentError)
163
163
  end
164
164
  end
165
165
  end
@@ -1,3 +1,5 @@
1
+ # encoding: US-ASCII
2
+
1
3
  require 'spec_helper'
2
4
  require 'ronin/formatting/extensions/binary/string'
3
5
 
@@ -7,35 +9,35 @@ describe String do
7
9
  subject { "hello" }
8
10
 
9
11
  it "should provide String#unpack_original" do
10
- should respond_to(:unpack_original)
12
+ expect(subject).to respond_to(:unpack_original)
11
13
  end
12
14
 
13
15
  it "should provide String#unpack" do
14
- should respond_to(:unpack)
16
+ expect(subject).to respond_to(:unpack)
15
17
  end
16
18
 
17
19
  it "should provide String#depack" do
18
- should respond_to(:depack)
20
+ expect(subject).to respond_to(:depack)
19
21
  end
20
22
 
21
23
  it "should provide String#zlib_inflate" do
22
- should respond_to(:zlib_inflate)
24
+ expect(subject).to respond_to(:zlib_inflate)
23
25
  end
24
26
 
25
27
  it "should provide String#zlib_deflate" do
26
- should respond_to(:zlib_deflate)
28
+ expect(subject).to respond_to(:zlib_deflate)
27
29
  end
28
30
 
29
31
  it "should provide String#hex_unescape" do
30
- should respond_to(:hex_unescape)
32
+ expect(subject).to respond_to(:hex_unescape)
31
33
  end
32
34
 
33
35
  it "should provide String#xor" do
34
- should respond_to(:xor)
36
+ expect(subject).to respond_to(:xor)
35
37
  end
36
38
 
37
39
  it "should provide String#unhexdump" do
38
- should respond_to(:unhexdump)
40
+ expect(subject).to respond_to(:unhexdump)
39
41
  end
40
42
 
41
43
  describe "#unpack" do
@@ -45,13 +47,13 @@ describe String do
45
47
 
46
48
  context "when given only a String" do
47
49
  it "should unpack Strings using String#unpack template Strings" do
48
- subject.unpack('VZ*').should == data
50
+ expect(subject.unpack('VZ*')).to eq(data)
49
51
  end
50
52
  end
51
53
 
52
54
  context "otherwise" do
53
55
  it "should unpack Strings using Binary::Template" do
54
- subject.unpack(:uint32_le, :string).should == data
56
+ expect(subject.unpack(:uint32_le, :string)).to eq(data)
55
57
  end
56
58
  end
57
59
  end
@@ -79,39 +81,39 @@ describe String do
79
81
  let(:ppc_packed_quad) { "\000\000\000\000\000\000\0237" }
80
82
 
81
83
  it "should depack itself for a little-endian architecture" do
82
- i386_packed_int.depack(i386).should == subject
84
+ expect(i386_packed_int.depack(i386)).to eq(subject)
83
85
  end
84
86
 
85
87
  it "should depack itself as a short for a little-endian architecture" do
86
- i386_packed_short.depack(i386,2).should == subject
88
+ expect(i386_packed_short.depack(i386,2)).to eq(subject)
87
89
  end
88
90
 
89
91
  it "should depack itself as a long for a little-endian architecture" do
90
- i386_packed_long.depack(i386,4).should == subject
92
+ expect(i386_packed_long.depack(i386,4)).to eq(subject)
91
93
  end
92
94
 
93
95
  it "should depack itself as a quad for a little-endian architecture" do
94
- i386_packed_quad.depack(i386,8).should == subject
96
+ expect(i386_packed_quad.depack(i386,8)).to eq(subject)
95
97
  end
96
98
 
97
99
  it "should depack itself for a big-endian architecture" do
98
- ppc_packed_int.depack(ppc).should == subject
100
+ expect(ppc_packed_int.depack(ppc)).to eq(subject)
99
101
  end
100
102
 
101
103
  it "should depack itself as a short for a big-endian architecture" do
102
- ppc_packed_short.depack(ppc,2).should == subject
104
+ expect(ppc_packed_short.depack(ppc,2)).to eq(subject)
103
105
  end
104
106
 
105
107
  it "should depack itself as a long for a big-endian architecture" do
106
- ppc_packed_long.depack(ppc,4).should == subject
108
+ expect(ppc_packed_long.depack(ppc,4)).to eq(subject)
107
109
  end
108
110
 
109
111
  it "should depack itself as a quad for a big-endian architecture" do
110
- ppc_packed_quad.depack(ppc,8).should == subject
112
+ expect(ppc_packed_quad.depack(ppc,8)).to eq(subject)
111
113
  end
112
114
 
113
115
  it "should accept String#unpack template strings" do
114
- i386_packed_long.depack('V').should == [subject]
116
+ expect(i386_packed_long.depack('V')).to eq([subject])
115
117
  end
116
118
  end
117
119
  end
@@ -120,7 +122,7 @@ describe String do
120
122
  subject { "hello\0" }
121
123
 
122
124
  it "should base64 encode a String" do
123
- subject.base64_encode.should == "aGVsbG8A\n"
125
+ expect(subject.base64_encode).to eq("aGVsbG8A\n")
124
126
  end
125
127
  end
126
128
 
@@ -128,7 +130,7 @@ describe String do
128
130
  subject { "aGVsbG8A\n" }
129
131
 
130
132
  it "should base64 decode a String" do
131
- subject.base64_decode.should == "hello\0"
133
+ expect(subject.base64_decode).to eq("hello\0")
132
134
  end
133
135
  end
134
136
 
@@ -138,7 +140,7 @@ describe String do
138
140
  end
139
141
 
140
142
  it "should inflate a zlib deflated String" do
141
- subject.zlib_inflate.should == "0f8f5ec6-14dc-46e7-a63a-f89b7d11265b\0"
143
+ expect(subject.zlib_inflate).to eq("0f8f5ec6-14dc-46e7-a63a-f89b7d11265b\0")
142
144
  end
143
145
  end
144
146
 
@@ -146,7 +148,7 @@ describe String do
146
148
  subject { "hello" }
147
149
 
148
150
  it "should zlib deflate a String" do
149
- subject.zlib_deflate.should == "x\x9c\xcbH\xcd\xc9\xc9\a\0\x06,\x02\x15"
151
+ expect(subject.zlib_deflate).to eq("x\x9c\xcbH\xcd\xc9\xc9\a\0\x06,\x02\x15")
150
152
  end
151
153
  end
152
154
 
@@ -154,7 +156,7 @@ describe String do
154
156
  subject { "hello\x4e" }
155
157
 
156
158
  it "should hex escape a String" do
157
- subject.hex_escape.should == "\\x68\\x65\\x6c\\x6c\\x6f\\x4e"
159
+ expect(subject.hex_escape).to eq("\\x68\\x65\\x6c\\x6c\\x6f\\x4e")
158
160
  end
159
161
  end
160
162
 
@@ -165,23 +167,23 @@ describe String do
165
167
  let(:keys) { [0x50, 0x55] }
166
168
 
167
169
  it "should not contain the key used in the xor" do
168
- should_not include(key.chr)
170
+ expect(subject).to_not include(key.chr)
169
171
  end
170
172
 
171
173
  it "should not equal the original string" do
172
- subject.xor(key).should_not == subject
174
+ expect(subject.xor(key)).to_not be == subject
173
175
  end
174
176
 
175
177
  it "should be able to be decoded with another xor" do
176
- subject.xor(key).xor(key).should == subject
178
+ expect(subject.xor(key).xor(key)).to eq(subject)
177
179
  end
178
180
 
179
181
  it "should allow xoring against a single key" do
180
- subject.xor(key).should == "85<<?"
182
+ expect(subject.xor(key)).to eq("85<<?")
181
183
  end
182
184
 
183
185
  it "should allow xoring against multiple keys" do
184
- subject.xor(keys).should == "80<9?"
186
+ expect(subject.xor(keys)).to eq("80<9?")
185
187
  end
186
188
  end
187
189
 
@@ -191,7 +193,7 @@ describe String do
191
193
  let(:raw) { "# Ronin Support\n" }
192
194
 
193
195
  it "should unhexdump a String" do
194
- subject.unhexdump.should == raw
196
+ expect(subject.unhexdump).to eq(raw)
195
197
  end
196
198
  end
197
199
  end