quarry 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. data/CHANGES +22 -1
  2. data/MANIFEST +30 -339
  3. data/RELEASE +2 -4
  4. data/VERSION +1 -1
  5. data/bin/quarry +14 -10
  6. data/bin/quarry-doc +2 -2
  7. data/lib/quarry/assertion.rb +27 -0
  8. data/lib/quarry/{spec/config.rb → config.rb} +0 -0
  9. data/lib/quarry/document/template.rhtml +239 -0
  10. data/lib/quarry/document.rb +126 -0
  11. data/lib/quarry/expectation.rb +60 -0
  12. data/lib/quarry/extract.rb +2 -0
  13. data/lib/quarry/grammar/assert.rb +48 -0
  14. data/lib/quarry/grammar/expect.rb +114 -0
  15. data/lib/quarry/grammar/legacy/assert.rb +280 -0
  16. data/lib/quarry/grammar/should.rb +50 -0
  17. data/lib/quarry/grammar.rb +4 -0
  18. data/lib/quarry/{spec → markup}/step.rb +4 -3
  19. data/lib/quarry/markup.rb +70 -0
  20. data/lib/quarry/{stub/mock.rb → mock.rb} +1 -1
  21. data/lib/quarry/{loadmonitor.rb → monitor.rb} +0 -0
  22. data/lib/quarry/{stub/probe.rb → probe.rb} +8 -35
  23. data/lib/quarry/reporter/dotprogress.rb +62 -0
  24. data/lib/quarry/reporter/summary.rb +70 -0
  25. data/lib/quarry/reporter/verbatim.rb +82 -0
  26. data/lib/quarry/reporter.rb +70 -0
  27. data/lib/quarry/{spec → runner}/context.rb +7 -2
  28. data/lib/quarry/runner.rb +123 -0
  29. data/lib/quarry/{stub/stub.rb → stub.rb} +1 -1
  30. data/lib/quarry.rb +10 -0
  31. data/spec/basic.rd +0 -2
  32. data/spec/complex.rd +0 -2
  33. data/spec/mock.rd +20 -26
  34. data/spec/stub.rd +8 -12
  35. metadata +48 -361
  36. data/bin/ruby-break +0 -10
  37. data/doc/assets/images/clipboard.jpg +0 -0
  38. data/doc/assets/images/clipboard2.png +0 -0
  39. data/doc/assets/images/darksilver.png +0 -0
  40. data/doc/assets/images/icon/book.jpg +0 -0
  41. data/doc/assets/images/icon/download.gif +0 -0
  42. data/doc/assets/images/icon/letter_r.png +0 -0
  43. data/doc/assets/images/icon/license.png +0 -0
  44. data/doc/assets/images/icon/software.png +0 -0
  45. data/doc/assets/images/icon/source.png +0 -0
  46. data/doc/assets/images/miner.jpg +0 -0
  47. data/doc/assets/images/rbrylmtrx.png +0 -0
  48. data/doc/assets/images/ruby.gif +0 -0
  49. data/doc/assets/images/runneth.png +0 -0
  50. data/doc/assets/images/silver.gif +0 -0
  51. data/doc/assets/images/test.jpg +0 -0
  52. data/doc/assets/jquery/jquery.js +0 -1
  53. data/doc/assets/jquery/jquery.tabs.js +0 -1
  54. data/doc/assets/rdoc_ad.html +0 -12
  55. data/doc/assets/styles/index.css +0 -138
  56. data/doc/guide/stubs.md +0 -125
  57. data/doc/index.html +0 -285
  58. data/doc/log/bstats/stats.html +0 -39
  59. data/doc/log/notes.xml +0 -32
  60. data/doc/log/stats.html +0 -25
  61. data/doc/log/stats.log +0 -14
  62. data/doc/log/syntax.log +0 -0
  63. data/doc/rdoc/classes/Assertion/False.html +0 -177
  64. data/doc/rdoc/classes/Assertion/True.html +0 -152
  65. data/doc/rdoc/classes/Assertion.html +0 -171
  66. data/doc/rdoc/classes/Kernel.html +0 -105
  67. data/doc/rdoc/classes/Method.html +0 -168
  68. data/doc/rdoc/classes/Object.html +0 -507
  69. data/doc/rdoc/classes/Quarry/Break.html +0 -231
  70. data/doc/rdoc/classes/Quarry/Command.html +0 -443
  71. data/doc/rdoc/classes/Quarry/Extract.html +0 -215
  72. data/doc/rdoc/classes/Quarry/MethodProbe.html +0 -325
  73. data/doc/rdoc/classes/Quarry/Mock/Delegator.html +0 -179
  74. data/doc/rdoc/classes/Quarry/Mock/Setter.html +0 -175
  75. data/doc/rdoc/classes/Quarry/Mock.html +0 -233
  76. data/doc/rdoc/classes/Quarry/Spec/Comment.html +0 -237
  77. data/doc/rdoc/classes/Quarry/Spec/Config.html +0 -257
  78. data/doc/rdoc/classes/Quarry/Spec/Context.html +0 -154
  79. data/doc/rdoc/classes/Quarry/Spec/Document.html +0 -382
  80. data/doc/rdoc/classes/Quarry/Spec/Header.html +0 -195
  81. data/doc/rdoc/classes/Quarry/Spec/Macro.html +0 -166
  82. data/doc/rdoc/classes/Quarry/Spec/Markup.html +0 -279
  83. data/doc/rdoc/classes/Quarry/Spec/Reporter/DotProgress.html +0 -234
  84. data/doc/rdoc/classes/Quarry/Spec/Reporter/Summary.html +0 -294
  85. data/doc/rdoc/classes/Quarry/Spec/Reporter/Verbatim.html +0 -311
  86. data/doc/rdoc/classes/Quarry/Spec/Runner.html +0 -352
  87. data/doc/rdoc/classes/Quarry/Spec/Step.html +0 -190
  88. data/doc/rdoc/classes/Quarry/Spec/Template.html +0 -205
  89. data/doc/rdoc/classes/Quarry/Stub/Delegator.html +0 -179
  90. data/doc/rdoc/classes/Quarry/Stub/Setter.html +0 -175
  91. data/doc/rdoc/classes/Quarry/Stub.html +0 -224
  92. data/doc/rdoc/classes/Quarry.html +0 -176
  93. data/doc/rdoc/created.rid +0 -1
  94. data/doc/rdoc/files/CHANGES.html +0 -150
  95. data/doc/rdoc/files/COPYING.html +0 -468
  96. data/doc/rdoc/files/README.html +0 -195
  97. data/doc/rdoc/files/RELEASE.html +0 -122
  98. data/doc/rdoc/files/VERSION.html +0 -107
  99. data/doc/rdoc/files/bin/quarry-doc.html +0 -109
  100. data/doc/rdoc/files/bin/quarry.html +0 -109
  101. data/doc/rdoc/files/bin/ruby-break.html +0 -108
  102. data/doc/rdoc/files/bin/ruby-xacto.html +0 -101
  103. data/doc/rdoc/files/lib/quarry/assert_rb.html +0 -155
  104. data/doc/rdoc/files/lib/quarry/break_rb.html +0 -101
  105. data/doc/rdoc/files/lib/quarry/extract_rb.html +0 -108
  106. data/doc/rdoc/files/lib/quarry/loadmonitor_rb.html +0 -101
  107. data/doc/rdoc/files/lib/quarry/spec/config_rb.html +0 -101
  108. data/doc/rdoc/files/lib/quarry/spec/context_rb.html +0 -101
  109. data/doc/rdoc/files/lib/quarry/spec/document_rb.html +0 -111
  110. data/doc/rdoc/files/lib/quarry/spec/markup_rb.html +0 -108
  111. data/doc/rdoc/files/lib/quarry/spec/reporter/dotprogress_rb.html +0 -108
  112. data/doc/rdoc/files/lib/quarry/spec/reporter/summary_rb.html +0 -108
  113. data/doc/rdoc/files/lib/quarry/spec/reporter/verbatim_rb.html +0 -108
  114. data/doc/rdoc/files/lib/quarry/spec/reporter_rb.html +0 -109
  115. data/doc/rdoc/files/lib/quarry/spec/runner_rb.html +0 -109
  116. data/doc/rdoc/files/lib/quarry/spec/step_rb.html +0 -101
  117. data/doc/rdoc/files/lib/quarry/spec/template_rhtml.html +0 -228
  118. data/doc/rdoc/files/lib/quarry/spec_rb.html +0 -113
  119. data/doc/rdoc/files/lib/quarry/stub/mock_rb.html +0 -101
  120. data/doc/rdoc/files/lib/quarry/stub/probe_rb.html +0 -122
  121. data/doc/rdoc/files/lib/quarry/stub/spec_txt.html +0 -118
  122. data/doc/rdoc/files/lib/quarry/stub/stub_rb.html +0 -101
  123. data/doc/rdoc/fr_class_index.html +0 -56
  124. data/doc/rdoc/fr_file_index.html +0 -55
  125. data/doc/rdoc/fr_method_index.html +0 -117
  126. data/doc/rdoc/index.html +0 -24
  127. data/doc/rdoc/rdoc-style.css +0 -208
  128. data/doc/ri/Assertion/False/assert-i.yaml +0 -10
  129. data/doc/ri/Assertion/False/cdesc-False.yaml +0 -21
  130. data/doc/ri/Assertion/False/message-i.yaml +0 -10
  131. data/doc/ri/Assertion/True/assert-i.yaml +0 -11
  132. data/doc/ri/Assertion/True/cdesc-True.yaml +0 -26
  133. data/doc/ri/Assertion/True/message-c.yaml +0 -11
  134. data/doc/ri/Assertion/True/message-i.yaml +0 -11
  135. data/doc/ri/Assertion/True/method_missing-i.yaml +0 -12
  136. data/doc/ri/Assertion/True/new-c.yaml +0 -11
  137. data/doc/ri/Assertion/cdesc-Assertion.yaml +0 -40
  138. data/doc/ri/Kernel/cdesc-Kernel.yaml +0 -15
  139. data/doc/ri/Method/cdesc-Method.yaml +0 -18
  140. data/doc/ri/Method/migration-i.yaml +0 -12
  141. data/doc/ri/Method/signature-i.yaml +0 -12
  142. data/doc/ri/Object/assert%21-i.yaml +0 -17
  143. data/doc/ri/Object/assert-i.yaml +0 -15
  144. data/doc/ri/Object/assert_raises%21-i.yaml +0 -12
  145. data/doc/ri/Object/assert_raises-i.yaml +0 -15
  146. data/doc/ri/Object/cdesc-Object.yaml +0 -42
  147. data/doc/ri/Object/mock-i.yaml +0 -12
  148. data/doc/ri/Object/refute-i.yaml +0 -13
  149. data/doc/ri/Object/refute_raises-i.yaml +0 -17
  150. data/doc/ri/Object/remove-i.yaml +0 -12
  151. data/doc/ri/Object/should-i.yaml +0 -12
  152. data/doc/ri/Object/should_not-i.yaml +0 -12
  153. data/doc/ri/Object/should_not_raise-i.yaml +0 -12
  154. data/doc/ri/Object/should_raise-i.yaml +0 -12
  155. data/doc/ri/Object/stub-i.yaml +0 -12
  156. data/doc/ri/Quarry/Break/cdesc-Break.yaml +0 -23
  157. data/doc/ri/Quarry/Break/edit-i.yaml +0 -11
  158. data/doc/ri/Quarry/Break/new-c.yaml +0 -11
  159. data/doc/ri/Quarry/Extract/cdesc-Extract.yaml +0 -26
  160. data/doc/ri/Quarry/Extract/create_test-i.yaml +0 -12
  161. data/doc/ri/Quarry/Extract/extract_test_from_file-i.yaml +0 -12
  162. data/doc/ri/Quarry/Extract/test_extract-i.yaml +0 -18
  163. data/doc/ri/Quarry/MethodProbe/cdesc-MethodProbe.yaml +0 -46
  164. data/doc/ri/Quarry/MethodProbe/duckcall-c.yaml +0 -10
  165. data/doc/ri/Quarry/MethodProbe/initialize_copy-i.yaml +0 -10
  166. data/doc/ri/Quarry/MethodProbe/method_missing-i.yaml +0 -10
  167. data/doc/ri/Quarry/MethodProbe/new-c.yaml +0 -10
  168. data/doc/ri/Quarry/Mock/Delegator/cdesc-Delegator.yaml +0 -20
  169. data/doc/ri/Quarry/Mock/Delegator/method_missing-i.yaml +0 -10
  170. data/doc/ri/Quarry/Mock/Delegator/new-c.yaml +0 -10
  171. data/doc/ri/Quarry/Mock/Setter/%3d%3d-i.yaml +0 -10
  172. data/doc/ri/Quarry/Mock/Setter/cdesc-Setter.yaml +0 -18
  173. data/doc/ri/Quarry/Mock/Setter/new-c.yaml +0 -10
  174. data/doc/ri/Quarry/Mock/__table__-i.yaml +0 -11
  175. data/doc/ri/Quarry/Mock/cdesc-Mock.yaml +0 -25
  176. data/doc/ri/Quarry/Mock/method_missing-i.yaml +0 -12
  177. data/doc/ri/Quarry/Mock/new-c.yaml +0 -10
  178. data/doc/ri/Quarry/Spec/Comment/cdesc-Comment.yaml +0 -33
  179. data/doc/ri/Quarry/Spec/Comment/macro%3f-i.yaml +0 -12
  180. data/doc/ri/Quarry/Spec/Comment/new-c.yaml +0 -10
  181. data/doc/ri/Quarry/Spec/Comment/type-i.yaml +0 -12
  182. data/doc/ri/Quarry/Spec/Config/after-i.yaml +0 -12
  183. data/doc/ri/Quarry/Spec/Config/after_spec-i.yaml +0 -12
  184. data/doc/ri/Quarry/Spec/Config/before-i.yaml +0 -12
  185. data/doc/ri/Quarry/Spec/Config/before_spec-i.yaml +0 -12
  186. data/doc/ri/Quarry/Spec/Config/cdesc-Config.yaml +0 -26
  187. data/doc/ri/Quarry/Spec/Config/new-c.yaml +0 -10
  188. data/doc/ri/Quarry/Spec/Context/cdesc-Context.yaml +0 -21
  189. data/doc/ri/Quarry/Spec/Context/new-c.yaml +0 -10
  190. data/doc/ri/Quarry/Spec/Document/cdesc-Document.yaml +0 -76
  191. data/doc/ri/Quarry/Spec/Document/generate-i.yaml +0 -12
  192. data/doc/ri/Quarry/Spec/Document/new-c.yaml +0 -12
  193. data/doc/ri/Quarry/Spec/Document/quiet%3f-i.yaml +0 -12
  194. data/doc/ri/Quarry/Spec/Document/require_rdoc-i.yaml +0 -11
  195. data/doc/ri/Quarry/Spec/Document/save-i.yaml +0 -12
  196. data/doc/ri/Quarry/Spec/Document/template-i.yaml +0 -12
  197. data/doc/ri/Quarry/Spec/Header/cdesc-Header.yaml +0 -30
  198. data/doc/ri/Quarry/Spec/Header/new-c.yaml +0 -10
  199. data/doc/ri/Quarry/Spec/Macro/cdesc-Macro.yaml +0 -22
  200. data/doc/ri/Quarry/Spec/Macro/new-c.yaml +0 -10
  201. data/doc/ri/Quarry/Spec/Markup/cdesc-Markup.yaml +0 -31
  202. data/doc/ri/Quarry/Spec/Markup/description-i.yaml +0 -11
  203. data/doc/ri/Quarry/Spec/Markup/new-c.yaml +0 -11
  204. data/doc/ri/Quarry/Spec/Markup/parse-i.yaml +0 -11
  205. data/doc/ri/Quarry/Spec/Markup/parse_section-i.yaml +0 -11
  206. data/doc/ri/Quarry/Spec/Reporter/DotProgress/cdesc-DotProgress.yaml +0 -21
  207. data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_intro-i.yaml +0 -10
  208. data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_step-i.yaml +0 -10
  209. data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_summary-i.yaml +0 -16
  210. data/doc/ri/Quarry/Spec/Reporter/Summary/cdesc-Summary.yaml +0 -31
  211. data/doc/ri/Quarry/Spec/Reporter/Summary/report_comment-i.yaml +0 -10
  212. data/doc/ri/Quarry/Spec/Reporter/Summary/report_error-i.yaml +0 -10
  213. data/doc/ri/Quarry/Spec/Reporter/Summary/report_fail-i.yaml +0 -10
  214. data/doc/ri/Quarry/Spec/Reporter/Summary/report_header-i.yaml +0 -10
  215. data/doc/ri/Quarry/Spec/Reporter/Summary/report_macro-i.yaml +0 -10
  216. data/doc/ri/Quarry/Spec/Reporter/Summary/report_pass-i.yaml +0 -10
  217. data/doc/ri/Quarry/Spec/Reporter/Verbatim/cdesc-Verbatim.yaml +0 -29
  218. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_comment-i.yaml +0 -10
  219. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_error-i.yaml +0 -10
  220. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_fail-i.yaml +0 -10
  221. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_header-i.yaml +0 -16
  222. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_macro-i.yaml +0 -10
  223. data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_pass-i.yaml +0 -10
  224. data/doc/ri/Quarry/Spec/Reporter/cdesc-Reporter.yaml +0 -20
  225. data/doc/ri/Quarry/Spec/Runner/cdesc-Runner.yaml +0 -47
  226. data/doc/ri/Quarry/Spec/Runner/check-i.yaml +0 -12
  227. data/doc/ri/Quarry/Spec/Runner/check_spec-i.yaml +0 -12
  228. data/doc/ri/Quarry/Spec/Runner/new-c.yaml +0 -12
  229. data/doc/ri/Quarry/Spec/Runner/run_step-i.yaml +0 -12
  230. data/doc/ri/Quarry/Spec/Step/cdesc-Step.yaml +0 -30
  231. data/doc/ri/Quarry/Spec/Step/new-c.yaml +0 -10
  232. data/doc/ri/Quarry/Spec/Template/cdesc-Template.yaml +0 -31
  233. data/doc/ri/Quarry/Spec/Template/new-c.yaml +0 -11
  234. data/doc/ri/Quarry/Spec/Template/parse_template-i.yaml +0 -10
  235. data/doc/ri/Quarry/Spec/cdesc-Spec.yaml +0 -15
  236. data/doc/ri/Quarry/Stub/Delegator/cdesc-Delegator.yaml +0 -20
  237. data/doc/ri/Quarry/Stub/Delegator/method_missing-i.yaml +0 -10
  238. data/doc/ri/Quarry/Stub/Delegator/new-c.yaml +0 -10
  239. data/doc/ri/Quarry/Stub/Setter/%3d%3d-i.yaml +0 -10
  240. data/doc/ri/Quarry/Stub/Setter/cdesc-Setter.yaml +0 -18
  241. data/doc/ri/Quarry/Stub/Setter/new-c.yaml +0 -10
  242. data/doc/ri/Quarry/Stub/__table__-i.yaml +0 -11
  243. data/doc/ri/Quarry/Stub/cdesc-Stub.yaml +0 -23
  244. data/doc/ri/Quarry/Stub/method_missing-i.yaml +0 -11
  245. data/doc/ri/Quarry/Stub/new-c.yaml +0 -10
  246. data/doc/ri/Quarry/cdesc-Quarry.yaml +0 -16
  247. data/doc/ri/created.rid +0 -1
  248. data/doc/spec/stub.html +0 -394
  249. data/lib/quarry/assert.rb +0 -198
  250. data/lib/quarry/break.rb +0 -51
  251. data/lib/quarry/spec/document.rb +0 -130
  252. data/lib/quarry/spec/markup.rb +0 -85
  253. data/lib/quarry/spec/reporter/dotprogress.rb +0 -66
  254. data/lib/quarry/spec/reporter/summary.rb +0 -74
  255. data/lib/quarry/spec/reporter/verbatim.rb +0 -87
  256. data/lib/quarry/spec/reporter.rb +0 -74
  257. data/lib/quarry/spec/runner.rb +0 -127
  258. data/lib/quarry/spec/template.rhtml +0 -116
  259. data/lib/quarry/spec.rb +0 -7
  260. data/lib/quarry/stub/spec.txt +0 -113
  261. data/work/consider/document.rb +0 -35
  262. data/work/consider/fixture.rb +0 -153
  263. data/work/deprecated/assert/must.rb +0 -9
  264. data/work/deprecated/assert/should.rb +0 -9
  265. data/work/deprecated/build.rb +0 -82
  266. data/work/deprecated/mock/file.rb +0 -11
  267. data/work/deprecated/mock/mock.0.rb +0 -77
  268. data/work/deprecated/overlay.rb +0 -64
  269. data/work/deprecated/spec.rb +0 -195
  270. data/work/deprecated/stub/stub.0.rb +0 -180
  271. data/work/deprecated/stub/stub.1.rb +0 -114
  272. data/work/deprecated/stub/test_stub.rb +0 -66
  273. data/work/deprecated/test/case.rb +0 -141
  274. data/work/sandbox/assert.rb +0 -100
  275. data/work/sandbox/bug.rb +0 -49
  276. data/work/sandbox/build/announce.rb +0 -213
  277. data/work/sandbox/build/check.rb +0 -109
  278. data/work/sandbox/build/gem.rb +0 -235
  279. data/work/sandbox/build/make.rb +0 -118
  280. data/work/sandbox/build/manpage.rb +0 -201
  281. data/work/sandbox/build/notes.rb +0 -214
  282. data/work/sandbox/build/pack.rb +0 -228
  283. data/work/sandbox/build/rdoc.rb +0 -289
  284. data/work/sandbox/build/rubyforge.rb +0 -91
  285. data/work/sandbox/build/sign.rb +0 -241
  286. data/work/sandbox/build/stamp.rb +0 -37
  287. data/work/sandbox/build/stats.rb +0 -154
  288. data/work/sandbox/build/svn.rb +0 -193
  289. data/work/sandbox/build/test.rb +0 -521
  290. data/work/sandbox/design.rb +0 -200
  291. data/work/sandbox/iface_scanner.rb +0 -102
  292. data/work/sandbox/testunit/assertions/assert_has_keys.rb +0 -38
  293. data/work/sandbox/testunit/assertions/assert_has_only_keys.rb +0 -38
  294. data/work/sandbox/testunit/unit.rb +0 -104
  295. data/work/sandbox/unitspec.rb +0 -54
  296. data/work/sandbox/x_isotest.rb +0 -532
@@ -1,82 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Utils
4
- #
5
- # = COPYING:
6
- #
7
- # Copyright (c) 2007 Tiger Ops
8
- #
9
- # This file is part of the Reap program.
10
- #
11
- # Reap is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Reap is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Reap. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- require 'yaml' # make it generally available
25
- require 'rbconfig' # replace with facets/system?
26
-
27
- require 'quarry/support/options'
28
- require 'quarry/utils/fileutils'
29
- require 'quarry/utils/shellutils'
30
- require 'quarry/utils/netutils'
31
- #require 'reap/tasksystem'
32
-
33
- module Quarry
34
-
35
- class Build
36
- include ShellUtils
37
- include FileUtils
38
- include NetUtils
39
-
40
- def initialize(*configs)
41
- configs.each do |config|
42
- next unless config
43
- config.each do |key,value|
44
- send("#{key}=", value) if respond_to?("#{key}=")
45
- end
46
- end
47
- end
48
-
49
- def initialize(options=nil)
50
- options ||= {}
51
- options.each do |k,v|
52
- k = k.to_s.downcase
53
- send("#{k}=", v) if respond_to?("#{k}=")
54
- end
55
- end
56
-
57
- # General options.
58
-
59
- attr_writer :dryrun, :trace, :force, :verbose
60
-
61
- def dryrun? ; @dryrun ; end
62
- def trace? ; @trace ; end
63
- def force? ; @force ; end
64
- def verbose? ; @verbose ; end
65
- def debug? ; @debug ; end
66
-
67
- alias_method :noharm=, :dryrun=
68
- alias_method :noharm?, :dryrun?
69
-
70
- def options
71
- {
72
- :dryrun => dryrun?,
73
- :trace => trace?,
74
- :force => force?,
75
- :verbose => verbose?,
76
- :debug => debug?
77
- }
78
- end
79
-
80
- end
81
-
82
- end
@@ -1,11 +0,0 @@
1
- # Mock File Class
2
-
3
- module Quarry
4
- module Mock
5
-
6
- class File
7
- end
8
-
9
- end
10
- end
11
-
@@ -1,77 +0,0 @@
1
- require 'quarry/assert'
2
-
3
- module Quarry
4
-
5
- # Quarry's Mocking facility.
6
- #
7
- # obj = "hello"
8
- #
9
- # obj.mock.upcase == "HeLLo"
10
- #
11
- # obj.upcase #=> "HeLLo"
12
- #
13
- # obj.mockless!
14
- #
15
- # obj.upcase #=> "HELLO"
16
- #
17
- class Mock < Module
18
- attr :object
19
-
20
- def initialize(object)
21
- super()
22
- @object = object
23
- @table = {}
24
- object.extend(self)
25
- end
26
-
27
- def __table__ ; @table ; end
28
-
29
- def method_missing(meth, *args, &block)
30
- table = @table
31
- interface = [meth, args, block_given?]
32
-
33
- table[interface] = nil
34
-
35
- define_method(meth) do |*args|
36
- result = super
37
- result.assert == table[interface]
38
- return result
39
- end
40
-
41
- Setter.new(table, interface)
42
- end
43
-
44
- #
45
- class Setter
46
- def initialize(table, interface)
47
- @table = table
48
- @interface = interface
49
- end
50
-
51
- def ==(result)
52
- @table[@interface] = result
53
- end
54
- end
55
-
56
- end
57
-
58
- #
59
- class ::Object
60
-
61
- def mock
62
- @_mock ||= Mock.new(self)
63
- end
64
-
65
- def mockless!
66
- mock.__table__.each do |interface, result|
67
- meth = interface[0]
68
- mock.module_eval do
69
- remove_method(meth)
70
- end
71
- end
72
- end
73
-
74
- end
75
-
76
- end
77
-
@@ -1,64 +0,0 @@
1
- module Quarry
2
-
3
- # = Overlay
4
- #
5
- # The idea of the Overlay is to proved a convenient way to
6
- # create test stubs. You can take an original class and
7
- # turn features on and off at your leasure, substituting
8
- # in your choice of code piece meal.
9
- #
10
- # class X
11
- # def a; 1; end
12
- # def b; a + 1; end
13
- # end
14
- #
15
- # XO = Quarry::Overlay.new do
16
- # def_over(:a) do
17
- # 2
18
- # end
19
- # end
20
- #
21
- # x = X.new
22
- # p x.a #=> 1
23
- #
24
- # XO.append_features(X)
25
- # p x.a #=> 2
26
- #
27
- # XO.remove_features(X)
28
- # p x.a #=> 1
29
- #
30
- class Overlay
31
-
32
- def initialize(&block)
33
- @over = {}
34
- @cache = Hash.new{ |h,k| h[k]={} }
35
- instance_eval(&block) if block_given?
36
- end
37
-
38
- def define_method(methname, &block)
39
- @over[methname] = block
40
- end
41
-
42
- def append_features(base)
43
- @over.each do |name, block|
44
- next if base.instance_methods(true).include?("#{name}:#{base.__id__}:super")
45
- if m = base.instance_methods(true).include?(name.to_s)
46
- base.__send__(:alias_method, "#{name}:#{base.__id__}:super", name)
47
- base.__send__(:define_method, name, &block)
48
- end
49
- end
50
- end
51
-
52
- def remove_features(base)
53
- @over.each do |name, block|
54
- next unless base.instance_methods(true).include?("#{name}:#{base.__id__}:super")
55
- if m = base.instance_method("#{name}:#{base.__id__}:super")
56
- base.__send__(:alias_method, name, "#{name}:#{base.__id__}:super")
57
- end
58
- end
59
- end
60
-
61
- end
62
-
63
- end
64
-
@@ -1,195 +0,0 @@
1
- require 'quarry/assertion'
2
-
3
- module Quarry
4
-
5
- class << self
6
- def specification(description, &specification)
7
- Design.specification(description, &specification)
8
- end
9
-
10
- alias_method :spec, :specification
11
- end
12
-
13
- module Design
14
-
15
- class << self
16
- def specifications
17
- @specifications ||= []
18
- end
19
-
20
- def specification(description, &specification)
21
- specifications << Spec.new(description, nil, &specification)
22
- end
23
- alias_method :spec, :specification
24
-
25
- # TODO: make output compatible with unit_diff ?
26
-
27
- def check
28
- specifications.each do |specification|
29
- Runner.new(specification).check
30
- end
31
- end
32
-
33
- def outline
34
- specifications.each do |specification|
35
- Runner.new(specification).outline
36
- end
37
- end
38
- end
39
-
40
- # = Spec
41
- #
42
- class Spec
43
- #undef_method *instance_methods.select{|m| m.to_s !~ /^(__|instance_|object_)/}
44
-
45
- # Specification description.
46
- attr :description
47
-
48
- # Parent specification (if any).
49
- attr :parent
50
-
51
- #
52
- attr :given
53
-
54
- #
55
- attr :before
56
-
57
- #
58
- attr :after
59
-
60
- # Subspecifications
61
- attr :specs
62
-
63
- # Steps in specification proof.
64
- attr :steps
65
-
66
- #
67
- def initialize(description, parent, &block)
68
- #@relation = relation
69
- @description = description
70
- @parent = parent
71
-
72
- @given = nil
73
- @before = nil
74
- @after = nil
75
-
76
- @specs = []
77
- @steps = []
78
-
79
- instance_eval(&block)
80
- end
81
-
82
- #
83
- def given(&block)
84
- block ? @given = block : @given
85
- end
86
-
87
- #
88
- def before(&block)
89
- block ? @before = block : @before
90
- end
91
-
92
- #
93
- def after(&block)
94
- block ? @after = block : @after
95
- end
96
-
97
- def context(description, &block)
98
- specs << Spec.new(description, self, &block)
99
- end
100
-
101
- #
102
- def prove(description, &block)
103
- steps << Step.new(description, self, &block)
104
- end
105
-
106
- alias_method :it, :prove
107
- alias_method :its, :prove
108
-
109
- #
110
- #def method_missing(relation, *description, &specification)
111
- # if description.size > 1
112
- # super
113
- # else
114
- # specifications << Specification.new(relation, description.first, self, &specification)
115
- # end
116
- #end
117
- end #class Context
118
-
119
- #
120
- class Step
121
- attr :description
122
- attr :parent
123
- attr :code
124
-
125
- def initialize(description, parent, &code)
126
- @description = description
127
- @parent = parent
128
- @code = code
129
- end
130
- end
131
-
132
- end #module Desgin
133
-
134
- end #module Quarry
135
-
136
- #at_exit { Quarry::Design.check unless $no_autocheck }
137
-
138
-
139
- =begin demo
140
-
141
- Quarry::Design.specification "Example Specification" do
142
-
143
- context "demonstrate basic assertions" do
144
-
145
- specify "fail if should is false" do
146
- 4.assert == 3
147
- end
148
-
149
- specify "fail if should_not is true" do
150
- 4.assert! == 4
151
- end
152
-
153
- specify "fail on should raise" do
154
- lambda{raise ArgumentError}.assert.raise? SyntaxError
155
- end
156
-
157
- end
158
-
159
- end
160
-
161
- $no_autocheck = true
162
-
163
- Quarry::Design.outline
164
-
165
- =end
166
-
167
-
168
- if __FILE__ == $0
169
-
170
- Quarry::Design.spec "Example Specification" do
171
-
172
- it "demontrates basic assertions" do
173
-
174
- it "eg. 4 == 3 fails" do
175
- 4.assert == 3
176
- end
177
-
178
- it "eg. 4 != 4 fails" do
179
- 4.assert! == 4
180
- end
181
-
182
- it "eg. raises an ArgumentError does not raise a SyntaxError" do
183
- lambda{raise ArgumentError}.assert.raise? SyntaxError
184
- end
185
-
186
- end
187
-
188
- end
189
-
190
- $no_autocheck = true
191
-
192
- Quarry::Design.outline
193
-
194
- end
195
-
@@ -1,180 +0,0 @@
1
- module Quarry
2
- require 'ostruct'
3
-
4
- # = Stub
5
- #
6
- # A straightfoward stubbing facility. Typically used in test cases.
7
- # The Stub class offers a few constructors for quickly building
8
- # of stubs.
9
- #
10
- # stat - Returns a static reponse.
11
- # echo - Returns the arguments passed-in.
12
- # spin - Returns a rotation of responses.
13
- # keys - Returns an index of responses.
14
- #
15
- # Stub classes can be built from sratch or partially framed
16
- # against other classes.
17
- #
18
- # === Usage
19
- #
20
- # class ContextStub < Stub
21
- # stat :response_headers, {}
22
- # spin :host_url, ['http://www.nitrohq.com','http://www.rubyforge.com']
23
- # end
24
- #
25
- # ctx = ContextStub.new
26
- # ctx.response_headers['location'] = url
27
- # ctx.host_url #=> "http://www.nitrohq.com"
28
- # ctx.host_url #=> "http://www.rubyforge.com"
29
- #
30
- # === Note
31
- #
32
- # Quarry doesn't have Mocks, and may never. You can combine
33
- # Stubs and Assertions fairly effectively to do essentailly
34
- # what Mocks do, without having to learn yet another DSL
35
- # for describing object behaviors.
36
- #
37
- class Stub < OpenStruct
38
-
39
- # Certain methods are not mocked:
40
- # inspect (tricky)
41
- # class (delegated)
42
- # kind_of? (delegated)
43
- # is_a? (delegated)
44
- # instance_of? (delegated)
45
- # method (works as-is)
46
- # send (works as-is)
47
- # respond_to? (works as-is)
48
- # hash (no way to mock)
49
- #
50
- # __id__, __call__, etc. (not meant to be stubbed, ever!)
51
- #
52
- UnstubbedMethods = %r{^(
53
- |inspect
54
- |kind_of\?|is_a\?|instance_of\?|class
55
- |method|send|respond_to\?
56
- |hash
57
- |__
58
- )}x
59
-
60
- class << self
61
- attr :realclass
62
-
63
- def stubbed_methods
64
- self.methods(false)
65
- end
66
-
67
- # Returns a static response.
68
- def stat(sym, val)
69
- define_method(sym){|*args| val}
70
- end
71
-
72
- # This one is dumb.
73
- # Responds with input.
74
- def echo(sym)
75
- define_method(sym){|*args| args}
76
- end
77
-
78
- # This is probably dumb.
79
- # Reponds with a rotation of reponses.
80
- def spin( sym, arr )
81
- define_method( sym ) { |*args| arr.push(arr.shift) ; arr[-1] }
82
- end
83
-
84
- # Responds according to a mapping of input parameters.
85
- def keys( sym, hsh )
86
- define_method( sym ) { |*args| hsh[args] }
87
- end
88
- end
89
-
90
- alias :__class :class
91
-
92
- # Delegate #class method.
93
- def class # :nodoc:
94
- return __class.realclass
95
- end
96
-
97
- # Delegate #instance_of? method.
98
- def instance_of?(klass) # :nodoc:
99
- self.class == klass
100
- end
101
-
102
- # Delegate #kind_of? method.
103
- def kind_of?(klass) # :nodoc:
104
- self.class <= klass
105
- end
106
-
107
- # Delegate #is_a? method.
108
- alias_method :is_a?, :kind_of?
109
-
110
- end # class Stub
111
-
112
- ### Factory method for automatically creating semi-functional
113
- ### stub classes given a real class. It looks like a constant
114
- ### for purposes of syntactic sugar.
115
- ###
116
- ### class MyStub < Stub(X)
117
- ### ...
118
- ### end
119
- ###
120
- def self.Stub(realclass)
121
-
122
- stubclass = Class.new(Stub)
123
-
124
- stubclass.instance_eval{ @realclass = realclass }
125
-
126
- # Provide an accessor to class instance var that holds the class
127
- # object we're faking
128
- class << stubclass
129
- # The actual class being mocked
130
- attr_reader :realclass
131
-
132
- # Propagate the mocked class ivar to derivatives so it can be
133
- # called like:
134
- # class MockFoo < Mock(RealClass)
135
- def inherited(subclass)
136
- rc = self.realclass
137
- subclass.instance_eval{ @realclass = rc }
138
- end
139
- end
140
-
141
- # Build method definitions for all the mocked class's instance
142
- # methods, as well as those given to it by its superclasses, since
143
- # we're not really inheriting from it.
144
- imethods = realclass.instance_methods(true).collect do |name|
145
- next if name =~ Quarry::Stub::UnstubbedMethods
146
-
147
- # Figure out the argument list
148
- arity = realclass.instance_method(name).arity
149
- optargs = false
150
-
151
- if arity < 0
152
- optargs = true
153
- arity = (arity+1).abs
154
- end
155
-
156
- args = []
157
- arity.times{|n| args << "arg#{n+1}"}
158
- args << "*optargs" if optargs
159
-
160
- # Build a method definition. Some methods need special
161
- # declarations.
162
- argsj = args.join(',')
163
- case name.intern
164
- when :initialize
165
- "def initialize(#{argsj}) ; super ; end"
166
- else
167
- "def #{name}(#{argsj}) ; self.send(#{name},#{argsj}) ; end"
168
- #"def %s( %s ) ; self.__mockRegisterCall(%s) ; end" %
169
- # [ name, argstr, [":#{name}", *args].join(',') ]
170
- end
171
- end
172
-
173
- # Now add the instance methods to the stubclass class
174
- stubclass.class_eval imethods.join( "\n" )
175
-
176
- return stubclass
177
- end
178
-
179
- end
180
-
@@ -1,114 +0,0 @@
1
- require 'quarry/stub/overlay'
2
-
3
- module Quarry
4
-
5
- =begin
6
- class Stub
7
- def initialize(object)
8
- @instance_delegate = object
9
- end
10
-
11
- def method_missing(s, *a, &b)
12
- @instance_delegate.__send__(s, *a, &b)
13
- end
14
- end
15
- =end
16
-
17
- # Quarry's Stubbing facility.
18
- #
19
- # obj = "hello"
20
- #
21
- # obj.stub.upcase == "HeLLo"
22
- #
23
- # obj.upcase #=> "HeLLo"
24
- #
25
- # obj.stubless!
26
- #
27
- # obj.upcase #=> "HELLO"
28
- #
29
- class Stub < Module
30
- attr :object
31
-
32
- def initialize(object)
33
- super()
34
- @object = object
35
- @table = {}
36
- @overlay = Overlay.new
37
- end
38
-
39
- def __table__ ; @table ; end
40
-
41
- def method_missing(meth, *args, &block)
42
- table = @table
43
- interface = [meth, args, block_given?]
44
-
45
- table[interface] = nil
46
-
47
- @overlay.define_method(meth) do |*args|
48
- table[interface]
49
- end
50
-
51
- @overlay.append_features((class << @object; self; end))
52
-
53
- Setter.new(table, interface)
54
- end
55
-
56
- #
57
- class Setter
58
- def initialize(table, interface)
59
- @table = table
60
- @interface = interface
61
- end
62
-
63
- def ==(result)
64
- @table[@interface] = result
65
- end
66
- end
67
-
68
- end
69
-
70
- #
71
- class ::Object
72
-
73
- def stub
74
- @_stub ||= Stub.new(self)
75
- end
76
-
77
- def remove_stubs
78
- stub.instance_eval do
79
- @overlay.remove_features((class << @object; self; end))
80
- end
81
- #stub.__table__.each do |interface, result|
82
- # meth = interface[0]
83
- # stub.module_eval do
84
- # remove_method(meth)
85
- # end
86
- #end
87
- end
88
-
89
- end
90
-
91
- end
92
-
93
- if $0 == __FILE__
94
-
95
- # Only one possible stub definition per object?
96
-
97
- obj = "hello"
98
-
99
- obj.stub.upcase == "HeLLo"
100
-
101
- p obj.upcase #=> "HeLLo"
102
-
103
- # We could always copy it.
104
-
105
- obj2 = obj.copy
106
-
107
- # Eek that means we need to copy stub too (FIXME: initialize_copy)
108
-
109
- obj.remove_stubs
110
-
111
- p obj.upcase #=> "HELLO"
112
-
113
- end
114
-