ronin 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +95 -0
  3. data/Manifest.txt +55 -25
  4. data/README.txt +64 -52
  5. data/Rakefile +21 -14
  6. data/bin/ronin +1 -1
  7. data/bin/ronin-add +1 -1
  8. data/bin/ronin-console +1 -1
  9. data/bin/ronin-help +1 -1
  10. data/bin/ronin-install +1 -1
  11. data/bin/ronin-list +1 -1
  12. data/bin/ronin-remove +1 -1
  13. data/bin/ronin-uninstall +1 -1
  14. data/bin/ronin-update +1 -1
  15. data/lib/ronin.rb +2 -4
  16. data/lib/ronin/arch.rb +66 -21
  17. data/lib/ronin/author.rb +27 -18
  18. data/lib/ronin/cacheable.rb +63 -23
  19. data/lib/ronin/code/emittable.rb +1 -4
  20. data/lib/ronin/code/reference.rb +2 -5
  21. data/lib/ronin/code/symbol_table.rb +1 -4
  22. data/lib/ronin/code/token.rb +1 -4
  23. data/lib/ronin/config.rb +31 -10
  24. data/lib/ronin/database.rb +1 -4
  25. data/lib/ronin/database/database.rb +42 -23
  26. data/lib/ronin/database/exceptions.rb +1 -4
  27. data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
  28. data/lib/ronin/environment.rb +1 -5
  29. data/lib/ronin/extensions.rb +1 -5
  30. data/lib/ronin/extensions/array.rb +8 -6
  31. data/lib/ronin/extensions/file.rb +9 -4
  32. data/lib/ronin/extensions/ip_addr.rb +33 -13
  33. data/lib/ronin/extensions/kernel.rb +44 -9
  34. data/lib/ronin/extensions/meta.rb +1 -4
  35. data/lib/ronin/extensions/string.rb +8 -7
  36. data/lib/ronin/extensions/uri.rb +1 -4
  37. data/lib/ronin/extensions/uri/http.rb +1 -48
  38. data/lib/ronin/extensions/uri/query_params.rb +27 -8
  39. data/lib/ronin/formatting.rb +1 -4
  40. data/lib/ronin/formatting/binary.rb +1 -4
  41. data/lib/ronin/formatting/digest.rb +1 -4
  42. data/lib/ronin/formatting/extensions.rb +1 -4
  43. data/lib/ronin/formatting/extensions/binary.rb +1 -4
  44. data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
  45. data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
  46. data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
  47. data/lib/ronin/formatting/extensions/digest.rb +1 -4
  48. data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
  49. data/lib/ronin/formatting/extensions/http.rb +1 -4
  50. data/lib/ronin/formatting/extensions/http/string.rb +16 -9
  51. data/lib/ronin/formatting/extensions/text.rb +1 -4
  52. data/lib/ronin/formatting/extensions/text/array.rb +17 -7
  53. data/lib/ronin/formatting/extensions/text/string.rb +70 -27
  54. data/lib/ronin/formatting/http.rb +1 -4
  55. data/lib/ronin/formatting/text.rb +1 -4
  56. data/lib/ronin/license.rb +72 -65
  57. data/lib/ronin/model.rb +1 -4
  58. data/lib/ronin/model/has_description.rb +37 -8
  59. data/lib/ronin/model/has_license.rb +12 -8
  60. data/lib/ronin/model/has_name.rb +10 -7
  61. data/lib/ronin/model/has_version.rb +14 -4
  62. data/lib/ronin/model/model.rb +71 -14
  63. data/lib/ronin/network.rb +1 -4
  64. data/lib/ronin/network/esmtp.rb +1 -4
  65. data/lib/ronin/network/extensions.rb +1 -4
  66. data/lib/ronin/network/extensions/esmtp.rb +1 -4
  67. data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
  68. data/lib/ronin/network/extensions/http.rb +1 -4
  69. data/lib/ronin/network/extensions/http/net.rb +319 -531
  70. data/lib/ronin/network/extensions/imap.rb +1 -4
  71. data/lib/ronin/network/extensions/imap/net.rb +50 -23
  72. data/lib/ronin/network/extensions/pop3.rb +1 -4
  73. data/lib/ronin/network/extensions/pop3/net.rb +40 -17
  74. data/lib/ronin/network/extensions/smtp.rb +1 -4
  75. data/lib/ronin/network/extensions/smtp/net.rb +49 -21
  76. data/lib/ronin/network/extensions/tcp.rb +1 -4
  77. data/lib/ronin/network/extensions/tcp/net.rb +234 -31
  78. data/lib/ronin/network/extensions/telnet.rb +1 -4
  79. data/lib/ronin/network/extensions/telnet/net.rb +83 -51
  80. data/lib/ronin/network/extensions/udp.rb +1 -4
  81. data/lib/ronin/network/extensions/udp/net.rb +164 -27
  82. data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
  83. data/lib/ronin/network/helpers/esmtp.rb +129 -0
  84. data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
  85. data/lib/ronin/network/helpers/http.rb +444 -0
  86. data/lib/ronin/network/helpers/imap.rb +115 -0
  87. data/lib/ronin/network/helpers/pop3.rb +110 -0
  88. data/lib/ronin/network/helpers/smtp.rb +123 -0
  89. data/lib/ronin/network/helpers/tcp.rb +309 -0
  90. data/lib/ronin/network/helpers/telnet.rb +158 -0
  91. data/lib/ronin/network/helpers/udp.rb +197 -0
  92. data/lib/ronin/network/http.rb +3 -156
  93. data/lib/ronin/network/http/exceptions.rb +1 -4
  94. data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
  95. data/lib/ronin/network/http/http.rb +214 -0
  96. data/lib/ronin/network/http/proxy.rb +308 -0
  97. data/lib/ronin/network/imap.rb +7 -6
  98. data/lib/ronin/network/pop3.rb +7 -6
  99. data/lib/ronin/network/smtp.rb +1 -4
  100. data/lib/ronin/network/smtp/email.rb +34 -18
  101. data/lib/ronin/network/smtp/smtp.rb +19 -7
  102. data/lib/ronin/network/tcp.rb +1 -4
  103. data/lib/ronin/network/telnet.rb +25 -12
  104. data/lib/ronin/network/udp.rb +1 -4
  105. data/lib/ronin/os.rb +43 -21
  106. data/lib/ronin/path.rb +29 -9
  107. data/lib/ronin/platform.rb +1 -4
  108. data/lib/ronin/platform/exceptions.rb +1 -4
  109. data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
  110. data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
  111. data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
  112. data/lib/ronin/platform/extension.rb +195 -52
  113. data/lib/ronin/platform/extension_cache.rb +60 -24
  114. data/lib/ronin/platform/maintainer.rb +15 -8
  115. data/lib/ronin/platform/object_cache.rb +29 -8
  116. data/lib/ronin/platform/overlay.rb +82 -26
  117. data/lib/ronin/platform/overlay_cache.rb +179 -56
  118. data/lib/ronin/platform/platform.rb +154 -58
  119. data/lib/ronin/platform/ronin.rb +38 -11
  120. data/lib/ronin/product.rb +17 -17
  121. data/lib/ronin/rpc.rb +1 -4
  122. data/lib/ronin/rpc/call.rb +1 -4
  123. data/lib/ronin/rpc/client.rb +1 -4
  124. data/lib/ronin/rpc/console.rb +1 -4
  125. data/lib/ronin/rpc/exceptions.rb +1 -4
  126. data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
  127. data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
  128. data/lib/ronin/rpc/response.rb +1 -4
  129. data/lib/ronin/rpc/service.rb +1 -4
  130. data/lib/ronin/rpc/shell.rb +1 -4
  131. data/lib/ronin/scanners.rb +1 -4
  132. data/lib/ronin/scanners/exceptions.rb +1 -4
  133. data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
  134. data/lib/ronin/scanners/scanner.rb +82 -26
  135. data/lib/ronin/static.rb +1 -4
  136. data/lib/ronin/static/finders.rb +1 -4
  137. data/lib/ronin/static/static.rb +16 -7
  138. data/lib/ronin/templates.rb +2 -4
  139. data/lib/ronin/templates/erb.rb +24 -10
  140. data/lib/ronin/templates/template.rb +130 -0
  141. data/lib/ronin/ui.rb +2 -6
  142. data/lib/ronin/ui/command_line.rb +1 -4
  143. data/lib/ronin/ui/command_line/command.rb +137 -68
  144. data/lib/ronin/ui/command_line/command_line.rb +52 -29
  145. data/lib/ronin/ui/command_line/commands/add.rb +39 -67
  146. data/lib/ronin/ui/command_line/commands/console.rb +23 -27
  147. data/lib/ronin/ui/command_line/commands/help.rb +10 -29
  148. data/lib/ronin/ui/command_line/commands/install.rb +31 -56
  149. data/lib/ronin/ui/command_line/commands/list.rb +34 -52
  150. data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
  151. data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
  152. data/lib/ronin/ui/command_line/commands/update.rb +15 -35
  153. data/lib/ronin/ui/command_line/exceptions.rb +1 -4
  154. data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
  155. data/lib/ronin/ui/console.rb +54 -23
  156. data/lib/ronin/ui/hexdump.rb +1 -4
  157. data/lib/ronin/ui/hexdump/extensions.rb +1 -4
  158. data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
  159. data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
  160. data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
  161. data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
  162. data/lib/ronin/ui/output/handler.rb +121 -0
  163. data/lib/ronin/ui/output/helpers.rb +110 -0
  164. data/lib/ronin/ui/output/output.rb +144 -0
  165. data/lib/ronin/ui/shell.rb +38 -12
  166. data/lib/ronin/version.rb +2 -5
  167. data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
  168. data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
  169. data/lib/ronin/yard/handlers/ruby.rb +27 -0
  170. data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
  171. data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
  172. data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
  173. data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
  174. data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
  175. data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
  176. data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
  177. data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
  178. data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
  179. data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
  180. data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
  181. data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
  182. data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
  183. data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
  184. data/spec/author_spec.rb +3 -3
  185. data/spec/extensions/classes/some_class.rb +2 -0
  186. data/spec/extensions/kernel_spec.rb +17 -0
  187. data/spec/extensions/uri/http_spec.rb +0 -31
  188. data/spec/formatting/binary/integer_spec.rb +4 -0
  189. data/spec/formatting/text/string_spec.rb +96 -0
  190. data/spec/license_spec.rb +6 -6
  191. data/spec/model/classes/basic_model.rb +13 -0
  192. data/spec/model/classes/custom_model.rb +17 -0
  193. data/spec/model/classes/described_model.rb +10 -0
  194. data/spec/model/has_description_spec.rb +42 -0
  195. data/spec/model/has_license_spec.rb +18 -4
  196. data/spec/model/model_spec.rb +68 -0
  197. data/spec/network/helpers/classes/test_helper.rb +11 -0
  198. data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
  199. data/spec/network/helpers/helper_spec.rb +25 -0
  200. data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
  201. data/spec/network/http/proxy_spec.rb +116 -0
  202. data/spec/os_spec.rb +4 -4
  203. data/spec/platform/extension_cache_spec.rb +14 -0
  204. data/spec/platform/extension_spec.rb +11 -0
  205. data/spec/platform/platform_spec.rb +8 -0
  206. data/spec/product_spec.rb +9 -9
  207. data/spec/spec_helper.rb +1 -1
  208. data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
  209. data/spec/templates/classes/example_template.rb +21 -0
  210. data/spec/templates/erb_spec.rb +2 -2
  211. data/spec/templates/helpers/static.rb +5 -0
  212. data/spec/templates/helpers/static/templates/_relative.erb +1 -0
  213. data/spec/templates/helpers/static/templates/example.erb +1 -0
  214. data/spec/templates/template_spec.rb +41 -0
  215. data/spec/ui/command_line/classes/test_command.rb +23 -0
  216. data/spec/ui/command_line/command_spec.rb +31 -0
  217. data/spec/ui/output_spec.rb +29 -0
  218. data/static/ronin/platform/overlay.xsl +135 -114
  219. data/tasks/spec.rb +1 -0
  220. data/tasks/yard.rb +18 -0
  221. metadata +98 -59
  222. metadata.gz.sig +0 -0
  223. data/TODO.txt +0 -15
  224. data/lib/ronin/extensions/hash.rb +0 -62
  225. data/lib/ronin/sessions/esmtp.rb +0 -57
  226. data/lib/ronin/sessions/http.rb +0 -678
  227. data/lib/ronin/sessions/imap.rb +0 -54
  228. data/lib/ronin/sessions/pop3.rb +0 -52
  229. data/lib/ronin/sessions/smtp.rb +0 -57
  230. data/lib/ronin/sessions/tcp.rb +0 -100
  231. data/lib/ronin/sessions/telnet.rb +0 -55
  232. data/lib/ronin/sessions/udp.rb +0 -73
  233. data/lib/ronin/ui/command_line/options.rb +0 -136
  234. data/lib/ronin/ui/diagnostics.rb +0 -66
  235. data/lib/ronin/ui/verbose.rb +0 -58
  236. data/spec/extensions/hash_spec.rb +0 -38
  237. data/spec/sessions/classes/test_session.rb +0 -11
  238. data/spec/sessions/classes/uses_test_session.rb +0 -10
  239. data/spec/sessions/session_spec.rb +0 -25
  240. data/spec/ui/verbose_spec.rb +0 -17
data/spec/license_spec.rb CHANGED
@@ -4,14 +4,14 @@ require 'helpers/database'
4
4
 
5
5
  describe License do
6
6
  it "should require name and description attributes" do
7
- @license = License.new
8
- @license.should_not be_valid
7
+ license = License.new
8
+ license.should_not be_valid
9
9
 
10
- @license.name = 'joke'
11
- @license.should_not be_valid
10
+ license.name = 'joke'
11
+ license.should_not be_valid
12
12
 
13
- @license.description = "yep, it's a joke."
14
- @license.should be_valid
13
+ license.description = "yep, it's a joke."
14
+ license.should be_valid
15
15
  end
16
16
 
17
17
  it "should provide built-in licenses"do
@@ -0,0 +1,13 @@
1
+ require 'ronin/model/model'
2
+
3
+ class BasicModel
4
+
5
+ include Ronin::Model
6
+
7
+ property :id, Serial
8
+
9
+ property :name, String
10
+
11
+ property :age, Integer
12
+
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'ronin/model/model'
2
+
3
+ require 'model/classes/basic_model'
4
+
5
+ class CustomModel < BasicModel
6
+
7
+ include Ronin::Model
8
+
9
+ attr_reader :var
10
+
11
+ def initialize(attributes={})
12
+ super(attributes)
13
+
14
+ @var = 2
15
+ end
16
+
17
+ end
@@ -0,0 +1,10 @@
1
+ require 'ronin/model/has_description'
2
+
3
+ class DescribedModel
4
+
5
+ include Ronin::Model
6
+ include Ronin::Model::HasDescription
7
+
8
+ property :id, Serial
9
+
10
+ end
@@ -0,0 +1,42 @@
1
+ require 'ronin/model/has_description'
2
+
3
+ require 'spec_helper'
4
+ require 'model/classes/described_model'
5
+
6
+ describe Model::HasDescription do
7
+ before(:each) do
8
+ @model = DescribedModel.new
9
+ end
10
+
11
+ it "should allow the setting of the description" do
12
+ @model.description = 'test one'
13
+ @model.description.should == 'test one'
14
+ end
15
+
16
+ it "should strip leading and tailing white-space" do
17
+ @model.description = %{
18
+ test two
19
+ }
20
+
21
+ @model.description.should == 'test two'
22
+ end
23
+
24
+ it "should strip leading and tailing white-space from each line" do
25
+ @model.description = %{
26
+ test
27
+ three
28
+ }
29
+
30
+ @model.description.should == "test\nthree"
31
+ end
32
+
33
+ it "should preserve non-bordering empty lines" do
34
+ @model.description = %{
35
+ test
36
+
37
+ four
38
+ }
39
+
40
+ @model.description.should == "test\n\nfour"
41
+ end
42
+ end
@@ -8,22 +8,36 @@ describe Model::HasLicense do
8
8
  LicensedModel.auto_migrate!
9
9
  end
10
10
 
11
+ it "should define a license relationship" do
12
+ relationship = LicensedModel.relationships['license']
13
+
14
+ relationship.should_not be_nil
15
+ relationship.parent_model.should == License
16
+ end
17
+
18
+ it "should define relationships with License" do
19
+ relationship = License.relationships['licensed_models']
20
+
21
+ relationship.should_not be_nil
22
+ relationship.child_model.should == LicensedModel
23
+ end
24
+
11
25
  it "should have a license" do
12
26
  model = LicensedModel.new(:content => 'bla')
13
- model.license = License.gpl_2
27
+ model.license = License.gpl2
14
28
  model.save
15
29
 
16
- model.license.should == License.gpl_2
30
+ model.license.should == License.gpl2
17
31
  end
18
32
 
19
33
  it "should provide helper methods for querying licensed models" do
20
34
  model = LicensedModel.new(:content => 'stuff here')
21
- model.license = License.gpl_2
35
+ model.license = License.gpl2
22
36
  model.save
23
37
  model.reload
24
38
 
25
39
  LicensedModel.all(
26
40
  :content.like => '%stuff%'
27
- ).licensed_under(:gpl_2).first.should == model
41
+ ).licensed_under(:gpl2).first.should == model
28
42
  end
29
43
  end
@@ -0,0 +1,68 @@
1
+ require 'ronin/model/model'
2
+
3
+ require 'spec_helper'
4
+ require 'model/classes/basic_model'
5
+ require 'model/classes/custom_model'
6
+
7
+ describe Model do
8
+ before(:all) do
9
+ BasicModel.auto_migrate!
10
+ CustomModel.auto_migrate!
11
+ end
12
+
13
+ it "should have a default repository name" do
14
+ BasicModel.default_repository_name.should == Model::REPOSITORY_NAME
15
+ end
16
+
17
+ it "should allow creating new instances of the model" do
18
+ resource = BasicModel.new(:name => 'joe')
19
+
20
+ resource.name.should == 'joe'
21
+ end
22
+
23
+ it "should call initialize when creating new instances of the model" do
24
+ resource = CustomModel.new(:name => 'joe')
25
+
26
+ resource.name.should == 'joe'
27
+ resource.var.should == 2
28
+ end
29
+
30
+ it "should still call initialize when loading from the database" do
31
+ CustomModel.create(:name => 'bob')
32
+
33
+ resource = CustomModel.first
34
+ resource.name.should == 'bob'
35
+ resource.var.should == 2
36
+ end
37
+
38
+ describe "humanize_attributes" do
39
+ before(:all) do
40
+ @resource = BasicModel.new(:name => 'joe', :age => 21)
41
+ end
42
+
43
+ it "should humanize the attributes of a model" do
44
+ @resource.humanize_attributes.should == {
45
+ 'Name' => 'joe',
46
+ 'Age' => '21'
47
+ }
48
+ end
49
+
50
+ it "should exclude certain attributes to humanize" do
51
+ @resource.humanize_attributes(:exclude => [:name]).should == {
52
+ 'Age' => '21'
53
+ }
54
+ end
55
+
56
+ it "should filter out nil values" do
57
+ resource = BasicModel.new(:name => 'joe')
58
+
59
+ resource.humanize_attributes.should == {'Name' => 'joe'}
60
+ end
61
+
62
+ it "should filter out empty values" do
63
+ resource = BasicModel.new(:name => '', :age => 21)
64
+
65
+ resource.humanize_attributes.should == {'Age' => '21'}
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,11 @@
1
+ require 'ronin/network/helpers/helper'
2
+
3
+ module TestHelper
4
+ include Network::Helpers::Helper
5
+
6
+ def connect
7
+ require_variable :host
8
+
9
+ return @host
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'network/helpers/classes/test_helper'
2
+
3
+ class UsesTestHelper
4
+
5
+ include TestHelper
6
+
7
+ # The host variable
8
+ attr_accessor :host
9
+
10
+ end
@@ -0,0 +1,25 @@
1
+ require 'ronin/network/helpers/helper'
2
+
3
+ require 'spec_helper'
4
+ require 'network/helpers/classes/test_helper'
5
+ require 'network/helpers/classes/uses_test_helper'
6
+
7
+ describe Network::Helpers::Helper do
8
+ describe "require_variable" do
9
+ before(:each) do
10
+ @obj = UsesTestHelper.new
11
+ @obj.host = 'www.example.com'
12
+ end
13
+
14
+ it "should raise a RuntimeError exception if a variable is nil" do
15
+ lambda {
16
+ @obj.host = nil
17
+ @obj.connect
18
+ }.should raise_error(RuntimeError)
19
+ end
20
+
21
+ it "should do nothing if the variable is not nil" do
22
+ @obj.connect.should == @obj.host
23
+ end
24
+ end
25
+ end
File without changes
@@ -0,0 +1,116 @@
1
+ require 'ronin/network/http/proxy'
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Network::HTTP::Proxy do
6
+ before(:each) do
7
+ @proxy = Network::HTTP::Proxy.new
8
+ end
9
+
10
+ it "should parse host-names" do
11
+ proxy = Network::HTTP::Proxy.parse('127.0.0.1')
12
+
13
+ proxy.host.should == '127.0.0.1'
14
+ end
15
+
16
+ it "should parse 'host:port' URLs" do
17
+ proxy = Network::HTTP::Proxy.parse('127.0.0.1:80')
18
+
19
+ proxy.host.should == '127.0.0.1'
20
+ proxy.port.should == 80
21
+ end
22
+
23
+ it "should parse 'user@host:port' URLs" do
24
+ proxy = Network::HTTP::Proxy.parse('joe@127.0.0.1:80')
25
+
26
+ proxy.user.should == 'joe'
27
+ proxy.host.should == '127.0.0.1'
28
+ proxy.port.should == 80
29
+ end
30
+
31
+ it "should prase 'user:password@host:port' URLs" do
32
+ proxy = Network::HTTP::Proxy.parse('joe:lol@127.0.0.1:80')
33
+
34
+ proxy.user.should == 'joe'
35
+ proxy.password.should == 'lol'
36
+ proxy.host.should == '127.0.0.1'
37
+ proxy.port.should == 80
38
+ end
39
+
40
+ it "should ignore http:// prefixes when parsing proxy URLs" do
41
+ proxy = Network::HTTP::Proxy.parse('http://joe:lol@127.0.0.1:80')
42
+
43
+ proxy.user.should == 'joe'
44
+ proxy.password.should == 'lol'
45
+ proxy.host.should == '127.0.0.1'
46
+ proxy.port.should == 80
47
+ end
48
+
49
+ it "should behave like a Hash" do
50
+ @proxy[:host] = 'example.com'
51
+ @proxy[:host].should == 'example.com'
52
+ end
53
+
54
+ it "should not have a host by default" do
55
+ @proxy.host.should be_nil
56
+ end
57
+
58
+ it "should have a default port" do
59
+ @proxy.port.should == 8080
60
+ end
61
+
62
+ it "should be disabled by default" do
63
+ @proxy.should_not be_enabled
64
+ end
65
+
66
+ it "should reset the host, port, user and password when disabled" do
67
+ @proxy[:host] = 'example.com'
68
+ @proxy[:port] = 9001
69
+ @proxy[:user] = 'joe'
70
+ @proxy[:password] = 'lol'
71
+
72
+ @proxy.disable!
73
+
74
+ @proxy[:host].should be_nil
75
+ @proxy[:port].should == 8080
76
+ @proxy[:user].should be_nil
77
+ @proxy[:password].should be_nil
78
+ end
79
+
80
+ it "should convert host-names to Strings" do
81
+ @proxy.host = :"example.com"
82
+ @proxy.host.should == 'example.com'
83
+ end
84
+
85
+ it "should convert ports to Integers" do
86
+ @proxy.port = '8001'
87
+ @proxy.port.should == 8001
88
+ end
89
+
90
+ it "should return a URI::HTTP representing the proxy" do
91
+ @proxy[:host] = 'example.com'
92
+ @proxy[:port] = 9001
93
+ @proxy[:user] = 'joe'
94
+ @proxy[:password] = 'lol'
95
+
96
+ url = @proxy.url
97
+
98
+ url.host.should == 'example.com'
99
+ url.port.should == 9001
100
+ url.user.should == 'joe'
101
+ url.password.should == 'lol'
102
+ end
103
+
104
+ it "should return nil when converting a disabled proxy to a URL" do
105
+ @proxy.url.should be_nil
106
+ end
107
+
108
+ it "should return the host-name when converted to a String" do
109
+ @proxy[:host] = 'example.com'
110
+ @proxy.to_s.should == 'example.com'
111
+ end
112
+
113
+ it "should return an empty String when there is no host-name" do
114
+ @proxy.to_s.should be_empty
115
+ end
116
+ end
data/spec/os_spec.rb CHANGED
@@ -4,11 +4,11 @@ require 'helpers/database'
4
4
 
5
5
  describe OS do
6
6
  it "should require a name" do
7
- @os = OS.new
8
- @os.should_not be_valid
7
+ os = OS.new
8
+ os.should_not be_valid
9
9
 
10
- @os.name = 'test'
11
- @os.should be_valid
10
+ os.name = 'test'
11
+ os.should be_valid
12
12
  end
13
13
 
14
14
  it "should provide methods for built-in OSes" do
@@ -6,7 +6,9 @@ require 'spec_helper'
6
6
  describe Platform::ExtensionCache do
7
7
  before(:all) do
8
8
  Platform.load_overlays(overlay_cache_path)
9
+ end
9
10
 
11
+ before(:each) do
10
12
  @cache = Platform::ExtensionCache.new
11
13
  end
12
14
 
@@ -17,6 +19,18 @@ describe Platform::ExtensionCache do
17
19
  ext.name.should == 'test'
18
20
  end
19
21
 
22
+ it "should determine if an extension was loaded" do
23
+ @cache['test']
24
+ @cache.has?('test').should == true
25
+ end
26
+
27
+ it "should select extensions with specific attributes" do
28
+ test = @cache['test']
29
+ random = @cache['random']
30
+
31
+ @cache.with { |ext| ext.name == 'test' }.should == [test]
32
+ end
33
+
20
34
  it "should provide transparent caching of extensions" do
21
35
  ext = @cache['test']
22
36
  ext.should_not be_nil
@@ -5,6 +5,9 @@ require 'spec_helper'
5
5
  describe Platform::Extension do
6
6
  before(:each) do
7
7
  @ext = Platform::Extension.new('test') do
8
+ attr_reader :var
9
+ attr_writer :var
10
+
8
11
  setup do
9
12
  @var = :setup
10
13
  end
@@ -59,4 +62,12 @@ describe Platform::Extension do
59
62
  ext.run_method.should == :running
60
63
  end
61
64
  end
65
+
66
+ it "should allow the definition of reader and writer methods" do
67
+ @ext.run do |ext|
68
+ ext.var.should == :setup
69
+ ext.var = :random
70
+ ext.var.should == :random
71
+ end
72
+ end
62
73
  end