arrow 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/ChangeLog +1590 -0
  2. data/LICENSE +28 -0
  3. data/README +75 -0
  4. data/Rakefile +366 -0
  5. data/Rakefile.local +63 -0
  6. data/data/arrow/applets/TEMPLATE.rb.tpl +53 -0
  7. data/data/arrow/applets/args.rb +50 -0
  8. data/data/arrow/applets/config.rb +55 -0
  9. data/data/arrow/applets/error.rb +63 -0
  10. data/data/arrow/applets/files.rb +46 -0
  11. data/data/arrow/applets/inspect.rb +46 -0
  12. data/data/arrow/applets/nosuchapplet.rb +31 -0
  13. data/data/arrow/applets/status.rb +92 -0
  14. data/data/arrow/applets/test.rb +133 -0
  15. data/data/arrow/applets/tutorial/counter.rb +96 -0
  16. data/data/arrow/applets/tutorial/dingus.rb +67 -0
  17. data/data/arrow/applets/tutorial/hello.rb +34 -0
  18. data/data/arrow/applets/tutorial/hello2.rb +73 -0
  19. data/data/arrow/applets/tutorial/imgtext.rb +90 -0
  20. data/data/arrow/applets/tutorial/imgtext2.rb +286 -0
  21. data/data/arrow/applets/tutorial/index.rb +36 -0
  22. data/data/arrow/applets/tutorial/logo.rb +98 -0
  23. data/data/arrow/applets/tutorial/memcache.rb +61 -0
  24. data/data/arrow/applets/tutorial/missing.rb +37 -0
  25. data/data/arrow/applets/tutorial/protected.rb +100 -0
  26. data/data/arrow/applets/tutorial/redirector.rb +52 -0
  27. data/data/arrow/applets/tutorial/rndimages.rb +159 -0
  28. data/data/arrow/applets/tutorial/sharenotes.rb +83 -0
  29. data/data/arrow/applets/tutorial/subclassed-hello.rb +32 -0
  30. data/data/arrow/applets/tutorial/superhello.rb +72 -0
  31. data/data/arrow/applets/tutorial/timeclock.rb +78 -0
  32. data/data/arrow/applets/view-applet.rb +123 -0
  33. data/data/arrow/applets/view-template.rb +85 -0
  34. data/data/arrow/applets/wiki.rb +274 -0
  35. data/data/arrow/templates/TEMPLATE.tmpl.tpl +36 -0
  36. data/data/arrow/templates/applet-status.tmpl +153 -0
  37. data/data/arrow/templates/args-display.tmpl +120 -0
  38. data/data/arrow/templates/config/display-table.tmpl +36 -0
  39. data/data/arrow/templates/config/display.tmpl +36 -0
  40. data/data/arrow/templates/counter-deleted.tmpl +33 -0
  41. data/data/arrow/templates/counter.tmpl +59 -0
  42. data/data/arrow/templates/dingus.tmpl +55 -0
  43. data/data/arrow/templates/enumtable.tmpl +8 -0
  44. data/data/arrow/templates/error-display.tmpl +92 -0
  45. data/data/arrow/templates/filemap.tmpl +89 -0
  46. data/data/arrow/templates/hello-world-src.tmpl +34 -0
  47. data/data/arrow/templates/hello-world.tmpl +60 -0
  48. data/data/arrow/templates/imgtext/fontlist.tmpl +46 -0
  49. data/data/arrow/templates/imgtext/form.tmpl +70 -0
  50. data/data/arrow/templates/imgtext/reload-error.tmpl +40 -0
  51. data/data/arrow/templates/imgtext/reload.tmpl +55 -0
  52. data/data/arrow/templates/inspect/display.tmpl +80 -0
  53. data/data/arrow/templates/loginform.tmpl +64 -0
  54. data/data/arrow/templates/logout.tmpl +32 -0
  55. data/data/arrow/templates/memcache/display.tmpl +41 -0
  56. data/data/arrow/templates/navbar.incl +27 -0
  57. data/data/arrow/templates/nosuchapplet.tmpl +32 -0
  58. data/data/arrow/templates/printsource.tmpl +35 -0
  59. data/data/arrow/templates/protected.tmpl +36 -0
  60. data/data/arrow/templates/rndimages.tmpl +38 -0
  61. data/data/arrow/templates/service-response.tmpl +13 -0
  62. data/data/arrow/templates/sharenotes/display.tmpl +38 -0
  63. data/data/arrow/templates/status.tmpl +120 -0
  64. data/data/arrow/templates/templateviewer.tmpl +43 -0
  65. data/data/arrow/templates/test/harness.tmpl +57 -0
  66. data/data/arrow/templates/test/list.tmpl +48 -0
  67. data/data/arrow/templates/test/problem.tmpl +42 -0
  68. data/data/arrow/templates/tutorial/index.tmpl +37 -0
  69. data/data/arrow/templates/tutorial/missingapplet.tmpl +29 -0
  70. data/data/arrow/templates/view-applet-nosuch.tmpl +32 -0
  71. data/data/arrow/templates/view-applet.tmpl +40 -0
  72. data/data/arrow/templates/view-template.tmpl +83 -0
  73. data/data/arrow/templates/wiki/formerror.tmpl +47 -0
  74. data/data/arrow/templates/wiki/markup_help.incl +6 -0
  75. data/data/arrow/templates/wiki/new.tmpl +56 -0
  76. data/data/arrow/templates/wiki/new_system.tmpl +122 -0
  77. data/data/arrow/templates/wiki/sectionlist.tmpl +43 -0
  78. data/data/arrow/templates/wiki/show.tmpl +34 -0
  79. data/docs/manual/layouts/default.page +43 -0
  80. data/docs/manual/lib/api-filter.rb +81 -0
  81. data/docs/manual/lib/editorial-filter.rb +64 -0
  82. data/docs/manual/lib/examples-filter.rb +244 -0
  83. data/docs/manual/lib/links-filter.rb +117 -0
  84. data/lib/apache/fakerequest.rb +448 -0
  85. data/lib/apache/logger.rb +33 -0
  86. data/lib/arrow.rb +51 -0
  87. data/lib/arrow/acceptparam.rb +207 -0
  88. data/lib/arrow/applet.rb +725 -0
  89. data/lib/arrow/appletmixins.rb +218 -0
  90. data/lib/arrow/appletregistry.rb +590 -0
  91. data/lib/arrow/applettestcase.rb +503 -0
  92. data/lib/arrow/broker.rb +255 -0
  93. data/lib/arrow/cache.rb +176 -0
  94. data/lib/arrow/config-loaders/yaml.rb +75 -0
  95. data/lib/arrow/config.rb +615 -0
  96. data/lib/arrow/constants.rb +24 -0
  97. data/lib/arrow/cookie.rb +359 -0
  98. data/lib/arrow/cookieset.rb +108 -0
  99. data/lib/arrow/dispatcher.rb +368 -0
  100. data/lib/arrow/dispatcherloader.rb +50 -0
  101. data/lib/arrow/exceptions.rb +61 -0
  102. data/lib/arrow/fallbackhandler.rb +48 -0
  103. data/lib/arrow/formvalidator.rb +631 -0
  104. data/lib/arrow/htmltokenizer.rb +343 -0
  105. data/lib/arrow/logger.rb +488 -0
  106. data/lib/arrow/logger/apacheoutputter.rb +69 -0
  107. data/lib/arrow/logger/arrayoutputter.rb +63 -0
  108. data/lib/arrow/logger/coloroutputter.rb +111 -0
  109. data/lib/arrow/logger/fileoutputter.rb +96 -0
  110. data/lib/arrow/logger/htmloutputter.rb +54 -0
  111. data/lib/arrow/logger/outputter.rb +123 -0
  112. data/lib/arrow/mixins.rb +425 -0
  113. data/lib/arrow/monkeypatches.rb +94 -0
  114. data/lib/arrow/object.rb +117 -0
  115. data/lib/arrow/path.rb +196 -0
  116. data/lib/arrow/service.rb +447 -0
  117. data/lib/arrow/session.rb +289 -0
  118. data/lib/arrow/session/dbstore.rb +100 -0
  119. data/lib/arrow/session/filelock.rb +160 -0
  120. data/lib/arrow/session/filestore.rb +132 -0
  121. data/lib/arrow/session/id.rb +98 -0
  122. data/lib/arrow/session/lock.rb +253 -0
  123. data/lib/arrow/session/md5id.rb +42 -0
  124. data/lib/arrow/session/nulllock.rb +42 -0
  125. data/lib/arrow/session/posixlock.rb +166 -0
  126. data/lib/arrow/session/sha1id.rb +54 -0
  127. data/lib/arrow/session/store.rb +366 -0
  128. data/lib/arrow/session/usertrackid.rb +52 -0
  129. data/lib/arrow/spechelpers.rb +73 -0
  130. data/lib/arrow/template.rb +713 -0
  131. data/lib/arrow/template/attr.rb +31 -0
  132. data/lib/arrow/template/call.rb +31 -0
  133. data/lib/arrow/template/comment.rb +33 -0
  134. data/lib/arrow/template/container.rb +118 -0
  135. data/lib/arrow/template/else.rb +41 -0
  136. data/lib/arrow/template/elsif.rb +44 -0
  137. data/lib/arrow/template/escape.rb +53 -0
  138. data/lib/arrow/template/export.rb +87 -0
  139. data/lib/arrow/template/for.rb +145 -0
  140. data/lib/arrow/template/if.rb +78 -0
  141. data/lib/arrow/template/import.rb +119 -0
  142. data/lib/arrow/template/include.rb +206 -0
  143. data/lib/arrow/template/iterator.rb +208 -0
  144. data/lib/arrow/template/nodes.rb +734 -0
  145. data/lib/arrow/template/parser.rb +571 -0
  146. data/lib/arrow/template/prettyprint.rb +53 -0
  147. data/lib/arrow/template/render.rb +191 -0
  148. data/lib/arrow/template/selectlist.rb +94 -0
  149. data/lib/arrow/template/set.rb +87 -0
  150. data/lib/arrow/template/timedelta.rb +81 -0
  151. data/lib/arrow/template/unless.rb +78 -0
  152. data/lib/arrow/template/urlencode.rb +51 -0
  153. data/lib/arrow/template/yield.rb +139 -0
  154. data/lib/arrow/templatefactory.rb +125 -0
  155. data/lib/arrow/testcase.rb +567 -0
  156. data/lib/arrow/transaction.rb +608 -0
  157. data/rake/191_compat.rb +26 -0
  158. data/rake/dependencies.rb +76 -0
  159. data/rake/documentation.rb +114 -0
  160. data/rake/helpers.rb +502 -0
  161. data/rake/hg.rb +282 -0
  162. data/rake/manual.rb +787 -0
  163. data/rake/packaging.rb +129 -0
  164. data/rake/publishing.rb +278 -0
  165. data/rake/style.rb +62 -0
  166. data/rake/svn.rb +668 -0
  167. data/rake/testing.rb +187 -0
  168. data/rake/verifytask.rb +64 -0
  169. data/spec/arrow/acceptparam_spec.rb +157 -0
  170. data/spec/arrow/applet_spec.rb +575 -0
  171. data/spec/arrow/appletmixins_spec.rb +409 -0
  172. data/spec/arrow/appletregistry_spec.rb +294 -0
  173. data/spec/arrow/broker_spec.rb +153 -0
  174. data/spec/arrow/config_spec.rb +224 -0
  175. data/spec/arrow/cookieset_spec.rb +164 -0
  176. data/spec/arrow/dispatcher_spec.rb +137 -0
  177. data/spec/arrow/dispatcherloader_spec.rb +65 -0
  178. data/spec/arrow/formvalidator_spec.rb +781 -0
  179. data/spec/arrow/logger_spec.rb +346 -0
  180. data/spec/arrow/mixins_spec.rb +120 -0
  181. data/spec/arrow/service_spec.rb +645 -0
  182. data/spec/arrow/session_spec.rb +121 -0
  183. data/spec/arrow/template/iterator_spec.rb +222 -0
  184. data/spec/arrow/templatefactory_spec.rb +185 -0
  185. data/spec/arrow/transaction_spec.rb +319 -0
  186. data/spec/arrow_spec.rb +37 -0
  187. data/spec/lib/appletmatchers.rb +281 -0
  188. data/spec/lib/constants.rb +77 -0
  189. data/spec/lib/helpers.rb +41 -0
  190. data/spec/lib/matchers.rb +44 -0
  191. data/tests/cookie.tests.rb +310 -0
  192. data/tests/path.tests.rb +157 -0
  193. data/tests/session.tests.rb +111 -0
  194. data/tests/session_id.tests.rb +82 -0
  195. data/tests/session_lock.tests.rb +191 -0
  196. data/tests/session_store.tests.rb +53 -0
  197. data/tests/template.tests.rb +1360 -0
  198. metadata +339 -0
@@ -0,0 +1,346 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ BEGIN {
4
+ require 'pathname'
5
+ basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
+
7
+ libdir = basedir + "lib"
8
+
9
+ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
10
+ }
11
+
12
+ require 'rubygems'
13
+ require 'spec'
14
+ require 'apache/fakerequest'
15
+ require 'arrow'
16
+ require 'arrow/logger'
17
+
18
+ require 'spec/lib/matchers'
19
+ require 'spec/lib/constants'
20
+ require 'spec/lib/helpers'
21
+
22
+
23
+ include Arrow::TestConstants
24
+
25
+
26
+ #####################################################################
27
+ ### C O N T E X T S
28
+ #####################################################################
29
+
30
+ describe Arrow::Logger do
31
+ include Arrow::SpecHelpers
32
+
33
+ before( :each ) do
34
+ Arrow::Logger.reset
35
+ end
36
+
37
+ after( :all ) do
38
+ Arrow::Logger.reset
39
+ end
40
+
41
+
42
+ it "has a global anonymous singleton instance" do
43
+ Arrow::Logger.global.should be_an_instance_of( Arrow::Logger )
44
+ Arrow::Logger.global.module.should == Object
45
+ end
46
+
47
+
48
+ it "writes every message to the global logger" do
49
+ outputter = mock( "logging outputter" )
50
+
51
+ Arrow::Logger.global.outputters << outputter
52
+
53
+ outputter.should_receive( :write ).with( duck_type(:strftime), :debug, "(global)", nil, "test message" )
54
+
55
+ Arrow::Logger.global.level = :debug
56
+ Arrow::Logger.global.debug "test message"
57
+ end
58
+
59
+
60
+ it "doesn't output a message if its level is less than the level set in the logger" do
61
+ outputter = mock( "logging outputter" )
62
+
63
+ Arrow::Logger.global.outputters << outputter
64
+
65
+ outputter.should_not_receive( :write ).
66
+ with( duck_type(:strftime), :debug, "(global)", nil, "debug message" )
67
+ outputter.should_receive( :write ).
68
+ with( duck_type(:strftime), :info, "(global)", nil, "info message" )
69
+
70
+ Arrow::Logger.global.level = :info
71
+ Arrow::Logger.global.debug "debug message"
72
+ Arrow::Logger.global.info "info message"
73
+ end
74
+
75
+
76
+ it "creates loggers for specific classes via its index operator" do
77
+ klass = Class.new
78
+ Arrow::Logger[ klass ].should be_an_instance_of( Arrow::Logger )
79
+ Arrow::Logger[ klass ].should_not == Arrow::Logger.global
80
+ end
81
+
82
+
83
+ it "propagates log messages from class-specific loggers to the global logger" do
84
+ outputter = mock( "logging outputter" )
85
+ classoutputter = mock( "outputter for a class" )
86
+
87
+ klass = Class.new
88
+
89
+ Arrow::Logger.global.outputters << outputter
90
+ Arrow::Logger.global.level = :info
91
+
92
+ Arrow::Logger[ klass ].outputters << classoutputter
93
+ Arrow::Logger[ klass ].level = :info
94
+
95
+ outputter.should_receive( :write ).
96
+ with( duck_type(:strftime), :info, klass.inspect, nil, "test message" )
97
+ classoutputter.should_receive( :write ).
98
+ with( duck_type(:strftime), :info, klass.inspect, nil, "test message" )
99
+
100
+ Arrow::Logger[ klass ].info "test message"
101
+ end
102
+
103
+
104
+ it "propagates log messages from specific class loggers to more-general ones" do
105
+ outputter = mock( "logging outputter" )
106
+ classoutputter = mock( "outputter for a class" )
107
+ subclassoutputter = mock( "outputter for a subclass" )
108
+
109
+ klass = Class.new
110
+ subclass = Class.new( klass )
111
+
112
+ Arrow::Logger.global.outputters << outputter
113
+ Arrow::Logger.global.level = :info
114
+
115
+ Arrow::Logger[ klass ].outputters << classoutputter
116
+ Arrow::Logger[ klass ].level = :info
117
+
118
+ Arrow::Logger[ subclass ].outputters << subclassoutputter
119
+ Arrow::Logger[ subclass ].level = :info
120
+
121
+ outputter.should_receive( :write ).
122
+ with( duck_type(:strftime), :info, subclass.inspect, nil, "test message" )
123
+ classoutputter.should_receive( :write ).
124
+ with( duck_type(:strftime), :info, subclass.inspect, nil, "test message" )
125
+ subclassoutputter.should_receive( :write ).
126
+ with( duck_type(:strftime), :info, subclass.inspect, nil, "test message" )
127
+
128
+ Arrow::Logger[ subclass ].info "test message"
129
+ end
130
+
131
+ it "never writes a message more than once to an outputter, even it it's set on more than " +
132
+ "one logger in the hierarchy" do
133
+ outputter = mock( "logging outputter" )
134
+
135
+ klass = Class.new
136
+ subclass = Class.new( klass )
137
+
138
+ Arrow::Logger.global.outputters << outputter
139
+ Arrow::Logger.global.level = :info
140
+
141
+ Arrow::Logger[ klass ].outputters << outputter
142
+ Arrow::Logger[ klass ].level = :info
143
+
144
+ Arrow::Logger[ subclass ].outputters << outputter
145
+ Arrow::Logger[ subclass ].level = :info
146
+
147
+ outputter.should_receive( :write ).once.
148
+ with( duck_type(:strftime), :info, subclass.inspect, nil, "test message" )
149
+
150
+ Arrow::Logger[ subclass ].info "test message"
151
+ end
152
+
153
+
154
+ it "can look up a logger by class name" do
155
+ Arrow::Logger[ "Arrow::Object" ].should be_equal( Arrow::Logger[Arrow::Object] )
156
+ end
157
+
158
+
159
+ it "can look up a logger by an instance of a class" do
160
+ Arrow::Logger[ Arrow::Object.new ].should be_equal( Arrow::Logger[Arrow::Object] )
161
+ end
162
+
163
+
164
+ it "can return a readable name for the module which it logs for" do
165
+ Arrow::Logger[ Arrow::Object ].readable_name.should == 'Arrow::Object'
166
+ end
167
+
168
+ it "can return a readable name for the module which it logs for, even if it's an anonymous class" do
169
+ klass = Class.new
170
+ Arrow::Logger[ klass ].readable_name.should == klass.inspect
171
+ end
172
+
173
+ it "can return a readable name for the global logger" do
174
+ Arrow::Logger.global.readable_name.should == '(global)'
175
+ end
176
+
177
+
178
+ it "can return its current level as a Symbol" do
179
+ Arrow::Logger.global.level = :notice
180
+ Arrow::Logger.global.readable_level.should == :notice
181
+ end
182
+
183
+
184
+ it "knows which loggers are for more-general classes" do
185
+ mod = Module.new
186
+ class1 = Class.new
187
+ class2 = Class.new( class1 ) do
188
+ include mod
189
+ end
190
+ class3 = Class.new( class2 )
191
+
192
+ Arrow::Logger[ class3 ].hierloggers.should == [
193
+ Arrow::Logger[class3],
194
+ Arrow::Logger[class2],
195
+ Arrow::Logger[mod],
196
+ Arrow::Logger[class1],
197
+ Arrow::Logger.global,
198
+ ]
199
+ end
200
+
201
+ it "knows which loggers are for more-general classes that are of the specified level or lower" do
202
+ mod = Module.new
203
+ class1 = Class.new
204
+ class2 = Class.new( class1 ) do
205
+ include mod
206
+ end
207
+ class3 = Class.new( class2 )
208
+
209
+ Arrow::Logger[ class2 ].level = :debug
210
+
211
+ Arrow::Logger[ class3 ].hierloggers( :debug ).should == [
212
+ Arrow::Logger[class2],
213
+ ]
214
+ end
215
+
216
+ it "can yield loggers for more-general classes" do
217
+ mod = Module.new
218
+ class1 = Class.new
219
+ class2 = Class.new( class1 ) do
220
+ include mod
221
+ end
222
+ class3 = Class.new( class2 )
223
+
224
+ loggers = []
225
+
226
+ Arrow::Logger[ class3 ].hierloggers do |l|
227
+ loggers << l
228
+ end
229
+
230
+ loggers.should == [
231
+ Arrow::Logger[class3],
232
+ Arrow::Logger[class2],
233
+ Arrow::Logger[mod],
234
+ Arrow::Logger[class1],
235
+ Arrow::Logger.global,
236
+ ]
237
+ end
238
+
239
+ it "knows which outputters are for more-general classes" do
240
+ mod = Module.new
241
+ class1 = Class.new
242
+ class2 = Class.new( class1 ) do
243
+ include mod
244
+ end
245
+ class3 = Class.new( class2 )
246
+
247
+ outputter1 = stub( "class2's outputter" )
248
+ Arrow::Logger[class2].outputters << outputter1
249
+ outputter2 = stub( "mod's outputter" )
250
+ Arrow::Logger[mod].outputters << outputter2
251
+
252
+ Arrow::Logger[ class3 ].hieroutputters.should == [
253
+ outputter1,
254
+ outputter2,
255
+ ]
256
+ end
257
+
258
+ it "can yield outputters for more-general classes" do
259
+ mod = Module.new
260
+ class1 = Class.new
261
+ class2 = Class.new( class1 ) do
262
+ include mod
263
+ end
264
+ class3 = Class.new( class2 )
265
+
266
+ outputter1 = stub( "class2's outputter" )
267
+ Arrow::Logger[class2].outputters << outputter1
268
+ outputter2 = stub( "mod's outputter" )
269
+ Arrow::Logger[mod].outputters << outputter2
270
+
271
+ outputters = []
272
+ Arrow::Logger[ class3 ].hieroutputters do |outp, logger|
273
+ outputters << outp
274
+ end
275
+
276
+ outputters.should == [
277
+ outputter1,
278
+ outputter2,
279
+ ]
280
+ end
281
+
282
+
283
+ it "includes an exception's backtrace if it is set at the log message" do
284
+ outputter = mock( "outputter" )
285
+ Arrow::Logger.global.outputters << outputter
286
+
287
+ outputter.should_receive( :write ).
288
+ with( duck_type(:strftime), :error, "(global)", nil, %r{Glah\.:\n } )
289
+
290
+ begin
291
+ raise "Glah."
292
+ rescue => err
293
+ Arrow::Logger.global.error( err )
294
+ end
295
+ end
296
+
297
+
298
+ it "can parse a single-word log setting" do
299
+ Arrow::Logger.parse_log_setting( 'debug' ).should == [ :debug, nil ]
300
+ end
301
+
302
+ it "can parse a two-word log setting" do
303
+ level, uri = Arrow::Logger.parse_log_setting( 'info apache' )
304
+
305
+ level.should == :info
306
+ uri.should be_an_instance_of( URI::Generic )
307
+ uri.path.should == 'apache'
308
+ end
309
+
310
+ it "can parse a word+uri log setting" do
311
+ uristring = 'error dbi://www:password@localhost/www.errorlog?driver=postgresql'
312
+ level, uri = Arrow::Logger.parse_log_setting( uristring )
313
+
314
+ level.should == :error
315
+ uri.should be_an_instance_of( URI::Generic )
316
+ uri.scheme.should == 'dbi'
317
+ uri.user.should == 'www'
318
+ uri.password.should == 'password'
319
+ uri.host.should == 'localhost'
320
+ uri.path.should == '/www.errorlog'
321
+ uri.query.should == 'driver=postgresql'
322
+ end
323
+
324
+
325
+ it "resets the level of any message written to it if its forced_level attribute is set" do
326
+ klass = Class.new
327
+ outputter = mock( "outputter" )
328
+ globaloutputter = mock( "global outputter" )
329
+
330
+ Arrow::Logger[ klass ].level = :info
331
+ Arrow::Logger[ klass ].forced_level = :debug
332
+ Arrow::Logger[ klass ].outputters << outputter
333
+
334
+ Arrow::Logger.global.level = :debug
335
+ Arrow::Logger.global.outputters << globaloutputter
336
+
337
+ outputter.should_not_receive( :write )
338
+ globaloutputter.should_receive( :write ).
339
+ with( duck_type(:strftime), :debug, klass.inspect, nil, 'Some annoying message' )
340
+
341
+ Arrow::Logger[ klass ].info( "Some annoying message" )
342
+ end
343
+
344
+ end
345
+
346
+ # vim: set nosta noet ts=4 sw=4:
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ BEGIN {
4
+ require 'pathname'
5
+ basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
+
7
+ libdir = basedir + "lib"
8
+
9
+ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
10
+ }
11
+
12
+ require 'rubygems'
13
+ require 'spec'
14
+ require 'apache/fakerequest'
15
+ require 'arrow/mixins'
16
+
17
+ require 'spec/lib/helpers'
18
+ require 'spec/lib/constants'
19
+
20
+
21
+ include Arrow::TestConstants
22
+
23
+
24
+ #####################################################################
25
+ ### C O N T E X T S
26
+ #####################################################################
27
+
28
+ describe Arrow, "mixins" do
29
+ include Arrow::SpecHelpers
30
+
31
+
32
+ #################################################################
33
+ ### E X A M P L E S
34
+ #################################################################
35
+
36
+ describe Arrow::HashUtilities do
37
+ it "includes a function for stringifying Hash keys" do
38
+ testhash = {
39
+ :foo => 1,
40
+ :bar => {
41
+ :klang => 'klong',
42
+ :barang => { :kerklang => 'dumdumdum' },
43
+ }
44
+ }
45
+
46
+ result = Arrow::HashUtilities.stringify_keys( testhash )
47
+
48
+ result.should be_an_instance_of( Hash )
49
+ result.should_not be_equal( testhash )
50
+ result.should == {
51
+ 'foo' => 1,
52
+ 'bar' => {
53
+ 'klang' => 'klong',
54
+ 'barang' => { 'kerklang' => 'dumdumdum' },
55
+ }
56
+ }
57
+ end
58
+
59
+
60
+ it "includes a function for symbolifying Hash keys" do
61
+ testhash = {
62
+ 'foo' => 1,
63
+ 'bar' => {
64
+ 'klang' => 'klong',
65
+ 'barang' => { 'kerklang' => 'dumdumdum' },
66
+ }
67
+ }
68
+
69
+ result = Arrow::HashUtilities.symbolify_keys( testhash )
70
+
71
+ result.should be_an_instance_of( Hash )
72
+ result.should_not be_equal( testhash )
73
+ result.should == {
74
+ :foo => 1,
75
+ :bar => {
76
+ :klang => 'klong',
77
+ :barang => { :kerklang => 'dumdumdum' },
78
+ }
79
+ }
80
+ end
81
+ end
82
+
83
+ describe Arrow::ArrayUtilities do
84
+ it "includes a function for stringifying Array elements" do
85
+ testarray = [:a, :b, :c, [:d, :e, [:f, :g]]]
86
+
87
+ result = Arrow::ArrayUtilities.stringify_array( testarray )
88
+
89
+ result.should be_an_instance_of( Array )
90
+ result.should_not be_equal( testarray )
91
+ result.should == ['a', 'b', 'c', ['d', 'e', ['f', 'g']]]
92
+ end
93
+
94
+
95
+ it "includes a function for symbolifying Array elements" do
96
+ testarray = ['a', 'b', 'c', ['d', 'e', ['f', 'g']]]
97
+
98
+ result = Arrow::ArrayUtilities.symbolify_array( testarray )
99
+
100
+ result.should be_an_instance_of( Array )
101
+ result.should_not be_equal( testarray )
102
+ result.should == [:a, :b, :c, [:d, :e, [:f, :g]]]
103
+ end
104
+ end
105
+
106
+ describe Arrow::Loggable do
107
+
108
+ it "adds a log method to instances of including classes" do
109
+ testclass = Class.new do
110
+ include Arrow::Loggable
111
+ end
112
+
113
+ testclass.new.should respond_to( :log )
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+