orange 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/lib/orange.rb +2 -5
  2. data/spec/orange_spec.rb +5 -0
  3. data/spec/{orange-core/spec_helper.rb → spec_helper.rb} +0 -0
  4. metadata +28 -235
  5. data/lib/orange-core.rb +0 -8
  6. data/lib/orange-core/application.rb +0 -132
  7. data/lib/orange-core/assets/css/exceptions.css +0 -50
  8. data/lib/orange-core/assets/js/exceptions.js +0 -44
  9. data/lib/orange-core/carton.rb +0 -178
  10. data/lib/orange-core/core.rb +0 -266
  11. data/lib/orange-core/magick.rb +0 -270
  12. data/lib/orange-core/middleware/base.rb +0 -96
  13. data/lib/orange-core/middleware/database.rb +0 -45
  14. data/lib/orange-core/middleware/four_oh_four.rb +0 -45
  15. data/lib/orange-core/middleware/globals.rb +0 -17
  16. data/lib/orange-core/middleware/loader.rb +0 -13
  17. data/lib/orange-core/middleware/rerouter.rb +0 -53
  18. data/lib/orange-core/middleware/restful_router.rb +0 -99
  19. data/lib/orange-core/middleware/route_context.rb +0 -39
  20. data/lib/orange-core/middleware/route_site.rb +0 -51
  21. data/lib/orange-core/middleware/show_exceptions.rb +0 -80
  22. data/lib/orange-core/middleware/static.rb +0 -67
  23. data/lib/orange-core/middleware/static_file.rb +0 -32
  24. data/lib/orange-core/middleware/template.rb +0 -60
  25. data/lib/orange-core/packet.rb +0 -232
  26. data/lib/orange-core/plugin.rb +0 -172
  27. data/lib/orange-core/resource.rb +0 -96
  28. data/lib/orange-core/resources/mapper.rb +0 -36
  29. data/lib/orange-core/resources/model_resource.rb +0 -228
  30. data/lib/orange-core/resources/not_found.rb +0 -10
  31. data/lib/orange-core/resources/page_parts.rb +0 -68
  32. data/lib/orange-core/resources/parser.rb +0 -113
  33. data/lib/orange-core/resources/routable_resource.rb +0 -16
  34. data/lib/orange-core/resources/scaffold.rb +0 -106
  35. data/lib/orange-core/stack.rb +0 -226
  36. data/lib/orange-core/templates/exceptions.haml +0 -111
  37. data/lib/orange-core/views/default_resource/create.haml +0 -4
  38. data/lib/orange-core/views/default_resource/edit.haml +0 -9
  39. data/lib/orange-core/views/default_resource/list.haml +0 -10
  40. data/lib/orange-core/views/default_resource/show.haml +0 -4
  41. data/lib/orange-core/views/default_resource/table_row.haml +0 -7
  42. data/lib/orange-core/views/not_found/404.haml +0 -2
  43. data/lib/orange-more.rb +0 -23
  44. data/lib/orange-more/administration.rb +0 -1
  45. data/lib/orange-more/administration/assets/css/admin.css +0 -286
  46. data/lib/orange-more/administration/assets/css/blueprint-ie.css +0 -35
  47. data/lib/orange-more/administration/assets/css/blueprint-print.css +0 -29
  48. data/lib/orange-more/administration/assets/css/blueprint.css +0 -257
  49. data/lib/orange-more/administration/assets/js/jquery.js +0 -152
  50. data/lib/orange-more/administration/cartons/site.rb +0 -7
  51. data/lib/orange-more/administration/cartons/site_carton.rb +0 -12
  52. data/lib/orange-more/administration/cartons/user.rb +0 -27
  53. data/lib/orange-more/administration/middleware/access_control.rb +0 -156
  54. data/lib/orange-more/administration/middleware/site_load.rb +0 -25
  55. data/lib/orange-more/administration/plugin.rb +0 -23
  56. data/lib/orange-more/administration/resources/admin_resource.rb +0 -27
  57. data/lib/orange-more/administration/resources/site_resource.rb +0 -10
  58. data/lib/orange-more/administration/resources/user_resource.rb +0 -40
  59. data/lib/orange-more/administration/templates/admin.haml +0 -25
  60. data/lib/orange-more/administration/views/openid_login.haml +0 -14
  61. data/lib/orange-more/administration/views/users/create.haml +0 -10
  62. data/lib/orange-more/administration/views/users/edit.haml +0 -15
  63. data/lib/orange-more/adverts.rb +0 -1
  64. data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
  65. data/lib/orange-more/adverts/plugin.rb +0 -13
  66. data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
  67. data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
  68. data/lib/orange-more/analytics.rb +0 -1
  69. data/lib/orange-more/analytics/middleware/analytics.rb +0 -30
  70. data/lib/orange-more/analytics/plugin.rb +0 -11
  71. data/lib/orange-more/analytics/resources/analytics_resource.rb +0 -42
  72. data/lib/orange-more/assets.rb +0 -1
  73. data/lib/orange-more/assets/cartons/asset_carton.rb +0 -27
  74. data/lib/orange-more/assets/plugin.rb +0 -13
  75. data/lib/orange-more/assets/resources/asset_resource.rb +0 -115
  76. data/lib/orange-more/assets/views/assets/change.haml +0 -1
  77. data/lib/orange-more/assets/views/assets/create.haml +0 -13
  78. data/lib/orange-more/assets/views/assets/insert.haml +0 -1
  79. data/lib/orange-more/blog.rb +0 -1
  80. data/lib/orange-more/blog/cartons/blog.rb +0 -8
  81. data/lib/orange-more/blog/cartons/blog_post.rb +0 -60
  82. data/lib/orange-more/blog/plugin.rb +0 -14
  83. data/lib/orange-more/blog/resources/blog_post_resource.rb +0 -53
  84. data/lib/orange-more/blog/resources/blog_resource.rb +0 -104
  85. data/lib/orange-more/blog/views/blog/blog_archive_view.haml +0 -6
  86. data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +0 -12
  87. data/lib/orange-more/blog/views/blog/blog_post_view.haml +0 -4
  88. data/lib/orange-more/blog/views/blog/sitemap_row.haml +0 -14
  89. data/lib/orange-more/blog/views/blog_posts/edit.haml +0 -8
  90. data/lib/orange-more/blog/views/blog_posts/show.haml +0 -4
  91. data/lib/orange-more/cloud.rb +0 -1
  92. data/lib/orange-more/cloud/plugin.rb +0 -10
  93. data/lib/orange-more/cloud/resources/cloud_resource.rb +0 -21
  94. data/lib/orange-more/contactforms.rb +0 -1
  95. data/lib/orange-more/contactforms/assets/js/jquery.validate.pack.js +0 -15
  96. data/lib/orange-more/contactforms/assets/js/lib/jquery-1.4.2.js +0 -6240
  97. data/lib/orange-more/contactforms/assets/js/lib/jquery.form.js +0 -660
  98. data/lib/orange-more/contactforms/assets/js/lib/jquery.js +0 -4376
  99. data/lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js +0 -122
  100. data/lib/orange-more/contactforms/cartons/contactforms_carton.rb +0 -12
  101. data/lib/orange-more/contactforms/plugin.rb +0 -13
  102. data/lib/orange-more/contactforms/resources/contactforms_resource.rb +0 -56
  103. data/lib/orange-more/contactforms/views/contactforms/contactform.haml +0 -20
  104. data/lib/orange-more/debugger.rb +0 -1
  105. data/lib/orange-more/debugger/assets/css/debug_bar.css +0 -46
  106. data/lib/orange-more/debugger/middleware/debugger.rb +0 -50
  107. data/lib/orange-more/debugger/plugin.rb +0 -12
  108. data/lib/orange-more/debugger/views/debug_bar.haml +0 -87
  109. data/lib/orange-more/disqus.rb +0 -1
  110. data/lib/orange-more/disqus/plugin.rb +0 -11
  111. data/lib/orange-more/disqus/resources/disqus_resource.rb +0 -9
  112. data/lib/orange-more/disqus/views/disqus/comment_thread.haml +0 -7
  113. data/lib/orange-more/donations.rb +0 -1
  114. data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
  115. data/lib/orange-more/donations/plugin.rb +0 -12
  116. data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
  117. data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
  118. data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
  119. data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
  120. data/lib/orange-more/events.rb +0 -1
  121. data/lib/orange-more/events/assets/js/events.js +0 -55
  122. data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
  123. data/lib/orange-more/events/cartons/orange_event.rb +0 -60
  124. data/lib/orange-more/events/plugin.rb +0 -14
  125. data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
  126. data/lib/orange-more/events/resources/event_resource.rb +0 -147
  127. data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
  128. data/lib/orange-more/events/views/events/create.haml +0 -55
  129. data/lib/orange-more/events/views/events/edit.haml +0 -59
  130. data/lib/orange-more/events/views/events/list.haml +0 -13
  131. data/lib/orange-more/events/views/events/show.haml +0 -4
  132. data/lib/orange-more/events/views/events/table_row.haml +0 -17
  133. data/lib/orange-more/members.rb +0 -1
  134. data/lib/orange-more/members/cartons/member_carton.rb +0 -38
  135. data/lib/orange-more/members/plugin.rb +0 -13
  136. data/lib/orange-more/members/resources/members_resource.rb +0 -327
  137. data/lib/orange-more/members/views/members/create.haml +0 -12
  138. data/lib/orange-more/members/views/members/edit.haml +0 -15
  139. data/lib/orange-more/members/views/members/live.show.haml +0 -1
  140. data/lib/orange-more/members/views/members/login.haml +0 -17
  141. data/lib/orange-more/members/views/members/logout.haml +0 -1
  142. data/lib/orange-more/members/views/members/profile.haml +0 -50
  143. data/lib/orange-more/members/views/members/register.haml +0 -37
  144. data/lib/orange-more/news.rb +0 -1
  145. data/lib/orange-more/news/cartons/news.rb +0 -12
  146. data/lib/orange-more/news/plugin.rb +0 -13
  147. data/lib/orange-more/news/resources/news_resource.rb +0 -82
  148. data/lib/orange-more/news/views/news/archive.haml +0 -14
  149. data/lib/orange-more/news/views/news/edit.haml +0 -7
  150. data/lib/orange-more/news/views/news/latest.haml +0 -8
  151. data/lib/orange-more/news/views/news/sitemap_row.haml +0 -14
  152. data/lib/orange-more/pages.rb +0 -1
  153. data/lib/orange-more/pages/cartons/page_carton.rb +0 -14
  154. data/lib/orange-more/pages/cartons/page_version_carton.rb +0 -12
  155. data/lib/orange-more/pages/plugin.rb +0 -13
  156. data/lib/orange-more/pages/resources/page_resource.rb +0 -179
  157. data/lib/orange-more/pages/views/pages/edit.haml +0 -34
  158. data/lib/orange-more/pages/views/pages/show.haml +0 -6
  159. data/lib/orange-more/sitemap.rb +0 -1
  160. data/lib/orange-more/sitemap/assets/img/sitemap_down.png +0 -0
  161. data/lib/orange-more/sitemap/assets/img/sitemap_down_d.png +0 -0
  162. data/lib/orange-more/sitemap/assets/img/sitemap_indent.png +0 -0
  163. data/lib/orange-more/sitemap/assets/img/sitemap_indent_d.png +0 -0
  164. data/lib/orange-more/sitemap/assets/img/sitemap_outdent.png +0 -0
  165. data/lib/orange-more/sitemap/assets/img/sitemap_outdent_d.png +0 -0
  166. data/lib/orange-more/sitemap/assets/img/sitemap_up.png +0 -0
  167. data/lib/orange-more/sitemap/assets/img/sitemap_up_d.png +0 -0
  168. data/lib/orange-more/sitemap/assets/js/sitemap.js +0 -11
  169. data/lib/orange-more/sitemap/cartons/route.rb +0 -43
  170. data/lib/orange-more/sitemap/middleware/flex_router.rb +0 -25
  171. data/lib/orange-more/sitemap/plugin.rb +0 -17
  172. data/lib/orange-more/sitemap/resources/sitemap_resource.rb +0 -295
  173. data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +0 -30
  174. data/lib/orange-more/sitemap/views/sitemap/breadcrumb.haml +0 -12
  175. data/lib/orange-more/sitemap/views/sitemap/list.haml +0 -4
  176. data/lib/orange-more/sitemap/views/sitemap/one_level.haml +0 -7
  177. data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +0 -15
  178. data/lib/orange-more/sitemap/views/sitemap/sitemap_links.haml +0 -14
  179. data/lib/orange-more/sitemap/views/sitemap/table_row.haml +0 -30
  180. data/lib/orange-more/sitemap/views/sitemap/two_level.haml +0 -13
  181. data/lib/orange-more/slices.rb +0 -1
  182. data/lib/orange-more/slices/middleware/radius_parser.rb +0 -24
  183. data/lib/orange-more/slices/plugin.rb +0 -15
  184. data/lib/orange-more/slices/resources/radius.rb +0 -117
  185. data/lib/orange-more/slices/resources/slices.rb +0 -35
  186. data/lib/orange-more/subsites.rb +0 -1
  187. data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
  188. data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
  189. data/lib/orange-more/subsites/plugin.rb +0 -17
  190. data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
  191. data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
  192. data/lib/orange-more/testimonials.rb +0 -1
  193. data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
  194. data/lib/orange-more/testimonials/plugin.rb +0 -13
  195. data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
  196. data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
  197. data/spec/orange-core/application_spec.rb +0 -183
  198. data/spec/orange-core/carton_spec.rb +0 -136
  199. data/spec/orange-core/core_spec.rb +0 -248
  200. data/spec/orange-core/magick_spec.rb +0 -96
  201. data/spec/orange-core/middleware/base_spec.rb +0 -38
  202. data/spec/orange-core/middleware/globals_spec.rb +0 -3
  203. data/spec/orange-core/middleware/rerouter_spec.rb +0 -3
  204. data/spec/orange-core/middleware/restful_router_spec.rb +0 -3
  205. data/spec/orange-core/middleware/route_context_spec.rb +0 -3
  206. data/spec/orange-core/middleware/route_site_spec.rb +0 -3
  207. data/spec/orange-core/middleware/show_exceptions_spec.rb +0 -3
  208. data/spec/orange-core/middleware/static_file_spec.rb +0 -3
  209. data/spec/orange-core/middleware/static_spec.rb +0 -3
  210. data/spec/orange-core/mock/mock_app.rb +0 -16
  211. data/spec/orange-core/mock/mock_carton.rb +0 -43
  212. data/spec/orange-core/mock/mock_core.rb +0 -2
  213. data/spec/orange-core/mock/mock_middleware.rb +0 -25
  214. data/spec/orange-core/mock/mock_mixins.rb +0 -19
  215. data/spec/orange-core/mock/mock_model_resource.rb +0 -47
  216. data/spec/orange-core/mock/mock_pulp.rb +0 -24
  217. data/spec/orange-core/mock/mock_resource.rb +0 -26
  218. data/spec/orange-core/mock/mock_router.rb +0 -10
  219. data/spec/orange-core/orange_spec.rb +0 -19
  220. data/spec/orange-core/packet_spec.rb +0 -203
  221. data/spec/orange-core/resource_spec.rb +0 -96
  222. data/spec/orange-core/resources/mapper_spec.rb +0 -5
  223. data/spec/orange-core/resources/model_resource_spec.rb +0 -246
  224. data/spec/orange-core/resources/parser_spec.rb +0 -5
  225. data/spec/orange-core/resources/routable_resource_spec.rb +0 -5
  226. data/spec/orange-core/stack_spec.rb +0 -232
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Orange::DefaultHash do
4
- it "should be a kind of Hash" do
5
- Orange::DefaultHash.new.should be_a_kind_of Hash
6
- end
7
- it "should handle setting default" do
8
- x = Orange::DefaultHash.new
9
- y = Orange::DefaultHash.new
10
- x.default = true
11
- y.default = false
12
- x[:not_there].should be_true
13
- y[:not_there].should be_false
14
- end
15
-
16
- it "should handle default in key access []" do
17
- x = Orange::DefaultHash.new
18
- x.default = 'baz'
19
- x[:not_there].should == 'baz'
20
- x[:not_there, 'bar'].should == 'bar'
21
- end
22
- end
23
-
24
- describe Orange::Ignore do
25
- it "should silently accept method" do
26
- o = Orange::Ignore.new
27
- lambda {
28
- o.banana
29
- o.args
30
- o.foo.bar('banana').baz
31
- }.should_not raise_error
32
- end
33
- end
34
-
35
- describe "Orange::Options" do
36
- it "should give a hash on hash" do
37
- Orange::Options.new.hash.should be_an_instance_of(Hash)
38
- end
39
-
40
- it "should accept hash key options" do
41
- hash1 = Orange::Options.new(:one => '1', :two => ['foo']).hash
42
- hash2 = Orange::Options.new(:one => '1').hash
43
- hash3 = Orange::Options.new({:one => '1', :two => ['foo']}).hash
44
- hash4 = Orange::Options.new({:one => '1'}).hash
45
- hash5 = Orange::Options.new(1,2, {:one => '1', :two => ['foo']}).hash
46
- hash6 = Orange::Options.new(1,2, {:one => '1'}).hash
47
- [hash2, hash4, hash6].each{ |hash|
48
- hash.should have_key(:one)
49
- hash.should_not have_key(:three)
50
- hash[:one].should == '1'
51
- }
52
- [hash1, hash3, hash5].each{ |hash|
53
- hash.should have_key(:one)
54
- hash.should have_key(:two)
55
- hash.should_not have_key(:three)
56
- hash[:one].should == '1'
57
- hash[:two].should == ['foo']
58
- }
59
- end
60
-
61
- it "should accept block options" do
62
- hash = Orange::Options.new {
63
- one '1'
64
- two ['foo']
65
- }.hash
66
- hash.should have_key(:one)
67
- hash.should have_key(:two)
68
- hash.should_not have_key(:three)
69
- hash[:one].should == '1'
70
- hash[:two].should == ['foo']
71
- end
72
-
73
- it "should accept both kinds of options" do
74
- hash = Orange::Options.new(:one => '1'){
75
- two ['foo']
76
- }.hash
77
-
78
- hash.should have_key(:one)
79
- hash.should have_key(:two)
80
- hash.should_not have_key(:three)
81
- hash[:one].should == '1'
82
- hash[:two].should == ['foo']
83
- end
84
-
85
- it "should override hash key options with block options" do
86
- hash = Orange::Options.new(:one => '1', :two => [:baz]){
87
- two ['foo']
88
- }.hash
89
-
90
- hash.should have_key(:one)
91
- hash.should have_key(:two)
92
- hash.should_not have_key(:three)
93
- hash[:one].should == '1'
94
- hash[:two].should == ['foo']
95
- end
96
- end
@@ -1,38 +0,0 @@
1
- describe Orange::Middleware::Base do
2
- it "should call init after initializing" do
3
- lambda{
4
- mid = MockOrangeDeathMiddleware.new(nil, Orange::Core.new, :foo => 'bar')
5
- }.should raise_error(RuntimeError, "middleware_init with foo=bar")
6
- end
7
-
8
- it "should create a packet and call packet call" do
9
- mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
10
- mid.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
11
- mid.call({})
12
- end
13
-
14
- it "should pass the packet on by default for packet_call" do
15
- mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
16
- mid.should_receive(:pass).with(an_instance_of(Orange::Packet))
17
- mid.packet_call(empty_packet)
18
- end
19
-
20
- it "should call the downstream app on pass" do
21
- app = mock("downstream")
22
- app2 = mock("downstream_orange")
23
- my_hash = {:foo => :bar}
24
- app.should_receive(:call).with(my_hash).and_return([{},200,[]])
25
- app2.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
26
- mid = MockOrangeBasedMiddlewareTwo.new(app, Orange::Core.new)
27
- mid2 = MockOrangeBasedMiddlewareTwo.new(app2, Orange::Core.new)
28
- mid.call(my_hash)
29
- mid2.call(my_hash)
30
- end
31
-
32
- it "should give access to the orange core on calling orange" do
33
- c = Orange::Core.new
34
- mid = MockOrangeBasedMiddlewareTwo.new(nil, c)
35
- mid.orange.should equal c
36
- end
37
-
38
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::Globals do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::Rerouter do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::RestfulRouter do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::RouteContext do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::RouteSite do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::ShowExceptions do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::StaticFile do
2
- it "should be spec'ed"
3
- end
@@ -1,3 +0,0 @@
1
- describe Orange::Middleware::Static do
2
- it "should be spec'ed"
3
- end
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
- require 'rack/abstract_format'
3
-
4
- class MockApplication < Orange::Application
5
-
6
- end
7
-
8
- class MockApplication2 < Orange::Application
9
-
10
- end
11
-
12
- class MockExitware
13
- def call(env)
14
- raise 'Mock Exitware'
15
- end
16
- end
@@ -1,43 +0,0 @@
1
- class MockCarton < Orange::Carton
2
- def self.scaffold_properties
3
- @scaffold_properties
4
- end
5
- id
6
- admin do
7
- text :admin
8
- end
9
- orange do
10
- text :orange
11
- end
12
- front do
13
- text :front
14
- end
15
- end
16
-
17
- class MockCartonTwo < Orange::Carton
18
- id
19
- def self.get(id)
20
- 'mock_get'
21
- end
22
- def self.all
23
- 'mock_all'
24
- end
25
- def save
26
- raise 'mock_save'
27
- end
28
- def destroy!
29
- raise 'mock_destroy'
30
- end
31
- def update(*args)
32
- raise 'mock_update'
33
- end
34
- end
35
-
36
- class MockCartonBlank < Orange::Carton
37
- def self.levels
38
- @levels
39
- end
40
- end
41
-
42
- class MockCartonBlankTwo < Orange::Carton
43
- end
@@ -1,2 +0,0 @@
1
- class MockCoreSubclass < Orange::Core
2
- end
@@ -1,25 +0,0 @@
1
- class MockOrangeBasedMiddleware < Orange::Middleware::Base
2
- def packet_call(packet)
3
- raise "It's over 9000 #{@core.class.to_s}s!"
4
- end
5
- end
6
-
7
- class MockMiddleware
8
- def initialize(app)
9
- end
10
- def call(env)
11
- raise "I'm in ur #{env[:test]}"
12
- end
13
- end
14
-
15
- class MockOrangeBasedMiddlewareTwo < Orange::Middleware::Base; end
16
- class MockOrangeBasedMiddlewareThree < Orange::Middleware::Base
17
- def stack_init
18
- end
19
- end
20
- class MockOrangeDeathMiddleware < Orange::Middleware::Base
21
- def init(*args)
22
- opts = args.extract_options!
23
- raise "middleware_init with foo=#{opts[:foo]}"
24
- end
25
- end
@@ -1,19 +0,0 @@
1
- module MockMixinOrange1
2
- def mixin_orange_one
3
- end
4
- end
5
-
6
- module MockMixinOrange2
7
- def mixin_orange_two
8
- end
9
- end
10
-
11
- module MockMixinCore1
12
- def mixin_core_one
13
- end
14
- end
15
-
16
- module MockMixinCore2
17
- def mixin_core_two
18
- end
19
- end
@@ -1,47 +0,0 @@
1
- class MockModelResource < Orange::ModelResource
2
- use MockCarton
3
- end
4
-
5
- class MockModelResourceOne < Orange::ModelResource
6
- use MockCarton
7
- def index(packet, *args)
8
- raise 'I see you\'re using index'
9
- end
10
- def show(packet, *args)
11
- raise 'I see you\'re using show'
12
- end
13
- def other(packet, *args)
14
- raise 'I see you\'re using other'
15
- end
16
- def find_one(packet, mode, resource_id =false)
17
- raise 'calling find_one'
18
- end
19
- def find_list(packet, mode)
20
- raise 'calling find_list'
21
- end
22
- end
23
-
24
- class MockModelResourceTwo < Orange::ModelResource
25
- use MockCartonTwo
26
- end
27
-
28
- class MockModelResourceThree < Orange::ModelResource
29
- use MockCarton
30
- def find_extras(packet, mode)
31
- raise 'calling find_extras'
32
- end
33
- end
34
-
35
- class MockModelResourceFour < Orange::ModelResource
36
- use MockCarton
37
- def find_one(packet, mode, resource_id =false)
38
- 'mock_one'
39
- end
40
- def find_list(packet, mode)
41
- 'mock_list'
42
- end
43
- end
44
-
45
- class MockModelResourceExtreme < Orange::ModelResource
46
-
47
- end
@@ -1,24 +0,0 @@
1
- module MockPulpOrange1
2
- def pulp_orange_one
3
- end
4
- end
5
-
6
- module MockPulpOrange2
7
- def pulp_orange_two
8
- end
9
- end
10
-
11
- module MockPulpCore1
12
- def pulp_core_one
13
- end
14
- end
15
-
16
- module MockPulpCore2
17
- def pulp_core_two
18
- end
19
- end
20
-
21
- module MockPulp
22
- def my_new_mock_method
23
- end
24
- end
@@ -1,26 +0,0 @@
1
- class MockResource < Orange::Resource
2
- def mock_method
3
- 'MockResource#mock_method'
4
- end
5
- def afterLoad
6
- @options[:mocked] = true
7
- end
8
- end
9
-
10
- class MockResourceTwo < Orange::Resource
11
- def mock_method
12
- 'MockResource#mock_method'
13
- end
14
- def afterLoad
15
- @options[:mocked] = true
16
- end
17
- def stack_init
18
- true
19
- end
20
- end
21
-
22
- class MockHamlParser < Orange::Resource
23
- def haml(template, packet, opts)
24
- [template, packet, opts]
25
- end
26
- end
@@ -1,10 +0,0 @@
1
-
2
- class TestRouter
3
- attr_accessor :x
4
- def initialize
5
- @x = 0
6
- end
7
- def route(packet)
8
- @x += 1
9
- end
10
- end
@@ -1,19 +0,0 @@
1
- describe Orange do
2
- it "should allow core mixin via mixin method" do
3
- c= Orange::Core.new
4
- c.should_not respond_to(:mixin_orange_one)
5
- Orange.mixin MockMixinOrange1
6
- c2= Orange::Core.new
7
- c.should respond_to(:mixin_orange_one)
8
- c2.should respond_to(:mixin_orange_one)
9
- end
10
- it "should allow pulp mixin via pulp method" do
11
- c= Orange::Core.new
12
- p= Orange::Packet.new(c, {})
13
- p.should_not respond_to(:pulp_orange_one)
14
- Orange.add_pulp MockPulpOrange1
15
- p2= Orange::Packet.new(c, {})
16
- p.should respond_to(:pulp_orange_one)
17
- p2.should respond_to(:pulp_orange_one)
18
- end
19
- end
@@ -1,203 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Orange::Packet do
4
- it "should return a default header content type of html" do
5
- p= Orange::Packet.new(Orange::Core.new, {})
6
- p.finish[1].should have_key("Content-Type")
7
- p.finish[1]["Content-Type"].should eql("text/html")
8
- end
9
-
10
- it "should not create a new object for env if one already exists" do
11
- p= Orange::Packet.new(Orange::Core.new, {})
12
- env = p.env
13
- p2= Orange::Packet.new(Orange::Core.new, env)
14
- p.should equal p2 # Exact equality - same instances
15
- end
16
-
17
- it "should save core passed to it on initialization" do
18
- c= Orange::Core.new
19
- p= Orange::Packet.new(c, {})
20
- p.orange.should equal c
21
- end
22
-
23
- it "should save the env passed to it on init" do
24
- p= Orange::Packet.new(Orange::Core.new, {:test => :foo})
25
- p.env.should have_key(:test)
26
- p.env[:test].should == :foo
27
- p.env.should_not be_empty
28
- end
29
-
30
- it "should add orange.packet and orange.env to env on init" do
31
- p= Orange::Packet.new(Orange::Core.new, {})
32
- p.env.should have_key('orange.packet')
33
- p.env['orange.packet'].should equal p
34
- p.env.should have_key('orange.env')
35
- p.env['orange.env'].should have_key(:request)
36
- p.env['orange.env'][:request].should be_an_instance_of(Rack::Request)
37
- p.env['orange.env'].should have_key(:headers)
38
- p.env['orange.env'][:headers].should be_an_instance_of(Hash)
39
- end
40
-
41
- it "should have access to the orange.env through []" do
42
- p= Orange::Packet.new(Orange::Core.new, {'orange.env' => {'foo' => :true}})
43
- p['foo'].should == :true
44
- p['foo'] = 'banana'
45
- p.env['orange.env']['foo'].should == 'banana'
46
- p['foo'].should == 'banana'
47
- end
48
-
49
- it "should allow defaults through [] calls" do
50
- p= Orange::Packet.new(Orange::Core.new, {})
51
- p['nonexistent'].should be_false
52
- p['nonexistent', true].should be_true
53
- p['nonexistent', true].should_not be_an_instance_of Hash
54
- p['nonexistent', {}].should be_an_instance_of Hash
55
- end
56
-
57
- it "should give access to the rack.session env" do
58
- p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {'foo' => 'banana'}})
59
- p.session.should have_key 'foo'
60
- p.session.should have_key 'flash'
61
- end
62
-
63
- it "should give always have a flash" do
64
- p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {}})
65
- p.session.should have_key 'flash'
66
- p.flash.should == {}
67
- end
68
-
69
- it "should destruct a flash value upon reading" do
70
- p= Orange::Packet.new(Orange::Core.new, {'rack.session' => {}})
71
- p.session.should have_key 'flash'
72
- p.session["flash"]["foo"] = "bar"
73
- p.flash("foo").should == "bar"
74
- p.flash("foo").should be_nil
75
- p.session["flash"].should_not have_key("foo")
76
- p.flash("foo", "bar")
77
- p.flash("foo").should == "bar"
78
- p.flash("foo").should be_nil
79
- p.session["flash"].should_not have_key("foo")
80
- p.flash["foo"] = "bar"
81
- p.flash("foo").should == "bar"
82
- p.flash("foo").should be_nil
83
- p.flash.should_not have_key("foo")
84
- end
85
-
86
- it "should give headers by combining :headers with defaults" do
87
- p= Orange::Packet.new(Orange::Core.new, {})
88
- p.headers.should == p[:headers, {}].with_defaults(Orange::Packet::DEFAULT_HEADERS)
89
- end
90
-
91
- it "should allow setting headers via header(key, val)" do
92
- p= Orange::Packet.new(Orange::Core.new, {})
93
- p.header('Content-Type', 'text/plain')
94
- p.headers['Content-Type'].should == 'text/plain'
95
- end
96
-
97
- it "should allow adding headers with add_header" do
98
- p1= Orange::Packet.new(Orange::Core.new, {})
99
- p2= Orange::Packet.new(Orange::Core.new, {})
100
- p1.add_header('Content-Type', 'text/plain')
101
- p2.header('Content-Type', 'text/plain')
102
- p1.headers['Content-Type'].should == p2.headers['Content-Type']
103
- end
104
-
105
- it "should give access to the core object via orange" do
106
- c= Orange::Core.new
107
- p= Orange::Packet.new(c, {})
108
- p.orange.should equal c
109
- p.orange.should be_an_instance_of(Orange::Core)
110
- end
111
-
112
- it "should create a triple according to rack standards on #finish" do
113
- p= Orange::Packet.new(Orange::Core.new, {})
114
- fin = p.finish
115
- fin[0].should be_a_kind_of Integer
116
- fin[1].should be_a_kind_of Hash
117
- fin[2].should be_a_kind_of Array
118
- end
119
-
120
- it "should give self when using packet" do
121
- p= Orange::Packet.new(Orange::Core.new, {})
122
- p.packet.should equal p
123
- end
124
-
125
- it "should mixin when calling mixin" do
126
- p= Orange::Packet.new(Orange::Core.new, {})
127
- p.should_not respond_to(:pulp_orange_two)
128
- Orange::Packet.mixin MockPulpOrange2
129
- p.should respond_to(:pulp_orange_two)
130
- end
131
-
132
- it "should raise an error if no router set" do
133
- p= Orange::Packet.new(Orange::Core.new, {})
134
- lambda{
135
- p.route
136
- }.should raise_error(RuntimeError, 'Router not found')
137
- end
138
-
139
- it "should pass self to assigned router's route method" do
140
- class MockDeathRouter
141
- def route(p); raise "die, die, death, #{p[:lame]}"; end
142
- end
143
- p= Orange::Packet.new(Orange::Core.new, {})
144
- p['route.router'] = MockDeathRouter.new
145
- p[:lame] = 'death'
146
- lambda{
147
- p.route
148
- }.should_not raise_error(RuntimeError, 'Router not found')
149
- lambda{
150
- p.route
151
- }.should raise_error(RuntimeError, 'die, die, death, death')
152
- end
153
-
154
- it "should give a request object" do
155
- p= Orange::Packet.new(Orange::Core.new, {})
156
- p.request.should be_an_instance_of Rack::Request
157
- end
158
-
159
- it "should store method matchers for extending method_missing handlers" do
160
- class Orange::Packet
161
- meta_methods(/pretend_method_we_dont_want/) do |match, args|
162
- "my mock meta method"
163
- end
164
-
165
- meta_methods(/pretend_method_we_dont_want(\w+)/) do |match, args|
166
- "my mock meta method"
167
- end
168
- end
169
- p= Orange::Packet.new(Orange::Core.new, {})
170
- p.matchers.size.should >= 2
171
- end
172
-
173
- it "should have method_missing capabilities" do
174
- p= Orange::Packet.new(Orange::Core.new, {})
175
- p.should respond_to(:method_missing)
176
- lambda {
177
- p.my_mock_meta_method
178
- p.mock_meta_test
179
- p.mock_meta_test_with_args
180
- }.should raise_error(NoMethodError)
181
- class Orange::Packet
182
- meta_methods(/my_mock_meta_method/) do
183
- "my mock meta method"
184
- end
185
-
186
- meta_methods(/mock_meta_(\w+)/) do |packet, match|
187
- "my mock #{match[1]} method"
188
- end
189
-
190
- meta_methods(/mock_meta_(\w+)_with_args/) do |packet, match, args|
191
- "my mock #{match[1]} method args0 = #{args[0]}"
192
- end
193
- end
194
- lambda {
195
- p.my_mock_meta_method
196
- p.mock_meta_test
197
- p.mock_meta_test_with_args 'test'
198
- }.should_not raise_error(NoMethodError)
199
- p.my_mock_meta_method.should == "my mock meta method"
200
- p.mock_meta_test.should == "my mock test method"
201
- p.mock_meta_test_with_args('test').should == "my mock test method args0 = test"
202
- end
203
- end