Pratt 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. data/.exrc +61 -0
  2. data/.gitignore +4 -0
  3. data/History.txt +6 -0
  4. data/Manifest.txt +46 -0
  5. data/Pratt.gemspec +351 -0
  6. data/README.txt +66 -0
  7. data/Rakefile +85 -0
  8. data/TODO +54 -0
  9. data/VERSION +1 -0
  10. data/bin/pratt.rb +13 -0
  11. data/config.rb +34 -0
  12. data/lib/pratt.rb +527 -0
  13. data/lib/pratt/array.rb +11 -0
  14. data/lib/pratt/string.rb +18 -0
  15. data/models/app.rb +40 -0
  16. data/models/customer.rb +24 -0
  17. data/models/payment.rb +22 -0
  18. data/models/pratt.rb +19 -0
  19. data/models/project.rb +82 -0
  20. data/models/whence.rb +70 -0
  21. data/pkgs/tile-0.8.2.tar.gz +0 -0
  22. data/pkgs/tile-0.8.2/ANNOUNCE.txt +95 -0
  23. data/pkgs/tile-0.8.2/ChangeLog +4651 -0
  24. data/pkgs/tile-0.8.2/Makefile +250 -0
  25. data/pkgs/tile-0.8.2/Makefile.in +250 -0
  26. data/pkgs/tile-0.8.2/README.txt +86 -0
  27. data/pkgs/tile-0.8.2/aclocal.m4 +2 -0
  28. data/pkgs/tile-0.8.2/altTheme.o +0 -0
  29. data/pkgs/tile-0.8.2/blink.o +0 -0
  30. data/pkgs/tile-0.8.2/button.o +0 -0
  31. data/pkgs/tile-0.8.2/cache.o +0 -0
  32. data/pkgs/tile-0.8.2/clamTheme.o +0 -0
  33. data/pkgs/tile-0.8.2/classicTheme.o +0 -0
  34. data/pkgs/tile-0.8.2/config.log +1330 -0
  35. data/pkgs/tile-0.8.2/config.status +795 -0
  36. data/pkgs/tile-0.8.2/configure +15248 -0
  37. data/pkgs/tile-0.8.2/configure.in +89 -0
  38. data/pkgs/tile-0.8.2/demos/autocomplete.tcl +59 -0
  39. data/pkgs/tile-0.8.2/demos/demo.tcl +870 -0
  40. data/pkgs/tile-0.8.2/demos/dirbrowser.tcl +167 -0
  41. data/pkgs/tile-0.8.2/demos/dlgtest.tcl +97 -0
  42. data/pkgs/tile-0.8.2/demos/iconlib.tcl +110 -0
  43. data/pkgs/tile-0.8.2/demos/repeater.tcl +117 -0
  44. data/pkgs/tile-0.8.2/demos/toolbutton.tcl +101 -0
  45. data/pkgs/tile-0.8.2/doc/Geometry.3 +230 -0
  46. data/pkgs/tile-0.8.2/doc/INDEX.MAP +153 -0
  47. data/pkgs/tile-0.8.2/doc/Makefile +36 -0
  48. data/pkgs/tile-0.8.2/doc/TILE.XML +45 -0
  49. data/pkgs/tile-0.8.2/doc/Theme.3 +34 -0
  50. data/pkgs/tile-0.8.2/doc/button.n +75 -0
  51. data/pkgs/tile-0.8.2/doc/checkbutton.n +61 -0
  52. data/pkgs/tile-0.8.2/doc/combobox.n +98 -0
  53. data/pkgs/tile-0.8.2/doc/converting.txt +97 -0
  54. data/pkgs/tile-0.8.2/doc/dialog.n +122 -0
  55. data/pkgs/tile-0.8.2/doc/entry.n +438 -0
  56. data/pkgs/tile-0.8.2/doc/frame.n +43 -0
  57. data/pkgs/tile-0.8.2/doc/html/Geometry.html +304 -0
  58. data/pkgs/tile-0.8.2/doc/html/Theme.html +48 -0
  59. data/pkgs/tile-0.8.2/doc/html/button.html +120 -0
  60. data/pkgs/tile-0.8.2/doc/html/category-index.html +18 -0
  61. data/pkgs/tile-0.8.2/doc/html/checkbutton.html +94 -0
  62. data/pkgs/tile-0.8.2/doc/html/combobox.html +164 -0
  63. data/pkgs/tile-0.8.2/doc/html/converting.txt +97 -0
  64. data/pkgs/tile-0.8.2/doc/html/dialog.html +159 -0
  65. data/pkgs/tile-0.8.2/doc/html/entry.html +613 -0
  66. data/pkgs/tile-0.8.2/doc/html/frame.html +76 -0
  67. data/pkgs/tile-0.8.2/doc/html/image.html +100 -0
  68. data/pkgs/tile-0.8.2/doc/html/index.html +25 -0
  69. data/pkgs/tile-0.8.2/doc/html/keyword-index.html +228 -0
  70. data/pkgs/tile-0.8.2/doc/html/label.html +133 -0
  71. data/pkgs/tile-0.8.2/doc/html/labelframe.html +91 -0
  72. data/pkgs/tile-0.8.2/doc/html/manpage.css +212 -0
  73. data/pkgs/tile-0.8.2/doc/html/menubutton.html +63 -0
  74. data/pkgs/tile-0.8.2/doc/html/notebook.html +280 -0
  75. data/pkgs/tile-0.8.2/doc/html/paned.html +149 -0
  76. data/pkgs/tile-0.8.2/doc/html/progressbar.html +138 -0
  77. data/pkgs/tile-0.8.2/doc/html/radiobutton.html +89 -0
  78. data/pkgs/tile-0.8.2/doc/html/scrollbar.html +221 -0
  79. data/pkgs/tile-0.8.2/doc/html/separator.html +48 -0
  80. data/pkgs/tile-0.8.2/doc/html/sizegrip.html +62 -0
  81. data/pkgs/tile-0.8.2/doc/html/style.html +172 -0
  82. data/pkgs/tile-0.8.2/doc/html/tile-intro.html +164 -0
  83. data/pkgs/tile-0.8.2/doc/html/treeview.html +634 -0
  84. data/pkgs/tile-0.8.2/doc/html/widget.html +342 -0
  85. data/pkgs/tile-0.8.2/doc/image.n +81 -0
  86. data/pkgs/tile-0.8.2/doc/internals.txt +409 -0
  87. data/pkgs/tile-0.8.2/doc/label.n +75 -0
  88. data/pkgs/tile-0.8.2/doc/labelframe.n +64 -0
  89. data/pkgs/tile-0.8.2/doc/man.macros +239 -0
  90. data/pkgs/tile-0.8.2/doc/menubutton.n +41 -0
  91. data/pkgs/tile-0.8.2/doc/notebook.n +188 -0
  92. data/pkgs/tile-0.8.2/doc/paned.n +95 -0
  93. data/pkgs/tile-0.8.2/doc/progressbar.n +79 -0
  94. data/pkgs/tile-0.8.2/doc/radiobutton.n +57 -0
  95. data/pkgs/tile-0.8.2/doc/scrollbar.n +160 -0
  96. data/pkgs/tile-0.8.2/doc/separator.n +30 -0
  97. data/pkgs/tile-0.8.2/doc/sizegrip.n +53 -0
  98. data/pkgs/tile-0.8.2/doc/style.n +119 -0
  99. data/pkgs/tile-0.8.2/doc/tile-intro.n +165 -0
  100. data/pkgs/tile-0.8.2/doc/tmml.options +4 -0
  101. data/pkgs/tile-0.8.2/doc/treeview.n +415 -0
  102. data/pkgs/tile-0.8.2/doc/widget.n +227 -0
  103. data/pkgs/tile-0.8.2/doc/xml/Geometry.tmml +379 -0
  104. data/pkgs/tile-0.8.2/doc/xml/INDEX.MAP +153 -0
  105. data/pkgs/tile-0.8.2/doc/xml/Theme.tmml +63 -0
  106. data/pkgs/tile-0.8.2/doc/xml/button.tmml +134 -0
  107. data/pkgs/tile-0.8.2/doc/xml/checkbutton.tmml +119 -0
  108. data/pkgs/tile-0.8.2/doc/xml/combobox.tmml +184 -0
  109. data/pkgs/tile-0.8.2/doc/xml/dialog.tmml +195 -0
  110. data/pkgs/tile-0.8.2/doc/xml/entry.tmml +630 -0
  111. data/pkgs/tile-0.8.2/doc/xml/frame.tmml +98 -0
  112. data/pkgs/tile-0.8.2/doc/xml/image.tmml +101 -0
  113. data/pkgs/tile-0.8.2/doc/xml/label.tmml +154 -0
  114. data/pkgs/tile-0.8.2/doc/xml/labelframe.tmml +116 -0
  115. data/pkgs/tile-0.8.2/doc/xml/menubutton.tmml +80 -0
  116. data/pkgs/tile-0.8.2/doc/xml/notebook.tmml +306 -0
  117. data/pkgs/tile-0.8.2/doc/xml/paned.tmml +154 -0
  118. data/pkgs/tile-0.8.2/doc/xml/progressbar.tmml +151 -0
  119. data/pkgs/tile-0.8.2/doc/xml/radiobutton.tmml +109 -0
  120. data/pkgs/tile-0.8.2/doc/xml/scrollbar.tmml +233 -0
  121. data/pkgs/tile-0.8.2/doc/xml/separator.tmml +59 -0
  122. data/pkgs/tile-0.8.2/doc/xml/sizegrip.tmml +82 -0
  123. data/pkgs/tile-0.8.2/doc/xml/style.tmml +171 -0
  124. data/pkgs/tile-0.8.2/doc/xml/tile-intro.tmml +192 -0
  125. data/pkgs/tile-0.8.2/doc/xml/treeview.tmml +604 -0
  126. data/pkgs/tile-0.8.2/doc/xml/widget.tmml +372 -0
  127. data/pkgs/tile-0.8.2/entry.o +0 -0
  128. data/pkgs/tile-0.8.2/frame.o +0 -0
  129. data/pkgs/tile-0.8.2/generic/Makefile.in +221 -0
  130. data/pkgs/tile-0.8.2/generic/TODO +493 -0
  131. data/pkgs/tile-0.8.2/generic/altTheme.c +1172 -0
  132. data/pkgs/tile-0.8.2/generic/blink.c +168 -0
  133. data/pkgs/tile-0.8.2/generic/button.c +858 -0
  134. data/pkgs/tile-0.8.2/generic/cache.c +354 -0
  135. data/pkgs/tile-0.8.2/generic/clamTheme.c +974 -0
  136. data/pkgs/tile-0.8.2/generic/classicTheme.c +518 -0
  137. data/pkgs/tile-0.8.2/generic/configure +10334 -0
  138. data/pkgs/tile-0.8.2/generic/configure.in +100 -0
  139. data/pkgs/tile-0.8.2/generic/entry.c +1922 -0
  140. data/pkgs/tile-0.8.2/generic/frame.c +648 -0
  141. data/pkgs/tile-0.8.2/generic/gunk.h +44 -0
  142. data/pkgs/tile-0.8.2/generic/image.c +416 -0
  143. data/pkgs/tile-0.8.2/generic/label.c +663 -0
  144. data/pkgs/tile-0.8.2/generic/layout.c +1215 -0
  145. data/pkgs/tile-0.8.2/generic/manager.c +554 -0
  146. data/pkgs/tile-0.8.2/generic/manager.h +91 -0
  147. data/pkgs/tile-0.8.2/generic/notebook.c +1380 -0
  148. data/pkgs/tile-0.8.2/generic/paned.c +958 -0
  149. data/pkgs/tile-0.8.2/generic/pkgIndex.tcl.in +7 -0
  150. data/pkgs/tile-0.8.2/generic/progress.c +549 -0
  151. data/pkgs/tile-0.8.2/generic/scale.c +526 -0
  152. data/pkgs/tile-0.8.2/generic/scroll.c +253 -0
  153. data/pkgs/tile-0.8.2/generic/scrollbar.c +346 -0
  154. data/pkgs/tile-0.8.2/generic/separator.c +132 -0
  155. data/pkgs/tile-0.8.2/generic/square.c +306 -0
  156. data/pkgs/tile-0.8.2/generic/tagset.c +147 -0
  157. data/pkgs/tile-0.8.2/generic/tile.c +296 -0
  158. data/pkgs/tile-0.8.2/generic/tkElements.c +1280 -0
  159. data/pkgs/tile-0.8.2/generic/tkTheme.c +1708 -0
  160. data/pkgs/tile-0.8.2/generic/tkTheme.h +419 -0
  161. data/pkgs/tile-0.8.2/generic/tkThemeInt.h +45 -0
  162. data/pkgs/tile-0.8.2/generic/tkstate.c +268 -0
  163. data/pkgs/tile-0.8.2/generic/trace.c +145 -0
  164. data/pkgs/tile-0.8.2/generic/track.c +174 -0
  165. data/pkgs/tile-0.8.2/generic/treeview.c +3211 -0
  166. data/pkgs/tile-0.8.2/generic/ttk.decls +154 -0
  167. data/pkgs/tile-0.8.2/generic/ttkDecls.h +340 -0
  168. data/pkgs/tile-0.8.2/generic/ttkStubInit.c +61 -0
  169. data/pkgs/tile-0.8.2/generic/ttkStubLib.c +70 -0
  170. data/pkgs/tile-0.8.2/generic/widget.c +785 -0
  171. data/pkgs/tile-0.8.2/generic/widget.h +263 -0
  172. data/pkgs/tile-0.8.2/image.o +0 -0
  173. data/pkgs/tile-0.8.2/label.o +0 -0
  174. data/pkgs/tile-0.8.2/layout.o +0 -0
  175. data/pkgs/tile-0.8.2/library/altTheme.tcl +101 -0
  176. data/pkgs/tile-0.8.2/library/aquaTheme.tcl +62 -0
  177. data/pkgs/tile-0.8.2/library/button.tcl +85 -0
  178. data/pkgs/tile-0.8.2/library/clamTheme.tcl +139 -0
  179. data/pkgs/tile-0.8.2/library/classicTheme.tcl +108 -0
  180. data/pkgs/tile-0.8.2/library/combobox.tcl +439 -0
  181. data/pkgs/tile-0.8.2/library/cursors.tcl +36 -0
  182. data/pkgs/tile-0.8.2/library/defaults.tcl +118 -0
  183. data/pkgs/tile-0.8.2/library/dialog.tcl +274 -0
  184. data/pkgs/tile-0.8.2/library/entry.tcl +580 -0
  185. data/pkgs/tile-0.8.2/library/fonts.tcl +153 -0
  186. data/pkgs/tile-0.8.2/library/icons.tcl +105 -0
  187. data/pkgs/tile-0.8.2/library/keynav.tcl +192 -0
  188. data/pkgs/tile-0.8.2/library/menubutton.tcl +171 -0
  189. data/pkgs/tile-0.8.2/library/notebook.tcl +193 -0
  190. data/pkgs/tile-0.8.2/library/paned.tcl +87 -0
  191. data/pkgs/tile-0.8.2/library/progress.tcl +51 -0
  192. data/pkgs/tile-0.8.2/library/scale.tcl +54 -0
  193. data/pkgs/tile-0.8.2/library/scrollbar.tcl +125 -0
  194. data/pkgs/tile-0.8.2/library/sizegrip.tcl +77 -0
  195. data/pkgs/tile-0.8.2/library/tile.tcl +211 -0
  196. data/pkgs/tile-0.8.2/library/treeview.tcl +382 -0
  197. data/pkgs/tile-0.8.2/library/utils.tcl +254 -0
  198. data/pkgs/tile-0.8.2/library/winTheme.tcl +77 -0
  199. data/pkgs/tile-0.8.2/library/xpTheme.tcl +63 -0
  200. data/pkgs/tile-0.8.2/libtile0.8.2.so +0 -0
  201. data/pkgs/tile-0.8.2/libttkstub.a +0 -0
  202. data/pkgs/tile-0.8.2/license.terms +24 -0
  203. data/pkgs/tile-0.8.2/macosx/aquaTheme.c +1076 -0
  204. data/pkgs/tile-0.8.2/manager.o +0 -0
  205. data/pkgs/tile-0.8.2/notebook.o +0 -0
  206. data/pkgs/tile-0.8.2/paned.o +0 -0
  207. data/pkgs/tile-0.8.2/pkgIndex.tcl +3 -0
  208. data/pkgs/tile-0.8.2/progress.o +0 -0
  209. data/pkgs/tile-0.8.2/scale.o +0 -0
  210. data/pkgs/tile-0.8.2/scroll.o +0 -0
  211. data/pkgs/tile-0.8.2/scrollbar.o +0 -0
  212. data/pkgs/tile-0.8.2/separator.o +0 -0
  213. data/pkgs/tile-0.8.2/tagset.o +0 -0
  214. data/pkgs/tile-0.8.2/tclconfig/install-sh +119 -0
  215. data/pkgs/tile-0.8.2/tclconfig/tcl.m4 +4069 -0
  216. data/pkgs/tile-0.8.2/tclconfig/teax.m4 +109 -0
  217. data/pkgs/tile-0.8.2/tests/all.tcl +18 -0
  218. data/pkgs/tile-0.8.2/tests/bwidget.test +103 -0
  219. data/pkgs/tile-0.8.2/tests/cbtest.tcl +125 -0
  220. data/pkgs/tile-0.8.2/tests/combobox.test +51 -0
  221. data/pkgs/tile-0.8.2/tests/compound.tcl +92 -0
  222. data/pkgs/tile-0.8.2/tests/entry.test +285 -0
  223. data/pkgs/tile-0.8.2/tests/entrytest.tcl +78 -0
  224. data/pkgs/tile-0.8.2/tests/image.test +94 -0
  225. data/pkgs/tile-0.8.2/tests/labelframe.tcl +41 -0
  226. data/pkgs/tile-0.8.2/tests/labelframe.test +137 -0
  227. data/pkgs/tile-0.8.2/tests/layout.test +33 -0
  228. data/pkgs/tile-0.8.2/tests/misc.test +35 -0
  229. data/pkgs/tile-0.8.2/tests/nbtest.tcl +66 -0
  230. data/pkgs/tile-0.8.2/tests/notebook.test +500 -0
  231. data/pkgs/tile-0.8.2/tests/paned.test +298 -0
  232. data/pkgs/tile-0.8.2/tests/progress.test +92 -0
  233. data/pkgs/tile-0.8.2/tests/pwtest.tcl +90 -0
  234. data/pkgs/tile-0.8.2/tests/sbtest.tcl +79 -0
  235. data/pkgs/tile-0.8.2/tests/scrollbar.test +77 -0
  236. data/pkgs/tile-0.8.2/tests/sgtest.tcl +52 -0
  237. data/pkgs/tile-0.8.2/tests/testutils.tcl +20 -0
  238. data/pkgs/tile-0.8.2/tests/tile.test +674 -0
  239. data/pkgs/tile-0.8.2/tests/treetags.test +78 -0
  240. data/pkgs/tile-0.8.2/tests/treeview.test +563 -0
  241. data/pkgs/tile-0.8.2/tests/tvtest.tcl +332 -0
  242. data/pkgs/tile-0.8.2/tests/validate.test +278 -0
  243. data/pkgs/tile-0.8.2/tile.o +0 -0
  244. data/pkgs/tile-0.8.2/tkElements.o +0 -0
  245. data/pkgs/tile-0.8.2/tkTheme.o +0 -0
  246. data/pkgs/tile-0.8.2/tkstate.o +0 -0
  247. data/pkgs/tile-0.8.2/tools/genStubs.tcl +861 -0
  248. data/pkgs/tile-0.8.2/trace.o +0 -0
  249. data/pkgs/tile-0.8.2/track.o +0 -0
  250. data/pkgs/tile-0.8.2/treeview.o +0 -0
  251. data/pkgs/tile-0.8.2/ttkStubInit.o +0 -0
  252. data/pkgs/tile-0.8.2/ttkStubLib.o +0 -0
  253. data/pkgs/tile-0.8.2/widget.o +0 -0
  254. data/pkgs/tile-0.8.2/win/Tile.dsp +261 -0
  255. data/pkgs/tile-0.8.2/win/makefile.vc +527 -0
  256. data/pkgs/tile-0.8.2/win/monitor.c +164 -0
  257. data/pkgs/tile-0.8.2/win/nmakehlp.c +483 -0
  258. data/pkgs/tile-0.8.2/win/rules.vc +512 -0
  259. data/pkgs/tile-0.8.2/win/tile.rc +40 -0
  260. data/pkgs/tile-0.8.2/win/winTheme.c +734 -0
  261. data/pkgs/tile-0.8.2/win/xpTheme.c +1029 -0
  262. data/spec/app_spec.rb +48 -0
  263. data/spec/customer_spec.rb +31 -0
  264. data/spec/fixtures/graph.expectation +18 -0
  265. data/spec/payment_spec.rb +19 -0
  266. data/spec/pratt_spec.rb +148 -0
  267. data/spec/project_spec.rb +163 -0
  268. data/spec/rcov.opts +0 -0
  269. data/spec/spec.opts +1 -0
  270. data/spec/spec_helper.rb +21 -0
  271. data/spec/whence_spec.rb +54 -0
  272. data/tasks/pratt.rb +84 -0
  273. data/templates/model.eruby +12 -0
  274. data/templates/spec.eruby +8 -0
  275. data/views/env.rb +22 -0
  276. data/views/graph.eruby +20 -0
  277. data/views/invoice.eruby +148 -0
  278. data/views/main.rb +92 -0
  279. data/views/pid.eruby +3 -0
  280. data/views/pop.rb +94 -0
  281. data/views/pop2.rb +75 -0
  282. data/views/raw.eruby +11 -0
  283. metadata +390 -0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe App do
4
+ context "instances" do
5
+ it "should only have one" do
6
+ App.last.should_not be_nil
7
+ end
8
+
9
+ it "should have log" do
10
+ @app = App.last
11
+ @app.expects(:log).with('pop').returns(@app)
12
+ @app.log 'pop'
13
+ end
14
+
15
+ it "should say it has something logged" do
16
+ @app = App.new
17
+ @app.gui?('main').should be_false
18
+ @app.gui?('pop').should be_false
19
+
20
+ @app.gui = 'main'
21
+ @app.gui?('main').should be_true
22
+
23
+ @app.gui = 'pop'
24
+ @app.gui?('main').should be_false
25
+
26
+ @app.gui = 'pop'
27
+ @app.gui?('pop').should be_true
28
+
29
+ @app.gui = 'pop'
30
+ @app.gui?('bob').should be_false
31
+ end
32
+
33
+ it "should remove the gui when expected" do
34
+ @app = App.create :gui => 'pop'
35
+
36
+ @app.gui?('pop').should be_true
37
+ @app.unlock
38
+ @app.gui?('pop').should be_false
39
+
40
+ @app.gui = 'main'
41
+ @app.save
42
+ @app.gui?('pop').should be_false
43
+ @app.gui?('main').should be_true
44
+
45
+ @app.destroy
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'pratt'
3
+
4
+ describe Customer do
5
+ it_should_behave_like "being a billable item"
6
+
7
+ describe "instance" do
8
+ before :each do
9
+ @customer = Customer.create :name => "frogstarr78", :address => '312 NW 7th', :zip => '97862'
10
+ end
11
+
12
+ after :each do
13
+ Customer.find_by_name('frogstarr78').destroy
14
+ end
15
+
16
+ it "responds to :projects" do
17
+ Customer.new.should respond_to(:projects)
18
+ end
19
+
20
+ it "responds to :payment" do
21
+ Customer.new.should respond_to(:payment)
22
+ end
23
+
24
+ it "calculates amount correctly" do
25
+ payment = mock('payment')
26
+ payment.expects(:rate).once.returns(31500)
27
+ @customer.expects(:payment).once.returns(payment)
28
+ @customer.amount.should == 315.0
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ Project detail
2
+ by week from
3
+ Mon 00:00:00 Sep 28 2009 to Sun 23:59:59 Oct 04 2009
4
+ dys hrs min
5
+ ------------------------------------------------------------
6
+
7
+ Lunch/Break| 00 day 01 hour 21 min
8
+ Task1| 00 day 01 hour 04 min
9
+ Task2| 00 day 00 hour 58 min
10
+ Another Task| 00 day 00 hour 05 min
11
+ Task3| 01 day 17 hour 32 min
12
+
13
+ ------------------------------------------------------------
14
+
15
+ Total 43.69 hrs
16
+ **** ******** 0.00%
17
+ Lunch/Break 3.11%
18
+ Other 100.00%
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'pratt'
3
+
4
+ describe Payment do
5
+ describe "instances" do
6
+ before :each do
7
+ @payment = Payment.new
8
+ end
9
+
10
+ it "responds to :pretty_print" do
11
+ @payment.should respond_to(:pretty_print)
12
+ end
13
+
14
+ it "pretty_print is the expected format " do
15
+ @payment.rate = '100'
16
+ @payment.pretty_print.should == '$1.00'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,148 @@
1
+ require 'spec_helper'
2
+ require 'pratt'
3
+
4
+ describe Pratt do
5
+ before :each do
6
+ @pratt = Pratt.new
7
+ end
8
+
9
+ # it "should act like an array" do
10
+ # @pratt.should respond_to(:<<)
11
+ # lambda {
12
+ # @pratt << :this
13
+ # }.should change(@pratt.todo, :size).by(1)
14
+ # @pratt.todo.should == [:this]
15
+ # end
16
+ #
17
+ # it "correctly report i_should?" do
18
+ # @pratt.send(:i_should?, :this).should be_false
19
+ # @pratt << :this
20
+ # @pratt.send(:i_should?, :this).should be_true
21
+ # end
22
+ #
23
+ # it "should start a new project when calling begin" do
24
+ # @pratt.project = mock('Refactor')
25
+ # @pratt.when_to = Time.now
26
+ # @pratt.project.expects(:start!).with(@pratt.when_to)
27
+ #
28
+ # @pratt.begin
29
+ # end
30
+ #
31
+ # it "should allow project to be set by object" do
32
+ # primary = Project.new :name => 'project', :weight => 1
33
+ # Project.expects(:find_or_create_by_name).never
34
+ # @pratt.project = primary
35
+ # @pratt.project.should == primary
36
+ # end
37
+ #
38
+ # it "should allow project to be set by a string" do
39
+ # Project.expects(:find_or_create_by_name).with( { :name => 'Refactor' } )
40
+ # @pratt.project = 'Refactor'
41
+ # end
42
+ #
43
+ # describe "color" do
44
+ #
45
+ # it "should color when expected" do
46
+ # @pratt.color = true
47
+ # @pratt.send( :red, 'this' ).should == 'this'.red
48
+ # end
49
+ #
50
+ # it "should not color when not expected" do
51
+ # @pratt.color = false
52
+ # @pratt.send( :red, 'this' ).should == 'this'
53
+ # end
54
+ # end
55
+ #
56
+ # describe "\b#root" do
57
+ # before :each do
58
+ # Dir.stubs(:pwd).returns("/home/scott/git/pratt")
59
+ # @expected_root = "/home/scott/git/pratt"
60
+ # end
61
+ #
62
+ # it "is correct without arguments" do
63
+ # Pratt.root.should == [Pathname.new(@expected_root)]
64
+ # end
65
+ #
66
+ # it "is correct with a block but no argument" do
67
+ # received = []
68
+ # Pratt.root {|model| received << model }
69
+ # received.should == [Pathname.new(@expected_root)]
70
+ # end
71
+ #
72
+ # it "is correct with an argument but no block" do
73
+ # Pratt.root('models').should == [Pathname.new(File.join(@expected_root, "models"))]
74
+ # end
75
+ #
76
+ # it "is correct with an argument and block" do
77
+ # received = []
78
+ # Pratt.root('models', '*.rb') {|model| received << model }
79
+ # received.to_set.should == %w(app.rb customer.rb log.rb project.rb payment.rb pratt.rb whence.rb).collect {|model| Pathname.new File.join(@expected_root, "models", model) }.to_set
80
+ # end
81
+ # end
82
+ #
83
+ # describe "graph" do
84
+ # before :each do
85
+ # @when_to = Chronic.parse('last week').beginning_of_week
86
+ # @pratt.scale = 'week'
87
+ # @pratt.when_to = @when_to
88
+ # end
89
+ #
90
+ # after :each do
91
+ # Whence.delete_all
92
+ # end
93
+ #
94
+ #
95
+ # def task name, time_spent
96
+ # task1 = Project.find_or_create_by_name :name => name
97
+ # task1.start! @when_to
98
+ # task1.stop! @when_to+time_spent
99
+ # end
100
+ #
101
+ # def populate_with_data
102
+ # Project.find_or_create_by_name :name => '**** ********', :weight => 1
103
+ # task 'Lunch/Break', 1.hour+21.minutes
104
+ # task 'Task1', 1.hour+4.minutes
105
+ # task 'Task2', 58.minutes
106
+ # task 'Another Task', 5.minutes
107
+ # task 'Task3', 1.day+17.hours+32.minutes
108
+ # end
109
+ #
110
+ # def get_expected_display
111
+ # Pratt.root('spec', 'fixtures', 'graph.expectation') {|file| File.open(file).read }
112
+ # end
113
+ #
114
+ # it "report no data" do
115
+ # Project.expects(:all).returns([])
116
+ # @pratt.expects(:process_template!).never
117
+ # @pratt.graph.should == "No data to report"
118
+ # end
119
+ #
120
+ # it "should look right with data" do
121
+ # populate_with_data
122
+ # @pratt.expects(:process_template!)
123
+ #
124
+ # @pratt.graph.should == get_expected_display
125
+ # end
126
+ # end
127
+
128
+ describe "parse" do
129
+ it "handles cli arg -n setting appropriate environment config"
130
+ # do
131
+ ## Pratt.expects(:connect).with('staging')
132
+ ## lambda {
133
+ # Pratt.parse %w(--env staging)
134
+ ## }.should change(ENV['PRATT_ENV']).from('test').to('staging')
135
+ # ENV['PRATT_ENV'].should == 'staging'
136
+ # end
137
+
138
+ # it "inits an irb console when given console argument" do
139
+ # Pratt.any_instance.stubs(:i_should?).returns false
140
+ # # ^ to bypass actually calling exec
141
+ # # :i_should? and Pratt#run should be
142
+ # # tested independently and we don't
143
+ # # need to test exec
144
+ # Pratt.any_instance.expects(:<<).with(:console)
145
+ # Pratt.parse %w(console)
146
+ # end
147
+ end
148
+ end
@@ -0,0 +1,163 @@
1
+ require 'spec_helper'
2
+
3
+ # enable laziness
4
+ class Mocha::Mock
5
+ def name
6
+ @name.instance_variable_get("@name")
7
+ end
8
+ end
9
+
10
+ describe Project do
11
+ it_should_behave_like "being a billable item"
12
+
13
+ context "scopes" do
14
+ it "named primary" do
15
+ Project.expects(:first).with(:conditions => { :weight => 1 }).returns(mock('Refactor'))
16
+ Project.primary.name.should == 'Refactor'
17
+ end
18
+
19
+ it "named off" do
20
+ Project.expects(:first).with(:conditions => { :name => 'Lunch/Break' }).returns(mock('Lunch/Break'))
21
+ Project.off.name.should == 'Lunch/Break'
22
+ end
23
+
24
+ it "named rest" do
25
+ prim = mock('Refactor')
26
+ off = mock('Lunch/Break')
27
+ other = mock('Other')
28
+
29
+ Project.expects(:primary).returns prim
30
+ Project.expects(:off).returns off
31
+ Project.expects(:all).returns([prim, off, other])
32
+ Project.rest.should == [other]
33
+ end
34
+
35
+ it "named named" do
36
+ Project.expects(:first).with(:conditions => { :name => 'Refactor' }).returns(mock('Refactor'))
37
+ Project.named('Refactor').name.should == 'Refactor'
38
+
39
+ Project.expects(:named).with(nil).returns nil
40
+ Project.named(nil).should be_nil
41
+ end
42
+ end
43
+
44
+ context "instances" do
45
+ before :each do
46
+ @project = Project.primary
47
+ @log_count = @project.whences.size
48
+ end
49
+
50
+ after :each do
51
+ @project.whences.destroy_all
52
+ end
53
+
54
+ it "should correctly log entries using start! and stop!" do
55
+ lambda {
56
+ @project.start!
57
+ }.should change(@project.whences, :count).by(1)
58
+ @project.whences.last.end_at.should be_nil
59
+
60
+ sleep 1
61
+ lambda {
62
+ @project.stop!
63
+ }.should_not change(@project.whences, :count)
64
+ @project.should be_valid
65
+ @project.whences.reload
66
+ @project.whences.last.end_at.should > @project.whences.last.start_at
67
+ end
68
+
69
+ it "should log correct time if given (not the default)" do
70
+ lambda {
71
+ @project.start!
72
+ }.should change(@project.whences, :count).by(1)
73
+ @project.whences.last.end_at.should be_nil
74
+ end
75
+
76
+ it "should do nothing if attempting to stop a project that hasn't been started" do
77
+ lambda {
78
+ @project.stop!
79
+ }.should_not change(@project.whences, :count)
80
+ end
81
+
82
+ it "should stop! then start! when calling restart!" do
83
+ @project.start!
84
+ first_started_id = @project.whences.last.id
85
+
86
+ lambda {
87
+ @project.restart!
88
+ }.should change(@project.whences, :count).by(1)
89
+ @project.whences.last.end_at.should be_nil
90
+ @project.whences.last.id.should_not == first_started_id
91
+ end
92
+
93
+ it "has a customer association" do
94
+ @project.should respond_to(:customer)
95
+ end
96
+
97
+ context "amount calculation" do
98
+ before :each do
99
+ Payment.create :rate => '315', :billable => @project
100
+
101
+ @now = Time.parse("2009-10-04 17:53:58")
102
+ Time.stubs(:now).returns(@now.beginning_of_week)
103
+
104
+ whence = Time.now-1.day
105
+ @project.start! whence
106
+ @project.stop! whence+3.hours
107
+
108
+ whence = Time.now
109
+ @project.start! whence
110
+ @project.stop! whence+3.hours
111
+
112
+ @project.reload
113
+ end
114
+
115
+ it "is correct with no arguments" do
116
+ @project.amount.should == 6*3.15
117
+ end
118
+
119
+ it "is correct with a scale" do
120
+ @project.amount(:month).should == 6*3.15
121
+ end
122
+
123
+ it "is correct with a scale and time" do
124
+ @project.amount(:week, @now).should == 3*3.15
125
+ end
126
+ end
127
+ end
128
+
129
+ context "time_spent" do
130
+ before :each do
131
+ @project = Project.new
132
+ end
133
+
134
+ it "correctly calculates with no data" do
135
+ Whence.expects(:find).with(:all, :conditions => ["end_at IS NOT NULL"]).returns []
136
+ @project.time_spent.should == 0.0
137
+ end
138
+
139
+ it "correctly calculates with time argument" do
140
+ now = Time.now.beginning_of_day
141
+ Whence.expects(:find).returns [mock('whence1', :start_at => now, :end_at => now+=1.hour), mock('whence2', :start_at => now+=2.hours, :end_at => now+=2.hour+30.minutes)]
142
+ @project.time_spent.should == 3.5
143
+ end
144
+
145
+ it "correctly calculates with string time argument" do
146
+ whence = mock('whence', :start_at => Chronic.parse('last monday 12:00 pm'), :end_at => Chronic.parse('last monday 12:00:05 pm'))
147
+ Whence.expects(:find).returns [whence]
148
+ @project.time_spent.should == 5.0/3600
149
+ end
150
+
151
+ it "correctly calculates with a scale" do
152
+ whence = mock('whence', :start_at => Time.parse('2009-10-04 23:53:32'), :end_at => Time.parse('2009-10-05 00:10:32'))
153
+ Whence.expects(:find).returns [whence]
154
+ @project.time_spent('month').should == 17.0/60
155
+ end
156
+
157
+ it "correctly calculates with a scale and specific time" do
158
+ whence = mock('whence', :start_at => Time.parse('2009-10-05 23:54:32'), :end_at => Time.parse('2009-10-06 00:12:32'))
159
+ Whence.expects(:find).returns [whence]
160
+ @project.time_spent('day', Chronic.parse('yesterday')).should == 18.0/60
161
+ end
162
+ end
163
+ end
File without changes
@@ -0,0 +1 @@
1
+ color=true color: true color colour c --colour --color -c
@@ -0,0 +1,21 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ require 'spec'
4
+ require 'config'
5
+ require 'ruby-debug'
6
+
7
+ Spec::Runner.configure do |config|
8
+ # config.mock_with :rspec
9
+ config.mock_with :mocha
10
+
11
+ Pratt.connect! 'test'
12
+ end
13
+
14
+ shared_examples_for "Time spent on a project" do
15
+ end
16
+
17
+ shared_examples_for "being a billable item" do
18
+ it "responds to amount" do
19
+ subject.class.new.should respond_to(:amount)
20
+ end
21
+ end