ronin-support 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
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,40 +8,40 @@ describe Network::HTTP::Proxy do
8
8
  it "should parse host-names" do
9
9
  proxy = subject.parse('127.0.0.1')
10
10
 
11
- proxy.host.should == '127.0.0.1'
11
+ expect(proxy.host).to eq('127.0.0.1')
12
12
  end
13
13
 
14
14
  it "should parse 'host:port' URLs" do
15
15
  proxy = subject.parse('127.0.0.1:80')
16
16
 
17
- proxy.host.should == '127.0.0.1'
18
- proxy.port.should == 80
17
+ expect(proxy.host).to eq('127.0.0.1')
18
+ expect(proxy.port).to eq(80)
19
19
  end
20
20
 
21
21
  it "should parse 'user@host:port' URLs" do
22
22
  proxy = subject.parse('joe@127.0.0.1:80')
23
23
 
24
- proxy.user.should == 'joe'
25
- proxy.host.should == '127.0.0.1'
26
- proxy.port.should == 80
24
+ expect(proxy.user).to eq('joe')
25
+ expect(proxy.host).to eq('127.0.0.1')
26
+ expect(proxy.port).to eq(80)
27
27
  end
28
28
 
29
29
  it "should prase 'user:password@host:port' URLs" do
30
30
  proxy = subject.parse('joe:lol@127.0.0.1:80')
31
31
 
32
- proxy.user.should == 'joe'
33
- proxy.password.should == 'lol'
34
- proxy.host.should == '127.0.0.1'
35
- proxy.port.should == 80
32
+ expect(proxy.user).to eq('joe')
33
+ expect(proxy.password).to eq('lol')
34
+ expect(proxy.host).to eq('127.0.0.1')
35
+ expect(proxy.port).to eq(80)
36
36
  end
37
37
 
38
38
  it "should ignore http:// prefixes when parsing proxy URLs" do
39
39
  proxy = subject.parse('http://joe:lol@127.0.0.1:80')
40
40
 
41
- proxy.user.should == 'joe'
42
- proxy.password.should == 'lol'
43
- proxy.host.should == '127.0.0.1'
44
- proxy.port.should == 80
41
+ expect(proxy.user).to eq('joe')
42
+ expect(proxy.password).to eq('lol')
43
+ expect(proxy.host).to eq('127.0.0.1')
44
+ expect(proxy.port).to eq(80)
45
45
  end
46
46
  end
47
47
 
@@ -54,55 +54,55 @@ describe Network::HTTP::Proxy do
54
54
  it "should accept Proxy objects" do
55
55
  proxy = subject.new(:host => host, :port => port)
56
56
 
57
- subject.create(proxy).should == proxy
57
+ expect(subject.create(proxy)).to eq(proxy)
58
58
  end
59
59
 
60
60
  it "should accept URI::HTTP objects" do
61
61
  url = URI::HTTP.build(:host => host, :port => port)
62
62
  proxy = subject.create(url)
63
63
 
64
- proxy.host.should == host
65
- proxy.port.should == port
64
+ expect(proxy.host).to eq(host)
65
+ expect(proxy.port).to eq(port)
66
66
  end
67
67
 
68
68
  it "should accept Hash objects" do
69
69
  hash = {:host => host, :port => port}
70
70
  proxy = subject.create(hash)
71
71
 
72
- proxy.host.should == host
73
- proxy.port.should == port
72
+ expect(proxy.host).to eq(host)
73
+ expect(proxy.port).to eq(port)
74
74
  end
75
75
 
76
76
  it "should accept String objects" do
77
77
  string = "#{host}:#{port}"
78
78
  proxy = subject.create(string)
79
79
 
80
- proxy.host.should == host
81
- proxy.port.should == port
80
+ expect(proxy.host).to eq(host)
81
+ expect(proxy.port).to eq(port)
82
82
  end
83
83
 
84
84
  it "should accept nil" do
85
85
  proxy = subject.create(nil)
86
86
 
87
- proxy.should_not be_enabled
87
+ expect(proxy).not_to be_enabled
88
88
  end
89
89
  end
90
90
 
91
91
  it "should behave like a Hash" do
92
92
  subject[:host] = 'example.com'
93
- subject[:host].should == 'example.com'
93
+ expect(subject[:host]).to eq('example.com')
94
94
  end
95
95
 
96
96
  it "should not have a host by default" do
97
- subject.host.should be_nil
97
+ expect(subject.host).to be_nil
98
98
  end
99
99
 
100
100
  it "should not have a port by default" do
101
- subject.port.should be_nil
101
+ expect(subject.port).to be_nil
102
102
  end
103
103
 
104
104
  it "should be disabled by default" do
105
- subject.should_not be_enabled
105
+ expect(subject).not_to be_enabled
106
106
  end
107
107
 
108
108
  it "should reset the host, port, user and password when disabled" do
@@ -113,10 +113,10 @@ describe Network::HTTP::Proxy do
113
113
 
114
114
  subject.disable!
115
115
 
116
- subject[:host].should be_nil
117
- subject[:port].should be_nil
118
- subject[:user].should be_nil
119
- subject[:password].should be_nil
116
+ expect(subject[:host]).to be_nil
117
+ expect(subject[:port]).to be_nil
118
+ expect(subject[:user]).to be_nil
119
+ expect(subject[:password]).to be_nil
120
120
  end
121
121
 
122
122
  it "should return a URI::HTTP representing the proxy" do
@@ -127,22 +127,22 @@ describe Network::HTTP::Proxy do
127
127
 
128
128
  url = subject.url
129
129
 
130
- url.host.should == 'example.com'
131
- url.port.should == 9001
132
- url.user.should == 'joe'
133
- url.password.should == 'lol'
130
+ expect(url.host).to eq('example.com')
131
+ expect(url.port).to eq(9001)
132
+ expect(url.user).to eq('joe')
133
+ expect(url.password).to eq('lol')
134
134
  end
135
135
 
136
136
  it "should return nil when converting a disabled proxy to a URL" do
137
- subject.url.should be_nil
137
+ expect(subject.url).to be_nil
138
138
  end
139
139
 
140
140
  it "should return the host-name when converted to a String" do
141
141
  subject[:host] = 'example.com'
142
- subject.to_s.should == 'example.com'
142
+ expect(subject.to_s).to eq('example.com')
143
143
  end
144
144
 
145
145
  it "should return an empty String when there is no host-name" do
146
- subject.to_s.should be_empty
146
+ expect(subject.to_s).to be_empty
147
147
  end
148
148
  end
@@ -3,6 +3,6 @@ require 'ronin/network/network'
3
3
 
4
4
  describe Network do
5
5
  it "should determine our public facing IP Address", :network do
6
- subject.ip.should_not be_nil
6
+ expect(subject.ip).not_to be_nil
7
7
  end
8
8
  end
@@ -24,8 +24,8 @@ describe Network::Proxy do
24
24
  :server => [server_host, server_port]
25
25
  )
26
26
 
27
- proxy.port.should == port
28
- proxy.host.should == '0.0.0.0'
27
+ expect(proxy.port).to eq(port)
28
+ expect(proxy.host).to eq('0.0.0.0')
29
29
  end
30
30
 
31
31
  it "should allow setting both the host and port" do
@@ -35,8 +35,8 @@ describe Network::Proxy do
35
35
  :server => [server_host, server_port]
36
36
  )
37
37
 
38
- proxy.port.should == port
39
- proxy.host.should == host
38
+ expect(proxy.port).to eq(port)
39
+ expect(proxy.host).to eq(host)
40
40
  end
41
41
 
42
42
  it "should set the server_host and server_port" do
@@ -46,20 +46,20 @@ describe Network::Proxy do
46
46
  :server => [server_host, server_port]
47
47
  )
48
48
 
49
- proxy.server_host.should == server_host
50
- proxy.server_port.should == server_port
49
+ expect(proxy.server_host).to eq(server_host)
50
+ expect(proxy.server_port).to eq(server_port)
51
51
  end
52
52
  end
53
53
 
54
54
  describe "#on_data" do
55
55
  it "should call on_client_data" do
56
- subject.should_receive(:on_client_data)
56
+ expect(subject).to receive(:on_client_data)
57
57
 
58
58
  subject.on_data { |client,server,data| }
59
59
  end
60
60
 
61
61
  it "should call on_server_data" do
62
- subject.should_receive(:on_server_data)
62
+ expect(subject).to receive(:on_server_data)
63
63
 
64
64
  subject.on_data { |client,server,data| }
65
65
  end
@@ -68,33 +68,33 @@ describe Network::Proxy do
68
68
  describe "actions" do
69
69
  describe "#ignore!" do
70
70
  it "should throw the :ignore action" do
71
- lambda {
71
+ expect {
72
72
  subject.ignore!
73
- }.should throw_symbol(:action, :ignore)
73
+ }.to throw_symbol(:action, :ignore)
74
74
  end
75
75
  end
76
76
 
77
77
  describe "#close!" do
78
78
  it "should throw the :close action" do
79
- lambda {
79
+ expect {
80
80
  subject.close!
81
- }.should throw_symbol(:action, :close)
81
+ }.to throw_symbol(:action, :close)
82
82
  end
83
83
  end
84
84
 
85
85
  describe "#reset!" do
86
86
  it "should throw the :reset action" do
87
- lambda {
87
+ expect {
88
88
  subject.reset!
89
- }.should throw_symbol(:action, :reset)
89
+ }.to throw_symbol(:action, :reset)
90
90
  end
91
91
  end
92
92
 
93
93
  describe "#stop!" do
94
94
  it "should throw the :stop action" do
95
- lambda {
95
+ expect {
96
96
  subject.stop!
97
- }.should throw_symbol(:action, :stop)
97
+ }.to throw_symbol(:action, :stop)
98
98
  end
99
99
  end
100
100
  end
@@ -103,11 +103,11 @@ describe Network::Proxy do
103
103
  subject { proxy.to_s }
104
104
 
105
105
  it "should include the proxy host and port" do
106
- subject.should include("#{host}:#{port}")
106
+ expect(subject).to include("#{host}:#{port}")
107
107
  end
108
108
 
109
109
  it "should include the server host and port" do
110
- subject.should include("#{server_host}:#{server_port}")
110
+ expect(subject).to include("#{server_host}:#{server_port}")
111
111
  end
112
112
  end
113
113
 
@@ -115,7 +115,7 @@ describe Network::Proxy do
115
115
  subject { proxy.inspect }
116
116
 
117
117
  it "should include the output of #to_s" do
118
- subject.should include(proxy.to_s)
118
+ expect(subject).to include(proxy.to_s)
119
119
  end
120
120
  end
121
121
  end
@@ -8,27 +8,27 @@ describe Network::SMTP::Email do
8
8
  it "should default 'date' to Time.now" do
9
9
  email = Network::SMTP::Email.new
10
10
 
11
- email.date.should_not be_nil
11
+ expect(email.date).not_to be_nil
12
12
  end
13
13
 
14
14
  it "should accept a String body" do
15
15
  body = 'hello'
16
16
  email = Network::SMTP::Email.new(:body => body)
17
17
 
18
- email.body.should == [body]
18
+ expect(email.body).to eq([body])
19
19
  end
20
20
 
21
21
  it "should accept an Array body" do
22
22
  body = ['hello', 'world']
23
23
  email = Network::SMTP::Email.new(:body => body)
24
24
 
25
- email.body.should == body
25
+ expect(email.body).to eq(body)
26
26
  end
27
27
 
28
28
  it "should default 'body' to an empty Array" do
29
29
  email = Network::SMTP::Email.new
30
30
 
31
- email.body.should be_empty
31
+ expect(email.body).to be_empty
32
32
  end
33
33
  end
34
34
 
@@ -38,39 +38,39 @@ describe Network::SMTP::Email do
38
38
  it "should add the 'from'" do
39
39
  subject.from = 'joe@example.com'
40
40
 
41
- subject.to_s.should include("From: joe@example.com\n\r")
41
+ expect(subject.to_s).to include("From: joe@example.com\n\r")
42
42
  end
43
43
 
44
44
  context "when formatting 'to'" do
45
45
  it "should accept an Array of addresses" do
46
46
  subject.to = ['alice@example.com', 'joe@example.com']
47
47
 
48
- subject.to_s.should include("To: alice@example.com, joe@example.com\n\r")
48
+ expect(subject.to_s).to include("To: alice@example.com, joe@example.com\n\r")
49
49
  end
50
50
 
51
51
  it "should accept a String" do
52
52
  subject.to = 'joe@example.com'
53
53
 
54
- subject.to_s.should include("To: joe@example.com\n\r")
54
+ expect(subject.to_s).to include("To: joe@example.com\n\r")
55
55
  end
56
56
  end
57
57
 
58
58
  it "should add the 'subject'" do
59
59
  subject.subject = 'Hello'
60
60
 
61
- subject.to_s.should include("Subject: Hello\n\r")
61
+ expect(subject.to_s).to include("Subject: Hello\n\r")
62
62
  end
63
63
 
64
64
  it "should add the 'date'" do
65
65
  subject.date = Date.parse('Sun Apr 24 17:22:55 PDT 2011')
66
66
 
67
- subject.to_s.should include("Date: #{subject.date}\n\r")
67
+ expect(subject.to_s).to include("Date: #{subject.date}\n\r")
68
68
  end
69
69
 
70
70
  it "should add the 'message_id'" do
71
71
  subject.message_id = '1234'
72
72
 
73
- subject.to_s.should include("Message-Id: <#{subject.message_id}>\n\r")
73
+ expect(subject.to_s).to include("Message-Id: <#{subject.message_id}>\n\r")
74
74
  end
75
75
 
76
76
  it "should add additional headers" do
@@ -79,21 +79,21 @@ describe Network::SMTP::Email do
79
79
 
80
80
  lines = subject.to_s.split("\n\r")
81
81
 
82
- lines.should include('X-Foo: Bar')
83
- lines.should include('X-Baz: Quix')
82
+ expect(lines).to include('X-Foo: Bar')
83
+ expect(lines).to include('X-Baz: Quix')
84
84
  end
85
85
 
86
86
  context "when formatting 'body'" do
87
87
  it "should append each line with a CRLF" do
88
88
  subject.body = ['hello', 'world']
89
89
 
90
- subject.to_s.should include("hello\n\rworld")
90
+ expect(subject.to_s).to include("hello\n\rworld")
91
91
  end
92
92
 
93
93
  it "should add a CRLF before the body" do
94
94
  subject.body = ['hello', 'world']
95
95
 
96
- subject.to_s.should include("\n\rhello")
96
+ expect(subject.to_s).to include("\n\rhello")
97
97
  end
98
98
  end
99
99
  end
@@ -6,15 +6,15 @@ describe Network::SSL do
6
6
  subject { Network::SSL::VERIFY }
7
7
 
8
8
  it "should map verify mode names to OpenSSL VERIFY_* constants" do
9
- subject[:peer].should == OpenSSL::SSL::VERIFY_PEER
9
+ expect(subject[:peer]).to eq(OpenSSL::SSL::VERIFY_PEER)
10
10
  end
11
11
 
12
12
  it "should default to VERIFY_NONE if no verify mode name is given" do
13
- subject[nil].should == OpenSSL::SSL::VERIFY_NONE
13
+ expect(subject[nil]).to eq(OpenSSL::SSL::VERIFY_NONE)
14
14
  end
15
15
 
16
16
  it "should raise an exception for unknown verify modes" do
17
- lambda { subject[:foo_bar] }.should raise_error
17
+ expect { subject[:foo_bar] }.to raise_error
18
18
  end
19
19
  end
20
20
 
@@ -30,15 +30,15 @@ describe Network::SSL do
30
30
 
31
31
  describe "#ssl_connect" do
32
32
  it "should connect to an SSL protected port" do
33
- lambda {
33
+ expect {
34
34
  subject.ssl_connect(host,port)
35
- }.should_not raise_error(OpenSSL::SSL::SSLError)
35
+ }.not_to raise_error
36
36
  end
37
37
 
38
38
  it "should return an OpenSSL::SSL::SSLSocket" do
39
39
  socket = subject.ssl_connect(host,port)
40
40
 
41
- socket.should be_kind_of(OpenSSL::SSL::SSLSocket)
41
+ expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
42
42
  end
43
43
 
44
44
  context "when a block is given" do
@@ -49,7 +49,7 @@ describe Network::SSL do
49
49
  socket = yielded_socket
50
50
  end
51
51
 
52
- socket.should be_kind_of(OpenSSL::SSL::SSLSocket)
52
+ expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
53
53
  end
54
54
  end
55
55
  end
@@ -62,8 +62,8 @@ describe Network::SSL do
62
62
  socket = yielded_socket
63
63
  end
64
64
 
65
- socket.should be_kind_of(OpenSSL::SSL::SSLSocket)
66
- socket.should be_closed
65
+ expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
66
+ expect(socket).to be_closed
67
67
  end
68
68
  end
69
69
  end
@@ -29,7 +29,7 @@ describe Network::TCP::Proxy, :network => true do
29
29
  end
30
30
 
31
31
  it "should trigger when a new client connects" do
32
- @socket.readline.should == injection
32
+ expect(@socket.readline).to eq(injection)
33
33
  end
34
34
 
35
35
  after { @socket.close }
@@ -47,7 +47,7 @@ describe Network::TCP::Proxy, :network => true do
47
47
  end
48
48
 
49
49
  it "should trigger after a new client connects" do
50
- @socket.readline.should == injection
50
+ expect(@socket.readline).to eq(injection)
51
51
  end
52
52
 
53
53
  after { @socket.close }
@@ -56,16 +56,18 @@ describe Network::TCP::Proxy, :network => true do
56
56
  describe "#on_client_data" do
57
57
  before do
58
58
  @proxy.on_client_data do |client,server,data|
59
- data.gsub!(/HTTP\/1.1/,'HTTP/1.0')
59
+ if (match = data.match(/HTTP\/(\d\.\d)/))
60
+ client.write("HTTP #{match[1]} detected!\r\n")
61
+ end
60
62
  end
61
63
 
62
64
  @socket = TCPSocket.new(host,port)
63
65
  end
64
66
 
65
67
  it "should trigger when the client sends data" do
66
- @socket.write("GET / HTTP/1.1\r\n\r\n")
68
+ @socket.write("GET /placeholder HTTP/1.0\r\n\r\n")
67
69
 
68
- @socket.readline.should == "HTTP/1.0 302 Found\r\n"
70
+ expect(@socket.readline).to eq("HTTP 1.0 detected!\r\n")
69
71
  end
70
72
 
71
73
  after { @socket.close }
@@ -83,7 +85,7 @@ describe Network::TCP::Proxy, :network => true do
83
85
  it "should trigger when the server sends data" do
84
86
  @socket.write("GET / HTTP/1.0\r\n\r\n")
85
87
 
86
- @socket.read.should include("Connection: keep-alive\r\n")
88
+ expect(@socket.read).to include("Connection: keep-alive\r\n")
87
89
  end
88
90
 
89
91
  after { @socket.close }
@@ -103,7 +105,7 @@ describe Network::TCP::Proxy, :network => true do
103
105
  it "should trigger when the server closes the connection" do
104
106
  @socket.write("GET / HTTP/1.0\r\n\r\n")
105
107
 
106
- @socket.read.end_with?(injection).should be_true
108
+ expect(@socket.read.end_with?(injection)).to be(true)
107
109
  end
108
110
 
109
111
  after { @socket.close }