lookout 2.3.0 → 3.0.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 (328) hide show
  1. checksums.yaml +7 -0
  2. data/README +351 -181
  3. data/Rakefile +20 -5
  4. data/lib/lookout-3.0.rb +138 -0
  5. data/lib/lookout-3.0/actual.rb +30 -0
  6. data/lib/lookout-3.0/actual/method.rb +31 -0
  7. data/lib/lookout-3.0/actual/not.rb +13 -0
  8. data/lib/lookout-3.0/actual/not/method.rb +10 -0
  9. data/lib/lookout-3.0/aphonic.rb +44 -0
  10. data/lib/lookout-3.0/diff.rb +29 -0
  11. data/lib/{lookout → lookout-3.0}/diff/algorithms.rb +1 -1
  12. data/lib/lookout-3.0/diff/algorithms/difflib.rb +62 -0
  13. data/lib/lookout-3.0/diff/algorithms/difflib/position.rb +63 -0
  14. data/lib/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +8 -17
  15. data/lib/lookout-3.0/diff/formats.rb +5 -0
  16. data/lib/lookout-3.0/diff/formats/inline.rb +43 -0
  17. data/lib/lookout-3.0/diff/formats/set.rb +48 -0
  18. data/lib/lookout-3.0/diff/formats/unified.rb +56 -0
  19. data/lib/lookout-3.0/diff/group.rb +57 -0
  20. data/lib/lookout-3.0/diff/groups.rb +47 -0
  21. data/lib/lookout-3.0/diff/match.rb +31 -0
  22. data/lib/lookout-3.0/diff/operation.rb +41 -0
  23. data/lib/lookout-3.0/diff/operations.rb +35 -0
  24. data/lib/lookout-3.0/diff/operations/copy.rb +25 -0
  25. data/lib/lookout-3.0/diff/operations/delete.rb +5 -0
  26. data/lib/lookout-3.0/diff/operations/insert.rb +5 -0
  27. data/lib/lookout-3.0/diff/operations/replace.rb +6 -0
  28. data/lib/lookout-3.0/diff/slice.rb +97 -0
  29. data/lib/lookout-3.0/difference.rb +10 -0
  30. data/lib/lookout-3.0/difference/array.rb +22 -0
  31. data/lib/lookout-3.0/difference/exception.rb +40 -0
  32. data/lib/lookout-3.0/difference/hash.rb +31 -0
  33. data/lib/lookout-3.0/difference/lookout.rb +5 -0
  34. data/lib/lookout-3.0/difference/lookout/actual.rb +6 -0
  35. data/lib/lookout-3.0/difference/lookout/actual/method.rb +13 -0
  36. data/lib/lookout-3.0/difference/lookout/actual/not.rb +6 -0
  37. data/lib/lookout-3.0/difference/lookout/actual/not/method.rb +9 -0
  38. data/lib/lookout-3.0/difference/lookout/output.rb +8 -0
  39. data/lib/lookout-3.0/difference/lookout/reception.rb +21 -0
  40. data/lib/lookout-3.0/difference/lookout/warning.rb +9 -0
  41. data/lib/lookout-3.0/difference/module.rb +12 -0
  42. data/lib/lookout-3.0/difference/object.rb +73 -0
  43. data/lib/lookout-3.0/difference/range.rb +12 -0
  44. data/lib/lookout-3.0/difference/regexp.rb +12 -0
  45. data/lib/lookout-3.0/difference/string.rb +21 -0
  46. data/lib/lookout-3.0/difference/symbol.rb +21 -0
  47. data/lib/lookout-3.0/encode.rb +20 -0
  48. data/lib/lookout-3.0/exception.rb +79 -0
  49. data/lib/lookout-3.0/exception/backtrace.rb +65 -0
  50. data/lib/lookout-3.0/exception/unknown.rb +25 -0
  51. data/lib/lookout-3.0/expect.rb +32 -0
  52. data/lib/lookout-3.0/expect/classes.rb +6 -0
  53. data/lib/lookout-3.0/expect/classes/exception.rb +27 -0
  54. data/lib/lookout-3.0/expect/exception.rb +30 -0
  55. data/lib/lookout-3.0/expect/object.rb +54 -0
  56. data/lib/lookout-3.0/expect/object/context.rb +149 -0
  57. data/lib/lookout-3.0/expectations.rb +69 -0
  58. data/lib/lookout-3.0/expectations/context.rb +52 -0
  59. data/lib/lookout-3.0/expected.rb +10 -0
  60. data/lib/lookout-3.0/expected/array.rb +16 -0
  61. data/lib/lookout-3.0/expected/classes.rb +5 -0
  62. data/lib/lookout-3.0/expected/classes/exception.rb +14 -0
  63. data/lib/lookout-3.0/expected/exception.rb +46 -0
  64. data/lib/lookout-3.0/expected/falseclass.rb +9 -0
  65. data/lib/lookout-3.0/expected/hash.rb +14 -0
  66. data/lib/lookout-3.0/expected/lookout.rb +5 -0
  67. data/lib/lookout-3.0/expected/lookout/actual.rb +5 -0
  68. data/lib/lookout-3.0/expected/lookout/actual/method.rb +13 -0
  69. data/lib/lookout-3.0/expected/lookout/actual/not.rb +6 -0
  70. data/lib/lookout-3.0/expected/lookout/actual/not/method.rb +13 -0
  71. data/lib/lookout-3.0/expected/lookout/output.rb +26 -0
  72. data/lib/lookout-3.0/expected/lookout/reception.rb +24 -0
  73. data/lib/lookout-3.0/expected/lookout/warning.rb +29 -0
  74. data/lib/lookout-3.0/expected/module.rb +12 -0
  75. data/lib/lookout-3.0/expected/object.rb +30 -0
  76. data/lib/lookout-3.0/expected/range.rb +12 -0
  77. data/lib/lookout-3.0/expected/regexp.rb +12 -0
  78. data/lib/lookout-3.0/expected/string.rb +11 -0
  79. data/lib/lookout-3.0/expected/symbol.rb +21 -0
  80. data/lib/lookout-3.0/expected/trueclass.rb +9 -0
  81. data/lib/lookout-3.0/inspect.rb +45 -0
  82. data/lib/lookout-3.0/interfaces.rb +5 -0
  83. data/lib/lookout-3.0/interfaces/commandline.rb +109 -0
  84. data/lib/lookout-3.0/literal.rb +18 -0
  85. data/lib/lookout-3.0/mock.rb +24 -0
  86. data/lib/lookout-3.0/object.rb +6 -0
  87. data/lib/lookout-3.0/object/not.rb +16 -0
  88. data/lib/lookout-3.0/object/not/receive.rb +18 -0
  89. data/lib/lookout-3.0/object/to.rb +12 -0
  90. data/lib/lookout-3.0/object/to/receive.rb +18 -0
  91. data/lib/lookout-3.0/output.rb +20 -0
  92. data/lib/lookout-3.0/plugins.rb +7 -0
  93. data/lib/lookout-3.0/reception.rb +128 -0
  94. data/lib/lookout-3.0/reception/arguments.rb +20 -0
  95. data/lib/lookout-3.0/reception/arguments/any.rb +16 -0
  96. data/lib/lookout-3.0/reception/arguments/error.rb +5 -0
  97. data/lib/lookout-3.0/reception/arguments/list.rb +17 -0
  98. data/lib/lookout-3.0/reception/arguments/none.rb +6 -0
  99. data/lib/lookout-3.0/reception/error.rb +24 -0
  100. data/lib/lookout-3.0/result.rb +16 -0
  101. data/lib/lookout-3.0/results.rb +5 -0
  102. data/lib/lookout-3.0/results/error.rb +18 -0
  103. data/lib/lookout-3.0/results/failure.rb +15 -0
  104. data/lib/lookout-3.0/results/success.rb +7 -0
  105. data/lib/lookout-3.0/stub.rb +55 -0
  106. data/lib/lookout-3.0/version.rb +133 -0
  107. data/lib/lookout-3.0/warning.rb +40 -0
  108. data/test/unit/examples.rb +208 -83
  109. data/test/unit/{lookout.rb → lookout-3.0.rb} +0 -0
  110. data/test/unit/lookout-3.0/actual.rb +13 -0
  111. data/test/unit/lookout-3.0/actual/method.rb +31 -0
  112. data/test/unit/lookout-3.0/actual/not.rb +15 -0
  113. data/test/unit/lookout-3.0/actual/not/method.rb +7 -0
  114. data/test/unit/lookout-3.0/aphonic.rb +31 -0
  115. data/test/unit/{lookout → lookout-3.0}/diff.rb +0 -0
  116. data/test/unit/{lookout/diff/group.rb → lookout-3.0/diff/algorithms.rb} +0 -0
  117. data/test/unit/lookout-3.0/diff/algorithms/difflib.rb +56 -0
  118. data/test/unit/lookout-3.0/diff/algorithms/difflib/position.rb +92 -0
  119. data/test/unit/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +1 -2
  120. data/test/unit/{lookout/results.rb → lookout-3.0/diff/formats.rb} +0 -0
  121. data/test/unit/{lookout → lookout-3.0}/diff/formats/inline.rb +0 -0
  122. data/test/unit/lookout-3.0/diff/formats/set.rb +26 -0
  123. data/test/unit/{lookout → lookout-3.0}/diff/formats/unified.rb +0 -0
  124. data/test/unit/{lookout/results/error.rb → lookout-3.0/diff/group.rb} +0 -0
  125. data/test/unit/lookout-3.0/diff/groups.rb +102 -0
  126. data/test/unit/{lookout → lookout-3.0}/diff/match.rb +0 -0
  127. data/test/unit/lookout-3.0/diff/operation.rb +17 -0
  128. data/test/unit/lookout-3.0/diff/operations.rb +22 -0
  129. data/test/unit/lookout-3.0/diff/operations/copy.rb +50 -0
  130. data/test/unit/lookout-3.0/diff/operations/delete.rb +45 -0
  131. data/test/unit/lookout-3.0/diff/operations/insert.rb +45 -0
  132. data/test/unit/lookout-3.0/diff/operations/replace.rb +45 -0
  133. data/test/unit/lookout-3.0/diff/slice.rb +56 -0
  134. data/test/unit/{lookout/results/failures/behavior.rb → lookout-3.0/difference.rb} +0 -0
  135. data/test/unit/lookout-3.0/difference/array.rb +32 -0
  136. data/test/unit/lookout-3.0/difference/exception.rb +69 -0
  137. data/test/unit/lookout-3.0/difference/hash.rb +30 -0
  138. data/test/unit/{lookout/results/failures/state.rb → lookout-3.0/difference/lookout.rb} +0 -0
  139. data/test/unit/{lookout/results/fulfilled.rb → lookout-3.0/difference/lookout/actual.rb} +0 -0
  140. data/test/unit/lookout-3.0/difference/lookout/actual/method.rb +7 -0
  141. data/test/unit/{lookout/runners/console.rb → lookout-3.0/difference/lookout/actual/not.rb} +0 -0
  142. data/test/unit/lookout-3.0/difference/lookout/actual/not/method.rb +7 -0
  143. data/test/unit/lookout-3.0/difference/lookout/output.rb +11 -0
  144. data/test/unit/lookout-3.0/difference/lookout/reception.rb +11 -0
  145. data/test/unit/lookout-3.0/difference/lookout/warning.rb +11 -0
  146. data/test/unit/lookout-3.0/difference/module.rb +11 -0
  147. data/test/unit/lookout-3.0/difference/object.rb +31 -0
  148. data/test/unit/lookout-3.0/difference/range.rb +11 -0
  149. data/test/unit/lookout-3.0/difference/regexp.rb +11 -0
  150. data/test/unit/lookout-3.0/difference/string.rb +29 -0
  151. data/test/unit/lookout-3.0/difference/symbol.rb +11 -0
  152. data/test/unit/lookout-3.0/encode.rb +28 -0
  153. data/test/unit/lookout-3.0/exception.rb +107 -0
  154. data/test/unit/lookout-3.0/exception/backtrace.rb +75 -0
  155. data/test/unit/lookout-3.0/exception/unknown.rb +23 -0
  156. data/test/unit/lookout-3.0/expect.rb +15 -0
  157. data/test/unit/{lookout/ui/console.rb → lookout-3.0/expect/classes.rb} +0 -0
  158. data/test/unit/lookout-3.0/expect/classes/exception.rb +41 -0
  159. data/test/unit/lookout-3.0/expect/exception.rb +63 -0
  160. data/test/unit/lookout-3.0/expect/object.rb +55 -0
  161. data/test/unit/lookout-3.0/expect/object/context.rb +120 -0
  162. data/test/unit/lookout-3.0/expectations.rb +55 -0
  163. data/test/unit/lookout-3.0/expectations/context.rb +44 -0
  164. data/test/unit/lookout-3.0/expected.rb +4 -0
  165. data/test/unit/lookout-3.0/expected/array.rb +19 -0
  166. data/test/unit/lookout-3.0/expected/classes.rb +4 -0
  167. data/test/unit/lookout-3.0/expected/classes/exception.rb +7 -0
  168. data/test/unit/lookout-3.0/expected/exception.rb +24 -0
  169. data/test/unit/lookout-3.0/expected/falseclass.rb +23 -0
  170. data/test/unit/lookout-3.0/expected/hash.rb +23 -0
  171. data/test/unit/lookout-3.0/expected/lookout.rb +4 -0
  172. data/test/unit/lookout-3.0/expected/lookout/actual.rb +4 -0
  173. data/test/unit/lookout-3.0/expected/lookout/actual/method.rb +11 -0
  174. data/test/unit/lookout-3.0/expected/lookout/actual/not.rb +4 -0
  175. data/test/unit/lookout-3.0/expected/lookout/actual/not/method.rb +11 -0
  176. data/test/unit/lookout-3.0/expected/lookout/output.rb +27 -0
  177. data/test/unit/lookout-3.0/expected/lookout/reception.rb +25 -0
  178. data/test/unit/lookout-3.0/expected/lookout/warning.rb +48 -0
  179. data/test/unit/lookout-3.0/expected/module.rb +23 -0
  180. data/test/unit/lookout-3.0/expected/object.rb +24 -0
  181. data/test/unit/lookout-3.0/expected/range.rb +19 -0
  182. data/test/unit/lookout-3.0/expected/regexp.rb +19 -0
  183. data/test/unit/lookout-3.0/expected/string.rb +44 -0
  184. data/test/unit/lookout-3.0/expected/symbol.rb +35 -0
  185. data/test/unit/lookout-3.0/expected/trueclass.rb +23 -0
  186. data/test/unit/lookout-3.0/inspect.rb +39 -0
  187. data/test/unit/lookout-3.0/interfaces.rb +4 -0
  188. data/test/unit/lookout-3.0/interfaces/commandline.rb +4 -0
  189. data/test/unit/lookout-3.0/literal.rb +15 -0
  190. data/test/unit/lookout-3.0/mock.rb +22 -0
  191. data/test/unit/lookout-3.0/object.rb +4 -0
  192. data/test/unit/lookout-3.0/object/not.rb +7 -0
  193. data/test/unit/lookout-3.0/object/not/receive.rb +9 -0
  194. data/test/unit/lookout-3.0/object/to.rb +7 -0
  195. data/test/unit/lookout-3.0/object/to/receive.rb +9 -0
  196. data/test/unit/lookout-3.0/output.rb +31 -0
  197. data/test/unit/lookout-3.0/plugins.rb +4 -0
  198. data/test/unit/lookout-3.0/reception.rb +86 -0
  199. data/test/unit/lookout-3.0/reception/arguments.rb +23 -0
  200. data/test/unit/lookout-3.0/reception/arguments/any.rb +15 -0
  201. data/test/unit/lookout-3.0/reception/arguments/error.rb +4 -0
  202. data/test/unit/lookout-3.0/reception/arguments/list.rb +19 -0
  203. data/test/unit/lookout-3.0/reception/arguments/none.rb +15 -0
  204. data/test/unit/lookout-3.0/reception/error.rb +4 -0
  205. data/test/unit/lookout-3.0/result.rb +27 -0
  206. data/test/unit/lookout-3.0/results.rb +4 -0
  207. data/test/unit/lookout-3.0/results/error.rb +37 -0
  208. data/test/unit/lookout-3.0/results/failure.rb +21 -0
  209. data/test/unit/lookout-3.0/results/success.rb +4 -0
  210. data/test/unit/lookout-3.0/stub.rb +53 -0
  211. data/test/unit/lookout-3.0/version.rb +4 -0
  212. data/test/unit/lookout-3.0/warning.rb +47 -0
  213. metadata +1159 -456
  214. data/lib/lookout.rb +0 -30
  215. data/lib/lookout/aphonic.rb +0 -40
  216. data/lib/lookout/diff.rb +0 -10
  217. data/lib/lookout/diff/algorithms/difflib.rb +0 -38
  218. data/lib/lookout/diff/algorithms/difflib/position.rb +0 -92
  219. data/lib/lookout/diff/formats.rb +0 -7
  220. data/lib/lookout/diff/formats/hash.rb +0 -53
  221. data/lib/lookout/diff/formats/inline.rb +0 -39
  222. data/lib/lookout/diff/formats/unified.rb +0 -57
  223. data/lib/lookout/diff/group.rb +0 -61
  224. data/lib/lookout/diff/groups.rb +0 -34
  225. data/lib/lookout/diff/match.rb +0 -36
  226. data/lib/lookout/diff/operation.rb +0 -33
  227. data/lib/lookout/diff/operations.rb +0 -36
  228. data/lib/lookout/diff/operations/delete.rb +0 -9
  229. data/lib/lookout/diff/operations/equal.rb +0 -27
  230. data/lib/lookout/diff/operations/insert.rb +0 -9
  231. data/lib/lookout/diff/operations/replace.rb +0 -9
  232. data/lib/lookout/diff/range.rb +0 -91
  233. data/lib/lookout/equalities.rb +0 -13
  234. data/lib/lookout/equalities/array.rb +0 -22
  235. data/lib/lookout/equalities/boolean.rb +0 -9
  236. data/lib/lookout/equalities/hash.rb +0 -25
  237. data/lib/lookout/equalities/include.rb +0 -9
  238. data/lib/lookout/equalities/object.rb +0 -24
  239. data/lib/lookout/equalities/output.rb +0 -19
  240. data/lib/lookout/equalities/standarderror.rb +0 -32
  241. data/lib/lookout/equalities/string.rb +0 -19
  242. data/lib/lookout/equalities/warning.rb +0 -16
  243. data/lib/lookout/equality.rb +0 -36
  244. data/lib/lookout/expectation.rb +0 -69
  245. data/lib/lookout/expectations.rb +0 -49
  246. data/lib/lookout/expectations/behavior.rb +0 -20
  247. data/lib/lookout/expectations/line.rb +0 -29
  248. data/lib/lookout/expectations/state.rb +0 -31
  249. data/lib/lookout/expectations/state/warning.rb +0 -26
  250. data/lib/lookout/mock.rb +0 -20
  251. data/lib/lookout/mock/method.rb +0 -70
  252. data/lib/lookout/mock/method/arguments.rb +0 -33
  253. data/lib/lookout/mock/method/arguments/any.rb +0 -11
  254. data/lib/lookout/mock/method/arguments/anything.rb +0 -11
  255. data/lib/lookout/mock/method/arguments/list.rb +0 -15
  256. data/lib/lookout/mock/method/arguments/none.rb +0 -11
  257. data/lib/lookout/mock/method/arguments/one.rb +0 -11
  258. data/lib/lookout/mock/method/calls.rb +0 -11
  259. data/lib/lookout/mock/method/calls/class.rb +0 -21
  260. data/lib/lookout/mock/method/calls/exactly.rb +0 -28
  261. data/lib/lookout/mock/method/calls/instance.rb +0 -25
  262. data/lib/lookout/mock/method/calls/lower.rb +0 -22
  263. data/lib/lookout/mock/method/calls/upper.rb +0 -22
  264. data/lib/lookout/mock/methods.rb +0 -12
  265. data/lib/lookout/mock/object.rb +0 -12
  266. data/lib/lookout/object.rb +0 -11
  267. data/lib/lookout/output.rb +0 -21
  268. data/lib/lookout/rake/tasks.rb +0 -36
  269. data/lib/lookout/rake/tasks/gem.rb +0 -49
  270. data/lib/lookout/rake/tasks/tags.rb +0 -16
  271. data/lib/lookout/rake/tasks/test.rb +0 -46
  272. data/lib/lookout/rake/tasks/test/loader.rb +0 -22
  273. data/lib/lookout/recorder.rb +0 -45
  274. data/lib/lookout/recorder/not.rb +0 -11
  275. data/lib/lookout/recorder/tape.rb +0 -21
  276. data/lib/lookout/recorders.rb +0 -6
  277. data/lib/lookout/recorders/reception.rb +0 -47
  278. data/lib/lookout/recorders/state.rb +0 -35
  279. data/lib/lookout/result.rb +0 -13
  280. data/lib/lookout/results.rb +0 -25
  281. data/lib/lookout/results/error.rb +0 -18
  282. data/lib/lookout/results/error/exception.rb +0 -34
  283. data/lib/lookout/results/error/exception/backtrace.rb +0 -50
  284. data/lib/lookout/results/failure.rb +0 -16
  285. data/lib/lookout/results/failures.rb +0 -6
  286. data/lib/lookout/results/failures/behavior.rb +0 -5
  287. data/lib/lookout/results/failures/state.rb +0 -5
  288. data/lib/lookout/results/fulfilled.rb +0 -5
  289. data/lib/lookout/results/unsuccessful.rb +0 -31
  290. data/lib/lookout/runners.rb +0 -6
  291. data/lib/lookout/runners/console.rb +0 -49
  292. data/lib/lookout/runners/trackers.rb +0 -5
  293. data/lib/lookout/runners/trackers/failure.rb +0 -14
  294. data/lib/lookout/stub.rb +0 -18
  295. data/lib/lookout/stub/method.rb +0 -105
  296. data/lib/lookout/stub/methods.rb +0 -18
  297. data/lib/lookout/stub/object.rb +0 -11
  298. data/lib/lookout/ui.rb +0 -7
  299. data/lib/lookout/ui/console.rb +0 -19
  300. data/lib/lookout/ui/silent.rb +0 -9
  301. data/lib/lookout/version.rb +0 -5
  302. data/lib/lookout/warning.rb +0 -7
  303. data/lib/lookout/xml.rb +0 -17
  304. data/test/unit/lookout/diff/algorithms/difflib.rb +0 -56
  305. data/test/unit/lookout/diff/algorithms/difflib/position.rb +0 -92
  306. data/test/unit/lookout/diff/groups.rb +0 -102
  307. data/test/unit/lookout/diff/operations.rb +0 -22
  308. data/test/unit/lookout/diff/operations/delete.rb +0 -45
  309. data/test/unit/lookout/diff/operations/equal.rb +0 -45
  310. data/test/unit/lookout/diff/operations/insert.rb +0 -45
  311. data/test/unit/lookout/diff/operations/replace.rb +0 -45
  312. data/test/unit/lookout/diff/range.rb +0 -50
  313. data/test/unit/lookout/equality.rb +0 -113
  314. data/test/unit/lookout/expectation.rb +0 -47
  315. data/test/unit/lookout/expectations.rb +0 -36
  316. data/test/unit/lookout/expectations/behavior.rb +0 -35
  317. data/test/unit/lookout/expectations/line.rb +0 -29
  318. data/test/unit/lookout/expectations/state.rb +0 -29
  319. data/test/unit/lookout/mock/method.rb +0 -143
  320. data/test/unit/lookout/mock/method/arguments.rb +0 -57
  321. data/test/unit/lookout/mock/method/arguments/any.rb +0 -11
  322. data/test/unit/lookout/recorder.rb +0 -11
  323. data/test/unit/lookout/results/error/exception/backtrace.rb +0 -20
  324. data/test/unit/lookout/results/unsuccessful.rb +0 -9
  325. data/test/unit/lookout/runners/trackers/failure.rb +0 -30
  326. data/test/unit/lookout/stub/method.rb +0 -48
  327. data/test/unit/lookout/stub/methods.rb +0 -19
  328. data/test/unit/lookout/xml.rb +0 -55
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect NoMethodError.
5
+ new("cannot convert upper reception limit to Integer: undefined method `to_int' for nil:NilClass") do
6
+ Object.new.to.receive.a.at_most(nil)
7
+ end
8
+
9
+ expect ArgumentError.new('upper reception limit must be positive: -1 < 1') do
10
+ Object.new.to.receive.a.at_most(-1)
11
+ end
12
+
13
+ expect ArgumentError.new('upper reception limit must be positive: 0 < 1') do
14
+ Object.new.to.receive.a.at_most(0)
15
+ end
16
+
17
+ expect Lookout::Reception do
18
+ Object.new.to.receive.a.at_most(1)
19
+ end
20
+
21
+ expect ArgumentError.new('expected reception count must be non-negative: -1 < 0') do
22
+ Object.new.to.receive.a.exactly(-1)
23
+ end
24
+
25
+ expect Lookout::Reception do
26
+ Object.new.to.receive.a.exactly(0)
27
+ end
28
+
29
+ expect ArgumentError.new('lower reception limit must be positive: -1 < 1') do
30
+ Object.new.to.receive.a.at_least(-1)
31
+ end
32
+
33
+ expect ArgumentError.new('lower reception limit must be positive: 0 < 1') do
34
+ Object.new.to.receive.a.at_least(0)
35
+ end
36
+
37
+ expect Lookout::Reception do
38
+ Object.new.to.receive.a.at_least(1)
39
+ end
40
+
41
+ expect Lookout::Results::Success.new('test', 1) do
42
+ stub.to.receive.call.to_lookout_expected.expect('test', 1){ |o| o.call }.call
43
+ end
44
+
45
+ expect Lookout::Results::Failure do
46
+ stub.to.receive.call.to_lookout_expected.expect('test', 1).call
47
+ end
48
+
49
+ if RUBY_VERSION < '1.9'
50
+ expect Lookout::Results::Error do
51
+ stub.to.receive.call.to_lookout_expected.expect('test', 1){ raise RuntimeError, 'error', [] }.call
52
+ end
53
+ else
54
+ expect Lookout::Results::Error.new('test', 1, nil, Lookout::Exception.new(RuntimeError.new('error').tap{ |e| e.set_backtrace([]) })) do
55
+ stub.to.receive.call.to_lookout_expected.expect('test', 1){ raise RuntimeError, 'error', [] }.call
56
+ end
57
+ end
58
+
59
+ expect Lookout::Results::Error do
60
+ stub.not.to.receive.call.to_lookout_expected.expect('test', 1){ |o| o.call }.call
61
+ end
62
+
63
+ expect 'stub#call: unexpected number of invocations (1 for 0)' do
64
+ stub.not.to.receive.call.to_lookout_expected.expect('test', 1){ |o| o.call }.call.exception.message
65
+ end
66
+
67
+ expect Lookout::Results::Success.new('test', 1) do
68
+ stub.not.to.receive.call.to_lookout_expected.expect('test', 1).call{ }
69
+ end
70
+
71
+ expect Lookout::Results::Error do
72
+ stub.to.receive.call(1).to_lookout_expected.expect('test', 1){ |o| o.call }.call
73
+ end
74
+
75
+ expect 'stub#call: unexpected arguments: []≠[1]' do
76
+ stub.to.receive.call(1).to_lookout_expected.expect('test', 1){ |o| o.call }.call.exception.message
77
+ end
78
+
79
+ expect Lookout::Results::Error do
80
+ stub.to.receive.call(1).to_lookout_expected.expect('test', 1){ |o| o.call(1, 2) }.call
81
+ end
82
+
83
+ expect 'stub#call: unexpected arguments: [1, 2]≠[1]' do
84
+ stub.to.receive.call(1).to_lookout_expected.expect('test', 1){ |o| o.call(1, 2) }.call.exception.message
85
+ end
86
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect Lookout::Reception::Arguments::Any do
5
+ Lookout::Reception::Arguments.for
6
+ end
7
+
8
+ expect Lookout::Reception::Arguments::Any do
9
+ Lookout::Reception::Arguments.for(1, Lookout::Reception::Arguments::Any.new)
10
+ end
11
+
12
+ expect Lookout::Reception::Arguments::None do
13
+ Lookout::Reception::Arguments.for(Lookout::Reception::Arguments::None.new)
14
+ end
15
+
16
+ expect Lookout::Reception::Arguments::None do
17
+ Lookout::Reception::Arguments.for(1, Lookout::Reception::Arguments::None.new)
18
+ end
19
+
20
+ expect Lookout::Reception::Arguments::List.new(1, 2, 3) do
21
+ Lookout::Reception::Arguments.for(1, 2, 3)
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect '*args, &block' do
5
+ Lookout::Reception::Arguments::Any.new.to_s
6
+ end
7
+
8
+ expect true do
9
+ Lookout::Reception::Arguments::Any.new =~ []
10
+ end
11
+
12
+ expect true do
13
+ Lookout::Reception::Arguments::Any.new =~ [1, 2, 3]
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect true do
5
+ Lookout::Reception::Arguments::List.new(1, Object, 3) =~ [1, 2, 3]
6
+ end
7
+
8
+ expect false do
9
+ Lookout::Reception::Arguments::List.new(1, 4, 3) =~ [1, 2, 3]
10
+ end
11
+
12
+ expect '1, 2, 3' do
13
+ Lookout::Reception::Arguments::List.new(1, 2, 3).to_s
14
+ end
15
+
16
+ expect '1, (cannot inspect argument: error), 3' do
17
+ Lookout::Reception::Arguments::List.new(1, stub(:inspect => proc{ raise 'error' } ), 3).to_s
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect true do
5
+ Lookout::Reception::Arguments::None.new =~ []
6
+ end
7
+
8
+ expect false do
9
+ Lookout::Reception::Arguments::None.new =~ [1, 2, 3]
10
+ end
11
+
12
+ expect '' do
13
+ Lookout::Reception::Arguments::None.new.to_s
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect true do
5
+ Lookout::Results::Success.new('a', 1) == Lookout::Results::Success.new('a', 1)
6
+ end
7
+
8
+ expect false do
9
+ Lookout::Results::Success.new('a', 1) == Lookout::Results::Success.new('a', 2)
10
+ end
11
+
12
+ expect false do
13
+ Lookout::Results::Success.new('a', 1) == Lookout::Results::Success.new('b', 1)
14
+ end
15
+
16
+ expect 'test:1' do
17
+ Lookout::Results::Success.new('test', 1).to_s
18
+ end
19
+
20
+ expect 'test' do
21
+ Lookout::Results::Success.new('test', 1).file
22
+ end
23
+
24
+ expect 1 do
25
+ Lookout::Results::Success.new('test', 1).line
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ # In Ruby 1.8.7, exceptions can’t be compared properly.
5
+ if RuntimeError.new == RuntimeError.new
6
+ expect true do
7
+ Lookout::Results::Error.new('a', 1, nil, Lookout::Exception.new(RuntimeError.new)) ==
8
+ Lookout::Results::Error.new('a', 1, nil, Lookout::Exception.new(RuntimeError.new))
9
+ end
10
+
11
+ expect false do
12
+ Lookout::Results::Error.new('a', 1, nil, Lookout::Exception.new(RuntimeError.new)) ==
13
+ Lookout::Results::Error.new('a', 1, 'a', Lookout::Exception.new(RuntimeError.new))
14
+ end
15
+
16
+ expect false do
17
+ Lookout::Results::Error.new('a', 1, nil, Lookout::Exception.new(RuntimeError.new)) ==
18
+ Lookout::Results::Error.new('a', 1, nil, Lookout::Exception.new(StandardError.new))
19
+ end
20
+
21
+ expect Lookout::Exception.new(RuntimeError.new('error')) do
22
+ Lookout::Results::Error.new('test', 1, 'a≠b', Lookout::Exception.new(RuntimeError.new('error'))).exception
23
+ end
24
+ end
25
+
26
+ expect "test:1: error (RuntimeError)\n" do
27
+ Lookout::Results::Error.new('test', 1, nil, Lookout::Exception.new(RuntimeError.new('error'))).to_s
28
+ end
29
+
30
+ expect "test:1: a≠b: error (RuntimeError)\n" do
31
+ Lookout::Results::Error.new('test', 1, 'a≠b', Lookout::Exception.new(RuntimeError.new('error'))).to_s
32
+ end
33
+
34
+ expect 'a≠b' do
35
+ Lookout::Results::Error.new('test', 1, 'a≠b', Lookout::Exception.new(RuntimeError.new('error'))).message
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect "test:1: 2≠1" do
5
+ Lookout::Results::Failure.new('test', 1, 1.to_lookout_expected.difference(2)).to_s
6
+ end
7
+
8
+ expect 'test:1: "b"≠"a": [-b-]{+a+}' do
9
+ Lookout::Results::Failure.new('test', 1, 'a'.to_lookout_expected.difference('b')).to_s
10
+ end
11
+
12
+ expect <<EOM.chomp do
13
+ test:1: "b\\nc"≠"a"
14
+ @@ -1,2 +1,1 @@
15
+ -b
16
+ -c
17
+ +a
18
+ EOM
19
+ Lookout::Results::Failure.new('test', 1, 'a'.to_lookout_expected.difference("b\nc")).to_s
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect 'stub' do
5
+ Lookout::Stub.new.inspect
6
+ end
7
+
8
+ expect Lookout::Stub.new do |o|
9
+ o.any_old_method
10
+ end
11
+
12
+ expect Lookout::Stub.new do |o|
13
+ o.any_old_method_with_various_arguments(1, [], {})
14
+ end
15
+
16
+ expect Lookout::Stub.new do |o|
17
+ o.any_old_method_with_a_block{ }
18
+ end
19
+
20
+ if proc{ }.respond_to? :lambda?
21
+ expect ArgumentError do
22
+ Lookout::Stub.new(:a => lambda{ 1 }).a(2)
23
+ end
24
+ end
25
+
26
+ expect 1 do
27
+ Lookout::Stub.new(:a => proc{ 1 }).a(2)
28
+ end
29
+
30
+ expect 1 do
31
+ Lookout::Stub.new(:a => proc{ 1 }).a
32
+ end
33
+
34
+ expect 1 do
35
+ Lookout::Stub.new(:a => proc{ |i| i }).a(1)
36
+ end
37
+
38
+ expect 1 do
39
+ Lookout::Stub.new(:a => proc{ |&b| b.call }).a{ 1 }
40
+ end
41
+
42
+ expect 1 do
43
+ Lookout::Stub.new(:a => 1).a
44
+ end
45
+
46
+ expect 1 do
47
+ Lookout::Stub.new(:a => 1).a(2)
48
+ end
49
+
50
+ expect 1 do
51
+ Lookout::Stub.new(:a => 1).a(2){ 3 }
52
+ end
53
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect true do
5
+ Lookout::Warning.new('a') == Lookout::Warning.new('a')
6
+ end
7
+
8
+ expect true do
9
+ Lookout::Warning.new('a') == Lookout::Warning.new("a\n")
10
+ end
11
+
12
+ expect false do
13
+ Lookout::Warning.new('a') == Lookout::Warning.new('b')
14
+ end
15
+
16
+ expect false do
17
+ Lookout::Warning.new('a') == Lookout::Warning.new("b\n")
18
+ end
19
+
20
+ expect true do
21
+ Lookout::Warning.new('a') === Lookout::Warning.new('/a/b/c:1: warning: a')
22
+ end
23
+
24
+ expect true do
25
+ Lookout::Warning.new('a') === Lookout::Warning.new("/a/b/c:1: warning: a\n")
26
+ end
27
+
28
+ expect false do
29
+ Lookout::Warning.new('a') === Lookout::Warning.new('/a/b/c:1: warning: b')
30
+ end
31
+
32
+ expect false do
33
+ Lookout::Warning.new('a') === Lookout::Warning.new("/a/b/c:1: warning: b\n")
34
+ end
35
+
36
+ expect '[-b-]{+a+}' do
37
+ Lookout::Warning.new('a').diff(Lookout::Warning.new("/a/b/c:1: warning: b\n")).to_s
38
+ end
39
+
40
+ expect 'warning("this is your final one!")' do
41
+ Lookout::Warning.new('this is your final one!').inspect
42
+ end
43
+
44
+ expect 'warning("this is your final one!")' do
45
+ Lookout::Warning.new("this is your final one!\n").inspect
46
+ end
47
+ end
metadata CHANGED
@@ -1,478 +1,1183 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
5
- prerelease:
4
+ version: 3.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nikolai Weibull
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-20 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: inventory
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: inventory-rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: inventory-rake-tasks-yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: lookout-rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
14
69
  - !ruby/object:Gem::Dependency
15
70
  name: yard
16
- requirement: &14532168 !ruby/object:Gem::Requirement
17
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard-heuristics
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard-value
99
+ requirement: !ruby/object:Gem::Requirement
18
100
  requirements:
19
101
  - - ~>
20
102
  - !ruby/object:Gem::Version
21
- version: 0.6.0
103
+ version: '1.2'
22
104
  type: :development
23
105
  prerelease: false
24
- version_requirements: *14532168
25
- description: ! " Lookout\n\n Lookout is a lightweight
26
- unit testing framework. Tests (expectations) can be\n written as follows\n\n expect
27
- 2 do\n 1 + 1\n end\n\n expect NoMethodError do\n Object.invalid_method_call\n
28
- \ end\n\n Lookout is designed to encourage – force, even – unit testing best
29
- practices\n such as\n\n• Setting up only one expectation per test\n• Not setting
30
- expectations on non-public APIs\n• Test isolation\n\n This is done by\n\n• Only
31
- allowing one expectation to be set per test\n• Providing no (additonal) way of
32
- accessing private state\n• Providing no setup and teardown methods, nor a method
33
- of providing test\n helpers\n\n Other important points are\n\n• A unified
34
- syntax for setting up both state-based and behavior-based\n expectations\n• A
35
- focus on code readability by providing no mechanism for describing an\n expectation
36
- other than the code in the expectation itself\n\n The way Lookout works has been
37
- heavily influenced by expectations¹, by\n {Jay Fields}². The code base was once
38
- also heavily based on expectations¹,\n based at Subversion {revision 76}³. A lot
39
- has happened since then and all of\n the work past that revision are due to {Nikolai
40
- Weibull}⁴.\n\n¹ Get more information on the expectations library at http://expectations.rubyforge.org/\n²
41
- Read Jay Fields’s blog at http://blog.jayfields.com/\n³ Review Lookout revision
42
- 76 at https://github.com/now/lookout/commit/537bedf3e5b3eb4b31c066b3266f42964ac35ebe\n⁴
43
- Visit Nikolai Weibull’s home page at http://bitwi.se/\n\n§ Installation\n\n Install
44
- Lookout with\n\n % gem install lookout\n\n\n§ Usage\n\n Lookout allows you
45
- to set expectations on an object’s state or behavior.\n We’ll begin by looking
46
- at state expectations and then take a look at\n expectations on behavior.\n\n
47
- \ § Expectations on State\n\n An expectation can be made on the result of a
48
- computation:\n\n expect 2 do\n 1 + 1\n end\n\n Most
49
- objects, in fact, have their state expectations checked by invoking\n ‹#==›
50
- on the expected value with the result as its argument.\n\n Checking that a
51
- result is within a given range is also simple:\n\n expect 0.099..0.101 do\n
52
- \ 0.4 - 0.3\n end\n\n Here, the more general ‹#===› is being
53
- used on the ‹Range›.\n\n ‹Strings› of course match against ‹Strings›:\n\n expect
54
- 'ab' do\n 'abc'[0..1]\n end\n\n but we can also match a ‹String›
55
- against a ‹Regexp›:\n\n expect %r{a substring} do\n 'a string with
56
- a substring'\n end\n\n (Note the use of ‹%r{…}› to avoid warnings that
57
- will be generated when\n Ruby parses ‹expect /…/›.)\n\n Checking that
58
- the result includes a certain module is done by expecting the\n ‹Module›.\n\n
59
- \ expect Enumerable do\n []\n end\n\n This, due to the
60
- nature of Ruby, of course also works for classes (as\n they are also modules):\n\n
61
- \ expect String do\n 'a string'\n end\n\n This doesn’t
62
- hinder us from expecting the actual ‹Module› itself:\n\n expect Enumerable
63
- do\n Enumerable\n end\n\n As you may have figured out yourself,
64
- this is accomplished by first\n trying ‹#==› and, if it returns ‹false›, then
65
- trying ‹#===› on the\n expected ‹Module›. This is also true of ‹Ranges› and
66
- ‹Regexps›.\n\n Truthfulness is expected with ‹true› and ‹false›:\n\n expect
67
- true do\n 1\n end\n\n expect false do\n nil\n end\n\n
68
- \ Results equaling ‹true› or ‹false› are slightly different:\n\n expect
69
- TrueClass do\n true\n end\n\n expect FalseClass do\n false\n
70
- \ end\n\n The rationale for this is that you should only care if the
71
- result of a\n computation evaluates to a value that Ruby considers to be either
72
- true or\n false, not the exact literals ‹true› or ‹false›.\n\n Expecting
73
- output on an IO object is also common:\n\n expect output(\"abc\\ndef\\n\")
74
- do |io|\n io.puts 'abc', 'def'\n end\n\n This can be used to
75
- capture the output of a formatter that takes an\n output object as a parameter.\n\n
76
- \ You should always be expecting errors from and in, but that’s a\n different
77
- story – your code:\n\n expect NoMethodError do\n Object.no_method\n
78
- \ end\n\n Often, not only the type of the error, but its description,
79
- is important\n to check:\n\n expect StandardError.new('message') do\n
80
- \ raise StandardError.new('message')\n end\n\n As with ‹Strings›,
81
- ‹Regexps› can be used to check the error description:\n\n expect StandardError.new(/mess/)
82
- do\n raise StandardError.new('message')\n end\n\n (Note that
83
- some of Ruby’s built-in error classes have slightly\n complicated behavior
84
- and will not allow you to pass a ‹Regexp› as a\n parameter. ‹NameError› is
85
- such a class. This may warrant further\n investigation into whether or not
86
- this is a bug, but I’ll leave that up\n to the reader to decide.)\n\n Lookout
87
- further provides a fluent way of setting up expectations on\n boolean results.
88
- \ An object can “be”\n\n expect Class.new{ attr_accessor :running; }.new.to.be.running
89
- do |process|\n process.running = true\n end\n\n or “not be”\n\n
90
- \ expect Class.new{ attr_accessor :running; }.new.not.to.be.running do |process|\n
91
- \ process.running = false\n end\n\n or to “have”\n\n expect
92
- Class.new{ attr_accessor :finished; }.new.to.have.finished do |process|\n process.finished
93
- = true\n end\n\n or “not have”\n\n expect Class.new{ attr_accessor
94
- :finished; }.new.not.to.have.finished do |process|\n process.finished =
95
- false\n end\n\n On the same note\n\n expect nil.to.be.nil?\n\n
96
- \ and\n\n expect Object.new.not.to.be.nil?\n\n As not every boolean
97
- method “is” or “has” you can even\n\n expect nil.to.respond_to? :nil?\n\n
98
- \ The rules here are that all ‹Objects› respond to ‹#to›. After ‹#to› you\n
99
- \ may call\n\n • ‹#not›\n • ‹#be›\n • ‹#have›\n • Any method
100
- whose name ends with ‹?›\n\n A call to ‹#not› must be followed by a call to
101
- one of the three\n alternatives that follow it in the list. ‹#Be› and ‹#have›
102
- must be\n followed by a call to a method.\n\n § Expectations on Behavior\n\n
103
- \ We expect our objects to be on their best behavior. Lookout allows you\n
104
- \ to make sure that they are.\n\n Mocks let use verify that a method is
105
- called in the way that we expect it\n to be:\n\n expect mock.to.receive.dial('2125551212').twice
106
- do |phone|\n phone.dial('2125551212')\n phone.dial('2125551212')\n
107
- \ end\n\n Here, ‹#mock› creates a mock object, an object that doesn’t
108
- respond to\n anything unless you tell it to. We tell it to expect to receive
109
- a call\n to ‹#dail› with ‹'2125551212'› as its formal argument, and we expect
110
- it\n to receive it twice. The mock object is then passed in to the block so\n
111
- \ that the expectations placed upon it can be fulfilled.\n\n Sometimes
112
- we only want to make sure that a method is called in the way\n that we expect
113
- it to be, but we don’t care if any other methods are\n called on the object.
114
- \ A stub object, created with ‹#stub›, expects any\n method and returns a stub
115
- object that, again, expects any method, and\n thus fits the bill.\n\n expect
116
- stub.to.receive.dial('2125551212').twice do |phone|\n phone.dial('2125551212')\n
117
- \ phone.hangup\n phone.dial('2125551212')\n end\n\n We
118
- can also use stubs without any expectations on them:\n\n expect 3 do\n s
119
- = stub(:a => 1, :b => 2)\n s.a + s.b\n end\n\n Blocks are also
120
- allowed:\n\n expect 3 do\n s = stub(:a => proc{ |a, b| a + b })\n
121
- \ s.a(1, 2)\n end\n\n If need be, we can stub out a specific
122
- method on an object:\n\n expect 'def' do\n a = 'abc'\n stub(a).to_str{
123
- 'def' }\n a.to_str\n end\n\n You don’t have to use a mock object
124
- to verify that a method is called:\n\n expect Object.to.receive.deal do\n
125
- \ Object.deal\n end\n\n As you have figured out by now, the
126
- expected method call is set up by\n calling ‹#receive› after ‹#to›. ‹#Receive›
127
- is followed by a call to the\n method to expect with any expected arguments.
128
- \ The body of the mocked\n method can be given as the block to the method.
129
- \ Finally, an expected\n invocation count may follow the method. Let’s look
130
- at this formal\n specification in more detail.\n\n The expected method
131
- arguments may be given in a variety of ways. Let’s\n introduce them by giving
132
- some examples:\n\n expect mock.to.receive.a do |m|\n …\n end\n\n
133
- \ Here, the method ‹#a› must be called with any number of arguments. It\n may
134
- be called any number of times, but it must be called at least once.\n\n If
135
- a method must receive exactly one argument, you can use ‹arg›:\n\n expect
136
- mock.to.receive.a(arg) do |m|\n …\n end\n\n If a method must
137
- receive a specific argument, you can use that argument:\n\n expect mock.to.receive.a(1..2)
138
- do |m|\n …\n end\n\n The same matching rules apply for arguments
139
- as they do for state\n expectations, so the previous example expects a call
140
- to ‹#a› with 1, 2,\n or the Range 1..2 as an argument on m›.\n\n If a
141
- method must be invoked without any arguments you can use\n ‹without_arguments›:\n\n
142
- \ expect mock.to.receive.a(without_arguments) do |m|\n …\n end\n\n
143
- \ You can of course use both ‹arg› and actual arguments:\n\n expect mock.to.receive.a(arg,
144
- 1, arg) do |m|\n …\n end\n\n The body of the mock method may
145
- be given as the block. Here, calling\n ‹#a› on ‹m› will give the result ‹1›:\n\n
146
- \ expect mock.to.receive.a{ 1 } do |m|\n …\n end\n\n If
147
- no body has been given, the result will be a stub object.\n\n There is a caveat
148
- here in that a block can’t yield in Ruby 1.8. To work\n around this deficiency
149
- you have to use the ‹#yield› method:\n\n expect mock.to.receive.a.yield(1)
150
- do |m|\n …\n end\n\n Any number of values to yield upon successive
151
- calls may be given. The\n last value given will be used repeatedly when all
152
- preceding values have\n been consumed. It’s also important to know that values
153
- are splatted when\n they are yielded.\n\n To simulate an ‹#each›-like
154
- method you can use ‹#each›. The following\n horrible example should give you
155
- an idea of how to use it.\n\n expect Object.new.to.receive.each.each(1, 2,
156
- 3) do |o|\n class << o\n include Enumerable\n end\n
157
- \ o.inject{ |i, a| i + a }\n end\n\n Invocation count expectations
158
- can also be set if the default expectation\n of “at least once” isn’t good
159
- enough. The following expectations are\n possible\n\n • ‹#at_most_once›\n
160
- \ • ‹#once›\n • ‹#at_least_once›\n • ‹#twice›\n\n And, for a
161
- given ‹N›,\n\n • ‹#at_most(N)›\n • ‹#exactly(N)›\n • ‹#at_least(N)›\n\n
162
- \ Method stubs are another useful thing to have in a unit testing\n framework.
163
- \ Sometimes you need to override a method that does something a\n test shouldn’t
164
- do, like access and alter bank accounts. We can override\n – stub out – a
165
- method by using the ‹#stub› method. Let’s assume that we\n have an Account
166
- class that has two methods, ‹#slips› and ‹#total›.\n ‹#Slips› retrieves the
167
- bank slips that keep track of your deposits to the\n ‹Account› from a database.
168
- \ ‹#Total› sums the ‹#slips›. In the following\n test we want to make sure
169
- that ‹#total› does what it should do without\n accessing the database. We
170
- therefore stub out ‹#slips› and make it\n return something that we can easily
171
- control.\n\n expect 6 do |m|\n account = Account.new\n stub(account).slips{
172
- [1, 2, 3] }\n account.total\n end\n\n As with mock methods,
173
- if no body is given, the result will be a stub\n object.\n\n To make it
174
- easy to create objects with a set of stubbed methods there’s\n also a convenience
175
- method:\n\n expect 3 do\n s = stub(:a => 1, :b => 2)\n s.a
176
- + s.b\n end\n\n Please note that this makes it impossible to stub a
177
- method on a Hash, but\n you shouldn’t be doing that anyway. In fact, you should
178
- never mock or\n stub methods on value objects.\n\n§ Integration\n\n Lookout
179
- can be used from Rake¹. Simply include the following code in\n your ‹Rakefile›:\n\n
180
- \ require 'lookout/rake/tasks'\n\n Lookout::Rake::Tasks::Test.new\n\n If
181
- the ‹:default› task hasn’t been defined it will be set to depend on the\n ‹:test›
182
- task.\n\n As an added bonus you can use Lookout’s own gem² tasks:\n\n Lookout::Rake::Tasks::Gem.new\n\n
183
- \ This provides tasks to ‹build›, ‹check›, ‹install›, and ‹push› your gem.\n\n
184
- \ To use Lookout together with Vim³, place ‹contrib/rakelookout.vim› in\n ‹~/.vim/compiler›
185
- and add\n\n compiler rakelookout\n\n to ‹~/.vim/after/ftplugin/ruby.vim›.
186
- \ Executing ‹:make› from inside Vim\n will now run your tests and an errors and
187
- failures can be visited with\n ‹:cnext›. Execute ‹:help quickfix› for additional
188
- information.\n\n Another useful addition to your ‹~/.vim/after/ftplugin/ruby.vim›
189
- file may\n be\n\n nnoremap <buffer> <silent> <Leader>M <Esc>:call <SID>run_test()<CR>\n
190
- \ let b:undo_ftplugin .= ' | nunmap <buffer> <Leader>M'\n\n function! s:run_test()\n
191
- \ let test = expand('%')\n let line = 'LINE=' . line('.')\n if
192
- test =~ '^lib/'\n let test = substitute(test, '^lib/', 'test/', '')\n let
193
- line = \"\"\n endif\n execute 'make' 'TEST=' . shellescape(test) line\n
194
- \ endfunction\n\n Now, pressing ‹<Leader>M› will either run all tests for
195
- a given class, if\n the implementation file is active, or run the test at or
196
- just before the\n cursor, if the test file is active. This is useful if you’re
197
- currently\n receiving a lot of errors and/or failures and want to focus on those\n
198
- \ associated with a specific class or on a specific test.\n\n¹ Read more about
199
- Rake at http://rake.rubyforge.org/\n² Get information on RubyGems at http://rubygems.org/\n³
200
- Find out more about Vim at http://www.vim.org/\n\n§ Interface Design\n\n The
201
- default output of Lookout can Spartanly be described as Spartan. If no\n errors
202
- or failures occur, no output is generated. This is unconventional,\n as unit
203
- testing frameworks tend to dump a lot of information on the user,\n concerning
204
- things such as progress, test count summaries, and flamboyantly\n colored text
205
- telling you that your tests passed. None of this output is\n needed. Your tests
206
- should run fast enough to not require progress reports.\n The lack of output
207
- provides you with the same amount of information as\n reporting success. Test
208
- count summaries are only useful if you’re worried\n that your tests aren’t being
209
- run, but if you worry about that, then\n providing such output doesn’t really
210
- help. Testing your tests requires\n something beyond reporting some arbitrary
211
- count that you would have to\n verify by hand anyway.\n\n When errors or failures
212
- do occur, however, the relevant information is\n output in a format that can
213
- easily be parsed by an ‹'errorformat'› for Vim\n or with {Compilation Mode}¹
214
- for Emacs². Diffs are generated for Strings,\n Arrays, Hashes, and I/O.\n\n¹
215
- Read up on Compilation mode for Emacs at http://www.emacswiki.org/emacs/CompilationMode\n²
216
- Visit The GNU Foundation’s Emacs’ software page at http://www.gnu.org/software/emacs/\n\n§
217
- External Design\n\n Let’s now look at some of the points made in the introduction
218
- in greater\n detail.\n\n Lookout only allows you to set one expectation per
219
- test. If you’re testing\n behavior with a mock, then only one method-invocation
220
- expectation can be\n set. If you’re testing state, then only one result can
221
- be verified. It\n may seem like this would cause unnecessary duplication between
222
- tests.\n While this is certainly a possibility, when you actually begin to try
223
- to\n avoid such duplication you find that you often do so by improving your\n
224
- \ interfaces. This kind of restriction tends to encourage the use of value\n
225
- \ objects, which are easy to test, and more focused objects, which require\n simpler
226
- tests, as they have less behavior to test, per method. By keeping\n your interfaces
227
- focused you’re also keeping your tests focused.\n\n Keeping your tests focused
228
- improves, in itself, test isolation, but let’s\n look at something that hinders
229
- it: setup and teardown methods. Most unit\n testing frameworks encourage test
230
- fragmentation by providing setup and\n teardown methods.\n\n Setup methods
231
- create objects and, perhaps, just their behavior for a set of\n tests. This
232
- means that you have to look in two places to figure out what’s\n being done in
233
- a test. This may work fine for few methods with simple\n set-ups, but makes
234
- things complicated when the number of tests increases\n and the set-up is complex.
235
- \ Often, each test further adjusts the previously\n set-up object before performing
236
- any verifications, further complicating the\n process of figuring out what state
237
- an object has in a given test.\n\n Teardown methods clean up after tests, perhaps
238
- by removing records from a\n database or deleting files from the file-system.
239
- \ \n\n The duplication that setup methods and teardown methods hope to remove
240
- is\n better avoided by improving your interfaces. This can be done by providing\n
241
- \ better set-up methods for your objects and using idioms such as {Resource\n
242
- \ Acquisition Is Initialization}¹ for guaranteed clean-up, test or no test.\n\n
243
- \ By not using setup and teardown methods we keep everything pertinent to a\n
244
- \ test in the test itself, thus improving test isolation. (You also wont\n {slow
245
- down your tests}² by keeping unnecessary state.)\n\n Most unit test frameworks
246
- also allow you to create arbitrary test helper\n methods. Lookout doesn’t. The
247
- same rationale as that that has been\n crystallized in the preceding paragraphs
248
- applies. If you need helpers\n you’re interface isn’t good enough. It really
249
- is as simple as that.\n\n To clarify: there’s nothing inherently wrong with test
250
- helper methods, but\n they should be general enough that they reside in their
251
- own library. The\n support for mocks in Lookout is provided through a set of
252
- test helper\n methods that make it easier to create mocks than it would have
253
- been without\n them. Lookout-rack³ is another example of a library providing
254
- test helper\n methods (well, one of method, actually) that are very useful in
255
- testing web\n applications that use Rack⁴.\n\n A final point at which some
256
- unit test frameworks try to fragment tests\n further is documentation. These
257
- frameworks provide ways of describing the\n whats and hows of what’s being tested,
258
- the rationale being that this will\n provide documentation of both the test and
259
- the code being tested.\n Describing how a stack data structure is meant to work
260
- is a common example.\n A stack is, however, a rather simple data structure, so
261
- such a description\n provides little, if any, additional information that can’t
262
- be extracted\n from the implementation and its tests themselves. The implementation
263
- and\n its tests is, in fact, its own best documentation. Taking the points made\n
264
- \ in the previous paragraphs into account, we should already have simple,\n self-describing,
265
- interfaces that have easily understood tests associated\n with them. Rationales
266
- for the use of a given data structure or\n system-design design documentation
267
- is better suited in separate\n documentation focused at describing exactly those
268
- issues.\n\n¹ Read the Wikipedia entry for Resource Acquisition Is Initialization
269
- at\n http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization\n² Read
270
- how 37signals had problems with slow Test::Unit tests at\n http://37signals.com/svn/posts/2742-the-road-to-faster-tests/\n³
271
- Visit the Lookout-rack GitHub project page at\n http://github.com/now/lookout-rack/\n⁴
272
- Visit the Rack Rubyforge project page at\n http://rack.rubyforge.org/\n\n§ Internal
273
- Design\n\n The internal design of Lookout has had a couple of goals.\n\n • As
274
- few external dependencies as possible\n • As few internal dependencies as possible\n
275
- \ • Internal extensibility provides external extensibility\n • As fast load
276
- times as possible\n • As high a ratio of value objects to mutable objects as
277
- possible\n • Each object must have a simple, obvious name\n • Use mix-ins,
278
- not inheritance for shared behavior\n • As few responsibilities per object as
279
- possible\n • Optimizing for speed can only be done when you have all the facts\n\n§
280
- External Dependencies\n\n Lookout used to depend on Mocha for mocks and stubs.
281
- \ While benchmarking I\n noticed that a method in Mocha was taking up more than
282
- 300 percent of the\n runtime. It turned out that Mocha’s method for cleaning
283
- up back-traces\n generated when a mock failed was doing something incredibly
284
- stupid:\n\n backtrace.reject{ |l| Regexp.new(@lib).match(File.expand_path(l))
285
- }\n\n Here ‹@lib› is a ‹String› containing the path to the lib subdirectory in\n
286
- \ the Mocha installation directory. I reported it, provided a patch five\n days
287
- later, then waited. Nothing happened. {254 days later}¹, according\n to {Wolfram
288
- Alpha}², half of my patch was, apparently – I say “apparently”,\n as I received
289
- no notification – applied. By that time I had replaced the\n whole mocking-and-stubbing
290
- subsystem and dropped the dependency.\n\n Many Ruby developers claim that Ruby
291
- and its gems are too fast-moving for\n normal package-managing systems to keep
292
- up. This is testament to the fact\n that this isn’t the case and that the real
293
- problem is instead related to\n sloppy practices.\n\n Please note that I don’t
294
- want to single out the Mocha library nor its\n developers. I only want to provide
295
- an example where relying on external\n dependencies can be “considered harmful”.\n\n¹
296
- See the Wolfram Alpha calculation at http://www.wolframalpha.com/input/?i=days+between+march+17%2C+2010+and+november+26%2C+2010\n²
297
- Check out the Wolfram Alpha computational knowledge engine at http://www.wolframalpha.com/\n\n§
298
- Internal Dependencies\n\n Lookout has been designed so as to keep each subsystem
299
- independent of any\n other. The diff subsystem is, for example, completely decoupled
300
- from any\n other part of the system as a whole and could be moved into its own
301
- library\n at a time where that would be of interest to anyone. What’s perhaps
302
- more\n interesting is that the diff subsystem is itself very modular. The data\n
303
- \ passes through a set of filters that depends on what kind of diff has been\n
304
- \ requested, each filter yielding modified data as it receives it. If you\n want
305
- to read some rather functional Ruby I can highly recommend looking at\n the code
306
- in the ‹lib/lookout/diff› directory.\n\n This lookout on the design of the library
307
- also makes it easy to extend\n Lookout. Lookout-rack was, for example, written
308
- in about four hours and\n about 5 of those 240 minutes were spent on setting
309
- up the interface between\n the two.\n\n§ Optimizing For Speed\n\n The following
310
- paragraph is perhaps a bit personal, but might be interesting\n nonetheless.\n\n
311
- \ I’ve always worried about speed. The original Expectations library used\n ‹extend›
312
- a lot to add new behavior to objects. Expectations, for example,\n used to hold
313
- the result of their execution (what we now term “evaluation”)\n by being extended
314
- by a module representing success, failure, or error. For\n the longest time
315
- I used this same method, worrying about the increased\n performance cost that
316
- creating new objects for results would incur. I\n finally came to a point where
317
- I felt that the code was so simple and clean\n that rewriting this part of the
318
- code for a benchmark wouldn’t take more\n than perhaps ten minutes. Well, ten
319
- minutes later I had my results and\n they confirmed that creating new objects
320
- wasnt harming performance. I was\n very pleased.\n\n§ Naming\n\n I hate
321
- low lines (underscores). I try to avoid them in method names and I\n always
322
- avoid them in file names. Since the current “best practice” in the\n Ruby community
323
- is to put ‹BeginEndStorage› in a file called\n ‹begin_end_storage.rb›, I only
324
- name constants using a single noun. This\n has had the added benefit that classes
325
- seem to have acquired less behavior,\n as using a single noun doesn’t allow you
326
- to tack on additional behavior\n without questioning if it’s really appropriate
327
- to do so, given the rather\n limited range of interpretation for that noun. It
328
- also seems to encourage\n the creation of value objects, as something named ‹Range
329
- feels a lot more\n like a value than ‹BeginEndStorage›. (To reach object-oriented-programming\n
330
- \ Nirvana you must achieve complete value.)\n\n\n§ Contributors\n\n Contributors
331
- to the original expectations codebase are mentioned there. We\n hope no one
332
- on that list feels left out of this list. Please\n {let us know}¹ if you do.\n\n
333
- \ • Nikolai Weibull\n\n¹ Add an issue to the Lookout issue tracker at https://github.com/now/lookout/issues\n\n\n§
334
- License\n\n You may use, copy, and redistribute this library under the same terms¹\n
335
- \ as Ruby itself.\n\n¹ Read the Ruby licensing terms at http://www.ruby-lang.org/en/LICENSE.txt\n"
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: value
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '1.1'
125
+ description: |2
126
+ Lookout
127
+
128
+ Lookout is a unit testing framework for Ruby¹ that puts your results in
129
+ focus. Tests (expectations) are written as follows
130
+
131
+ expect 2 do
132
+ 1 + 1
133
+ end
134
+
135
+ expect ArgumentError do
136
+ Integer('1 + 1')
137
+ end
138
+
139
+ expect Array do
140
+ [1, 2, 3].select{ |i| i % 2 == 0 }
141
+ end
142
+
143
+ expect [2, 4, 6] do
144
+ [1, 2, 3].map{ |i| i * 2 }
145
+ end
146
+
147
+ Lookout is designed to encourage force, even unit testing best practices
148
+ such as
149
+
150
+ • Setting up only one expectation per test
151
+ • Not setting expectations on non-public APIs
152
+ • Test isolation
153
+
154
+ This is done by
155
+
156
+ • Only allowing one expectation to be set per test
157
+ • Providing no (additional) way of accessing private state
158
+ • Providing no setup and tear-down methods, nor a method of providing test
159
+ helpers
160
+
161
+ Other important points are
162
+
163
+ • Putting the expected outcome of a test in focus with the steps of the
164
+ calculation of the actual result only as a secondary concern
165
+ • A focus on code readability by providing no mechanism for describing an
166
+ expectation other than the code in the expectation itself
167
+ • A unified syntax for setting up both state-based and behavior-based
168
+ expectations
169
+
170
+ The way Lookout works has been heavily influenced by expectations², by
171
+ {Jay Fields}³. The code base was once also heavily based on expectations,
172
+ based at Subversion {revision 76}⁴. A lot has happened since then and all of
173
+ the work past that revision are due to {Nikolai Weibull}⁵.
174
+
175
+ ¹ Ruby: http://ruby-lang.org/
176
+ ² Expectations: http://expectations.rubyforge.org/
177
+ ³ Jay Fields’s blog: http://blog.jayfields.com/
178
+ Lookout revision 76:
179
+ https://github.com/now/lookout/commit/537bedf3e5b3eb4b31c066b3266f42964ac35ebe
180
+ Nikolai Weibull’s home page: http://disu.se/
181
+
182
+ § Installation
183
+
184
+ Install Lookout with
185
+
186
+ % gem install lookout
187
+
188
+
189
+ § Usage
190
+
191
+ Lookout allows you to set expectations on an object’s state or behavior.
192
+ We’ll begin by looking at state expectations and then take a look at
193
+ expectations on behavior.
194
+
195
+ § Expectations on State: Literals
196
+
197
+ An expectation can be made on the result of a computation:
198
+
199
+ expect 2 do
200
+ 1 + 1
201
+ end
202
+
203
+ Most objects, in fact, have their state expectations checked by invoking
204
+ ‹#==› on the expected value with the result as its argument.
205
+
206
+ Checking that a result is within a given range is also simple:
207
+
208
+ expect 0.099..0.101 do
209
+ 0.4 - 0.3
210
+ end
211
+
212
+ Here, the more general ‹#===› is being used on the ‹Range›.
213
+
214
+ § Regexps
215
+
216
+ ‹Strings› of course match against ‹Strings›:
217
+
218
+ expect 'ab' do
219
+ 'abc'[0..1]
220
+ end
221
+
222
+ but we can also match a ‹String› against aRegexp›:
223
+
224
+ expect %r{a substring} do
225
+ 'a string with a substring'
226
+ end
227
+
228
+ (Note the use of ‹%r{…} to avoid warnings that will be generated when
229
+ Ruby parses ‹expect /…/›.)
230
+
231
+ § Modules
232
+
233
+ Checking that the result includes a certain module is done by expecting the
234
+ ‹Module›.
235
+
236
+ expect Enumerable do
237
+ []
238
+ end
239
+
240
+ This, due to the nature of Ruby, of course also works for classes (as
241
+ they are also modules):
242
+
243
+ expect String do
244
+ 'a string'
245
+ end
246
+
247
+ This doesn’t hinder us from expecting the actualModule itself:
248
+
249
+ expect Enumerable do
250
+ Enumerable
251
+ end
252
+
253
+ or the ‹Class›:
254
+
255
+ expect String do
256
+ String
257
+ end
258
+
259
+ for obvious reasons.
260
+
261
+ As you may have figured out yourself, this is accomplished by first
262
+ trying ‹#==› and, if it returns ‹false›, then trying ‹#===› on the
263
+ expected ‹Module›. This is also true of ‹Ranges› and ‹Regexps›.
264
+
265
+ § Booleans
266
+
267
+ Truthfulness is expected with ‹true› and ‹false›:
268
+
269
+ expect true do
270
+ 1
271
+ end
272
+
273
+ expect false do
274
+ nil
275
+ end
276
+
277
+ Results equaling ‹true› or ‹false› are slightly different:
278
+
279
+ expect TrueClass do
280
+ true
281
+ end
282
+
283
+ expect FalseClass do
284
+ false
285
+ end
286
+
287
+ The rationale for this is that you should only care if the result of a
288
+ computation evaluates to a value that Ruby considers to be either true or
289
+ false, not the exact literals ‹true› or ‹false›.
290
+
291
+ § IO
292
+
293
+ Expecting output on an IO object is also common:
294
+
295
+ expect output("abc\ndef\n") do |io|
296
+ io.puts 'abc', 'def'
297
+ end
298
+
299
+ This can be used to capture the output of a formatter that takes an
300
+ output object as a parameter.
301
+
302
+ § Warnings
303
+
304
+ Expecting warnings from code isn’t very common, but should be done:
305
+
306
+ expect warning('this is your final one!') do
307
+ warn 'this is your final one!'
308
+ end
309
+
310
+ expect warning('this is your final one!') do
311
+ warn '%s:%d: warning: this is your final one!' % [__FILE__, __LINE__]
312
+ end
313
+
314
+ ‹$VERBOSE› is set to ‹true› during the execution of the block, so you
315
+ don’t need to do so yourself. If you have other code that depends on the
316
+ value of $VERBOSE, that can be done with ‹#with_verbose›
317
+
318
+ expect nil do
319
+ with_verbose nil do
320
+ $VERBOSE
321
+ end
322
+ end
323
+
324
+ § Errors
325
+
326
+ You should always be expecting errors from and in, but thats a
327
+ different story your code:
328
+
329
+ expect ArgumentError do
330
+ Integer('1 + 1')
331
+ end
332
+
333
+ Often, not only the type of the error, but its description, is important
334
+ to check:
335
+
336
+ expect StandardError.new('message') do
337
+ raise StandardError.new('message')
338
+ end
339
+
340
+ As with ‹Strings›, ‹Regexps› can be used to check the error description:
341
+
342
+ expect StandardError.new(/mess/) do
343
+ raise StandardError.new('message')
344
+ end
345
+
346
+ § Queries Through Symbols
347
+
348
+ Symbols are generally matched against symbols, but as a special case,
349
+ symbols ending with ‹?› are seen as expectations on the result of query
350
+ methods on the result of the block, given that the method is of zero
351
+ arity and that the result isn’t a Symbol itself. Simply expect a symbol
352
+ ending with ‹?›:
353
+
354
+ expect :empty? do
355
+ []
356
+ end
357
+
358
+ To expect it’s negation, expect the same symbol beginning with ‹not_›:
359
+
360
+ expect :not_nil? do
361
+ [1, 2, 3]
362
+ end
363
+
364
+ This is the same as
365
+
366
+ expect true do
367
+ [].empty?
368
+ end
369
+
370
+ and
371
+
372
+ expect false do
373
+ [1, 2, 3].empty?
374
+ end
375
+
376
+ but provides much clearer failure messages. It also makes the
377
+ expectation’s intent a lot clearer.
378
+
379
+ § Queries By Proxy
380
+
381
+ There’s also a way to make the expectations of query methods explicit by
382
+ invoking methods on the result of the block. For example, to check that
383
+ the even elements of the Array ‹[1, 2, 3]› include ‹1› you could write
384
+
385
+ expect result.to.include? 1 do
386
+ [1, 2, 3].reject{ |e| e.even? }
387
+ end
388
+
389
+ You could likewise check that the result doesn’t include 2:
390
+
391
+ expect result.not.to.include? 2 do
392
+ [1, 2, 3].reject{ |e| e.even? }
393
+ end
394
+
395
+ This is the same as (and executes a little bit slower than) writing
396
+
397
+ expect false do
398
+ [1, 2, 3].reject{ |e| e.even? }.include? 2
399
+ end
400
+
401
+ but provides much clearer failure messages. Given that these two last
402
+ examples would fail, youd get a message saying “[1, 2, 3]#include?(2)”
403
+ instead of the terser “true≠false”. It also clearly separates the actual
404
+ expectation from the set-up.
405
+
406
+ The keyword for this kind of expectations is ‹result›. This may be
407
+ followed by any of the methods
408
+
409
+ • ‹#not›
410
+ • ‹#to›
411
+ • ‹#be›
412
+ ‹#have›
413
+
414
+ or any other method you will want to call on the result. The methods
415
+ ‹#to›, ‹#be›, and ‹#have› do nothing except improve readability. The
416
+ ‹#not› method inverts the expectation.
417
+
418
+ § Literal Literals
419
+
420
+ If you need to literally check against any of the types of objects
421
+ otherwise treated specially, that is, any instances of
422
+
423
+ • ‹Module›
424
+ • ‹Range›
425
+ • ‹Regexp›
426
+ • ‹Exception›
427
+ • ‹Symbol›, given that it ends with ‹?›
428
+
429
+ you can do so by wrapping it in ‹literal(…)›:
430
+
431
+ expect literal(:empty?) do
432
+ :empty?
433
+ end
434
+
435
+ You almost never need to do this, as, for all but symbols, instances will
436
+ match accordingly as well.
437
+
438
+ § Expectations on Behavior
439
+
440
+ We expect our objects to be on their best behavior. Lookout allows you
441
+ to make sure that they are.
442
+
443
+ Reception expectations let us verify that a method is called in the way
444
+ that we expect it to be:
445
+
446
+ expect mock.to.receive.to_str(without_arguments){ '123' } do |o|
447
+ o.to_str
448
+ end
449
+
450
+ Here, ‹#mock› creates a mock object, an object that doesn’t respond to
451
+ anything unless you tell it to. We tell it to expect to receive a call
452
+ to ‹#to_str› without arguments and have ‹#to_str› return ‹'123'› when
453
+ called. The mock object is then passed in to the block so that the
454
+ expectations placed upon it can be fulfilled.
455
+
456
+ Sometimes we only want to make sure that a method is called in the way
457
+ that we expect it to be, but we don’t care if any other methods are
458
+ called on the object. A stub object, created with ‹#stub›, expects any
459
+ method and returns a stub object that, again, expects any method, and
460
+ thus fits the bill.
461
+
462
+ expect stub.to.receive.to_str(without_arguments){ '123' } do |o|
463
+ o.to_str if o.convertable?
464
+ end
465
+
466
+ You don’t have to use a mock object to verify that a method is called:
467
+
468
+ expect Object.to.receive.name do
469
+ Object.name
470
+ end
471
+
472
+ As you have figured out by now, the expected method call is set up by
473
+ calling ‹#receive› after ‹#to›. ‹#Receive› is followed by a call to the
474
+ method to expect with any expected arguments. The body of the expected
475
+ method can be given as the block to the method. Finally, an expected
476
+ invocation count may follow the method. Let’s look at this formal
477
+ specification in more detail.
478
+
479
+ The expected method arguments may be given in a variety of ways. Let’s
480
+ introduce them by giving some examples:
481
+
482
+ expect mock.to.receive.a do |m|
483
+ m.a
484
+ end
485
+
486
+ Here, the method ‹#a› must be called with any number of arguments. It
487
+ may be called any number of times, but it must be called at least once.
488
+
489
+ If a method must receive exactly one argument, you can use ‹Object›, as
490
+ the same matching rules apply for arguments as they do for state
491
+ expectations:
492
+
493
+ expect mock.to.receive.a(Object) do |m|
494
+ m.a 0
495
+ end
496
+
497
+ If a method must receive a specific argument, you can use that argument:
498
+
499
+ expect mock.to.receive.a(1..2) do |m|
500
+ m.a 1
501
+ end
502
+
503
+ Again, the same matching rules apply for arguments as they do for state
504
+ expectations, so the previous example expects a call to ‹#a› with 1, 2,
505
+ or the Range 1..2 as an argument on ‹m›.
506
+
507
+ If a method must be invoked without any arguments you can use
508
+ ‹without_arguments›:
509
+
510
+ expect mock.to.receive.a(without_arguments) do |m|
511
+ m.a
512
+ end
513
+
514
+ You can of course use both ‹Object› and actual arguments:
515
+
516
+ expect mock.to.receive.a(Object, 2, Object) do |m|
517
+ m.a nil, 2, '3'
518
+ end
519
+
520
+ The body of the expected method may be given as the block. Here, calling
521
+ ‹#a› on ‹m› will give the result ‹1›:
522
+
523
+ expect mock.to.receive.a{ 1 } do |m|
524
+ raise 'not 1' unless m.a == 1
525
+ end
526
+
527
+ If no body has been given, the result will be a stub object.
528
+
529
+ To take a block, grab a block parameter and ‹#call› it:
530
+
531
+ expect mock.to.receive.a{ |&b| b.call(1) } do |m|
532
+ j = 0
533
+ m.a{ |i| j = i }
534
+ raise 'not 1' unless j == 1
535
+ end
536
+
537
+ To simulate an ‹#each›-like method, ‹#call› the block several times.
538
+
539
+ Invocation count expectations can be set if the default expectation of
540
+ “at least once” isn’t good enough. The following expectations are
541
+ possible
542
+
543
+ • ‹#at_most_once›
544
+ • ‹#once›
545
+ • ‹#at_least_once›
546
+ • ‹#twice›
547
+
548
+ And, for a given ‹N›,
549
+
550
+ • ‹#at_most(N)›
551
+ • ‹#exactly(N)›
552
+ • ‹#at_least(N)›
553
+
554
+ § Utilities: Stubs
555
+
556
+ Method stubs are another useful thing to have in a unit testing
557
+ framework. Sometimes you need to override a method that does something a
558
+ test shouldn’t do, like access and alter bank accounts. We can override
559
+ – stub out – a method by using the ‹#stub› method. Let’s assume that we
560
+ have an ‹Account› class that has two methods, ‹#slips› and ‹#total›.
561
+ ‹#Slips› retrieves the bank slips that keep track of your deposits to the
562
+ ‹Account› from a database. ‹#Total› sums the ‹#slips›. In the following
563
+ test we want to make sure that ‹#total› does what it should do without
564
+ accessing the database. We therefore stub out ‹#slips› and make it
565
+ return something that we can easily control.
566
+
567
+ expect 6 do |m|
568
+ stub(Class.new{
569
+ def slips
570
+ raise 'database not available'
571
+ end
572
+
573
+ def total
574
+ slips.reduce(0){ |m, n| m.to_i + n.to_i }
575
+ end
576
+ }.new, :slips => [1, 2, 3]){ |account| account.total }
577
+ end
578
+
579
+ To make it easy to create objects with a set of stubbed methods there’s
580
+ also a convenience method:
581
+
582
+ expect 3 do
583
+ s = stub(:a => 1, :b => 2)
584
+ s.a + s.b
585
+ end
586
+
587
+ This short-hand notation can also be used for the expected value:
588
+
589
+ expect stub(:a => 1, :b => 2).to.receive.a do |o|
590
+ o.a + o.b
591
+ end
592
+
593
+ and also works for mock objects:
594
+
595
+ expect mock(:a => 2, :b => 2).to.receive.a do |o|
596
+ o.a + o.b
597
+ end
598
+
599
+ Blocks are also allowed when defining stub methods:
600
+
601
+ expect 3 do
602
+ s = stub(:a => proc{ |a, b| a + b })
603
+ s.a(1, 2)
604
+ end
605
+
606
+ If need be, we can stub out a specific method on an object:
607
+
608
+ expect 'def' do
609
+ stub('abc', :to_str => 'def'){ |a| a.to_str }
610
+ end
611
+
612
+ The stub is active during the execution of the block.
613
+
614
+ § Overriding Constants
615
+
616
+ Sometimes you need to override the value of a constant during the
617
+ execution of some code. Use ‹#with_const› to do just that:
618
+
619
+ expect 'hello' do
620
+ with_const 'A::B::C', 'hello' do
621
+ A::B::C
622
+ end
623
+ end
624
+
625
+ Here, the constant ‹A::B::C› is set to ‹'hello'› during the execution of
626
+ the block. None of the constants ‹A›, ‹B›, and ‹C› need to exist for
627
+ this to work. If a constant doesn’t exist it’s created and set to a new,
628
+ empty, ‹Module›. The value of ‹A::B::C›, if any, is restored after the
629
+ block returns and any constants that didn’t previously exist are removed.
630
+
631
+ § Overriding Environment Variables
632
+
633
+ Another thing you often need to control in your tests is the value of
634
+ environment variables. Depending on such global values is, of course,
635
+ not a good practice, but is often unavoidable when working with external
636
+ libraries. ‹#With_env› allows you to override the value of environment
637
+ variables during the execution of a block by giving it a ‹Hash› of
638
+ key/value pairs where the key is the name of the environment variable and
639
+ the value is the value that it should have during the execution of that
640
+ block:
641
+
642
+ expect 'hello' do
643
+ with_env 'INTRO' => 'hello' do
644
+ ENV['INTRO']
645
+ end
646
+ end
647
+
648
+ Any overridden values are restored and any keys that weren’t previously a
649
+ part of the environment are removed when the block returns.
650
+
651
+ § Overriding Globals
652
+
653
+ You may also want to override the value of a global temporarily:
654
+
655
+ expect 'hello' do
656
+ with_global :$stdout, StringIO.new do
657
+ print 'hello'
658
+ $stdout.string
659
+ end
660
+ end
661
+
662
+ You thus provide the name of the global and a value that it should take
663
+ during the execution of a block of code. The block gets passed the
664
+ overridden value, should you need it:
665
+
666
+ expect true do
667
+ with_global :$stdout, StringIO.new do |overridden|
668
+ $stdout != overridden
669
+ end
670
+ end
671
+
672
+ § Integration
673
+
674
+ Lookout can be used from Rake¹. Simply install Lookout-Rake²:
675
+
676
+ % gem install lookout-rake
677
+
678
+ and add the following code to your Rakefile
679
+
680
+ require 'lookout-rake-3.0'
681
+
682
+ Lookout::Rake::Tasks::Test.new
683
+
684
+ Make sure to read up on using Lookout-Rake for further benefits and
685
+ customization.
686
+
687
+ ¹ Read more about Rake at http://rake.rubyforge.org/
688
+ ² Get information on Lookout-Rake at http://disu.se/software/lookout-rake/
689
+
690
+ § API
691
+
692
+ Lookout comes with an API¹ that let’s you create things such as new
693
+ expected values, difference reports for your types, and so on.
694
+
695
+ ¹ See http://disu.se/software/lookout/api/
696
+
697
+ § Interface Design
698
+
699
+ The default output of Lookout can Spartanly be described as Spartan. If no
700
+ errors or failures occur, no output is generated. This is unconventional,
701
+ as unit testing frameworks tend to dump a lot of information on the user,
702
+ concerning things such as progress, test count summaries, and flamboyantly
703
+ colored text telling you that your tests passed. None of this output is
704
+ needed. Your tests should run fast enough to not require progress reports.
705
+ The lack of output provides you with the same amount of information as
706
+ reporting success. Test count summaries are only useful if you’re worried
707
+ that your tests aren’t being run, but if you worry about that, then
708
+ providing such output doesn’t really help. Testing your tests requires
709
+ something beyond reporting some arbitrary count that you would have to
710
+ verify by hand anyway.
711
+
712
+ When errors or failures do occur, however, the relevant information is
713
+ output in a format that can easily be parsed by an ‹'errorformat'› for Vim
714
+ or with {Compilation Mode}¹ for Emacs². Diffs are generated for Strings,
715
+ Arrays, Hashes, and I/O.
716
+
717
+ ¹ Read up on Compilation mode for Emacs at http://www.emacswiki.org/emacs/CompilationMode
718
+ ² Visit The GNU Foundation’s Emacs’ software page at http://www.gnu.org/software/emacs/
719
+
720
+ § External Design
721
+
722
+ Let’s now look at some of the points made in the introduction in greater
723
+ detail.
724
+
725
+ Lookout only allows you to set one expectation per test. If you’re testing
726
+ behavior with a reception expectation, then only one method-invocation
727
+ expectation can be set. If you’re testing state, then only one result can
728
+ be verified. It may seem like this would cause unnecessary duplication
729
+ between tests. While this is certainly a possibility, when you actually
730
+ begin to try to avoid such duplication you find that you often do so by
731
+ improving your interfaces. This kind of restriction tends to encourage the
732
+ use of value objects, which are easy to test, and more focused objects,
733
+ which require simpler tests, as they have less behavior to test, per
734
+ method. By keeping your interfaces focused you’re also keeping your tests
735
+ focused.
736
+
737
+ Keeping your tests focused improves, in itself, test isolation, but let’s
738
+ look at something that hinders it: setup and tear-down methods. Most unit
739
+ testing frameworks encourage test fragmentation by providing setup and
740
+ tear-down methods.
741
+
742
+ Setup methods create objects and, perhaps, just their behavior for a set of
743
+ tests. This means that you have to look in two places to figure out what’s
744
+ being done in a test. This may work fine for few methods with simple
745
+ set-ups, but makes things complicated when the number of tests increases
746
+ and the set-up is complex. Often, each test further adjusts the previously
747
+ set-up object before performing any verifications, further complicating the
748
+ process of figuring out what state an object has in a given test.
749
+
750
+ Tear-down methods clean up after tests, perhaps by removing records from a
751
+ database or deleting files from the file-system.
752
+
753
+ The duplication that setup methods and tear-down methods hope to remove is
754
+ better avoided by improving your interfaces. This can be done by providing
755
+ better set-up methods for your objects and using idioms such as {Resource
756
+ Acquisition Is Initialization}¹ for guaranteed clean-up, test or no test.
757
+
758
+ By not using setup and tear-down methods we keep everything pertinent to a
759
+ test in the test itself, thus improving test isolation. (You also won’t
760
+ {slow down your tests}² by keeping unnecessary state.)
761
+
762
+ Most unit test frameworks also allow you to create arbitrary test helper
763
+ methods. Lookout doesn’t. The same rationale as that that has been
764
+ crystallized in the preceding paragraphs applies. If you need helpers
765
+ you’re interface isn’t good enough. It really is as simple as that.
766
+
767
+ To clarify: there’s nothing inherently wrong with test helper methods, but
768
+ they should be general enough that they reside in their own library. The
769
+ support for mocks in Lookout is provided through a set of test helper
770
+ methods that make it easier to create mocks than it would have been without
771
+ them. Lookout-rack³ is another example of a library providing test helper
772
+ methods (well, one method, actually) that are very useful in testing web
773
+ applications that use Rack⁴.
774
+
775
+ A final point at which some unit test frameworks try to fragment tests
776
+ further is documentation. These frameworks provide ways of describing the
777
+ whats and hows of what’s being tested, the rationale being that this will
778
+ provide documentation of both the test and the code being tested.
779
+ Describing how a stack data structure is meant to work is a common example.
780
+ A stack is, however, a rather simple data structure, so such a description
781
+ provides little, if any, additional information that can’t be extracted
782
+ from the implementation and its tests themselves. The implementation and
783
+ its tests is, in fact, its own best documentation. Taking the points made
784
+ in the previous paragraphs into account, we should already have simple,
785
+ self-describing, interfaces that have easily understood tests associated
786
+ with them. Rationales for the use of a given data structure or
787
+ system-design design documentation is better suited in separate
788
+ documentation focused at describing exactly those issues.
789
+
790
+ ¹ Read the Wikipedia entry for Resource Acquisition Is Initialization at
791
+ http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
792
+ ² Read how 37signals had problems with slow Test::Unit tests at
793
+ http://37signals.com/svn/posts/2742-the-road-to-faster-tests/
794
+ ³ Visit the Lookout-rack GitHub project page at
795
+ http://github.com/now/lookout-rack/
796
+ ⁴ Visit the Rack Rubyforge project page at
797
+ http://rack.rubyforge.org/
798
+
799
+ § Internal Design
800
+
801
+ The internal design of Lookout has had a couple of goals.
802
+
803
+ • As few external dependencies as possible
804
+ • As few internal dependencies as possible
805
+ • Internal extensibility provides external extensibility
806
+ • As fast load times as possible
807
+ • As high a ratio of value objects to mutable objects as possible
808
+ • Each object must have a simple, obvious name
809
+ • Use mix-ins, not inheritance for shared behavior
810
+ • As few responsibilities per object as possible
811
+ • Optimizing for speed can only be done when you have all the facts
812
+
813
+ § External Dependencies
814
+
815
+ Lookout used to depend on Mocha for mocks and stubs. While benchmarking I
816
+ noticed that a method in Mocha was taking up more than 300 percent of the
817
+ runtime. It turned out that Mocha’s method for cleaning up back-traces
818
+ generated when a mock failed was doing something incredibly stupid:
819
+
820
+ backtrace.reject{ |l| Regexp.new(@lib).match(File.expand_path(l)) }
821
+
822
+ Here ‹@lib› is a ‹String› containing the path to the lib sub-directory in
823
+ the Mocha installation directory. I reported it, provided a patch five
824
+ days later, then waited. Nothing happened. {254 days later}¹, according
825
+ to {Wolfram Alpha}², half of my patch was, apparently – I say “apparently”,
826
+ as I received no notification – applied. By that time I had replaced the
827
+ whole mocking-and-stubbing subsystem and dropped the dependency.
828
+
829
+ Many Ruby developers claim that Ruby and its gems are too fast-moving for
830
+ normal package-managing systems to keep up. This is testament to the fact
831
+ that this isn’t the case and that the real problem is instead related to
832
+ sloppy practices.
833
+
834
+ Please note that I don’t want to single out the Mocha library nor its
835
+ developers. I only want to provide an example where relying on external
836
+ dependencies can be “considered harmful”.
837
+
838
+ ¹ See the Wolfram Alpha calculation at http://www.wolframalpha.com/input/?i=days+between+march+17%2C+2010+and+november+26%2C+2010
839
+ ² Check out the Wolfram Alpha computational knowledge engine at http://www.wolframalpha.com/
840
+
841
+ § Internal Dependencies
842
+
843
+ Lookout has been designed so as to keep each subsystem independent of any
844
+ other. The diff subsystem is, for example, completely decoupled from any
845
+ other part of the system as a whole and could be moved into its own library
846
+ at a time where that would be of interest to anyone. What’s perhaps more
847
+ interesting is that the diff subsystem is itself very modular. The data
848
+ passes through a set of filters that depends on what kind of diff has been
849
+ requested, each filter yielding modified data as it receives it. If you
850
+ want to read some rather functional Ruby I can highly recommend looking at
851
+ the code in the ‹lib/lookout/diff› directory.
852
+
853
+ This lookout on the design of the library also makes it easy to extend
854
+ Lookout. Lookout-rack was, for example, written in about four hours and
855
+ about 5 of those 240 minutes were spent on setting up the interface between
856
+ the two.
857
+
858
+ § Optimizing For Speed
859
+
860
+ The following paragraph is perhaps a bit personal, but might be interesting
861
+ nonetheless.
862
+
863
+ I’ve always worried about speed. The original Expectations library used
864
+ ‹extend› a lot to add new behavior to objects. Expectations, for example,
865
+ used to hold the result of their execution (what we now term “evaluation”)
866
+ by being extended by a module representing success, failure, or error. For
867
+ the longest time I used this same method, worrying about the increased
868
+ performance cost that creating new objects for results would incur. I
869
+ finally came to a point where I felt that the code was so simple and clean
870
+ that rewriting this part of the code for a benchmark wouldn’t take more
871
+ than perhaps ten minutes. Well, ten minutes later I had my results and
872
+ they confirmed that creating new objects wasn’t harming performance. I was
873
+ very pleased.
874
+
875
+ § Naming
876
+
877
+ I hate low lines (underscores). I try to avoid them in method names and I
878
+ always avoid them in file names. Since the current “best practice” in the
879
+ Ruby community is to put ‹BeginEndStorage› in a file called
880
+ ‹begin_end_storage.rb›, I only name constants using a single noun. This
881
+ has had the added benefit that classes seem to have acquired less behavior,
882
+ as using a single noun doesn’t allow you to tack on additional behavior
883
+ without questioning if it’s really appropriate to do so, given the rather
884
+ limited range of interpretation for that noun. It also seems to encourage
885
+ the creation of value objects, as something named ‹Range› feels a lot more
886
+ like a value than ‹BeginEndStorage›. (To reach object-oriented-programming
887
+ Nirvana you must achieve complete value.)
888
+
889
+ § News
890
+
891
+ § 3.0.0
892
+
893
+ The ‹xml› expectation has been dropped. It wasn’t documented, didn’t
894
+ suit very many use cases, and can be better implemented by an external
895
+ library.
896
+
897
+ The ‹arg› argument matcher for mock method arguments has been removed, as
898
+ it didn’t provide any benefit over using Object.
899
+
900
+ The ‹#yield› and ‹#each› methods on stub and mock methods have been
901
+ removed. They were slightly weird and their use case can be implemented
902
+ using block parameters instead.
903
+
904
+ The ‹stub› method inside ‹expect› blocks now stubs out the methods during
905
+ the execution of a provided block instead of during the execution of the
906
+ whole except block.
907
+
908
+ When a mock method is called too many times, this is reported
909
+ immediately, with a full backtrace. This makes it easier to pin down
910
+ what’s wrong with the code.
911
+
912
+ Query expectations were added.
913
+
914
+ Explicit query expectations were added.
915
+
916
+ Fluent boolean expectations, for example, ‹expect nil.to.be.nil?› have
917
+ been replaced by query expectations (‹expect :nil? do nil end›) and
918
+ explicit query expectations (‹expect result.to.be.nil? do nil end›).
919
+ This was done to discourage creating objects as the expected value and
920
+ creating objects that change during the course of the test.
921
+
922
+ The ‹literal› expectation was added.
923
+
924
+ Equality (‹#==›) is now checked before “caseity” (‹#===›) for modules,
925
+ ranges, and regular expressions to match the documentation.
926
+
927
+ § Financing
928
+
929
+ Currently, most of my time is spent at my day job and in my rather busy
930
+ private life. Please motivate me to spend time on this piece of software
931
+ by donating some of your money to this project. Yeah, I realize that
932
+ requesting money to develop software is a bit, well, capitalistic of me.
933
+ But please realize that I live in a capitalistic society and I need money
934
+ to have other people give me the things that I need to continue living
935
+ under the rules of said society. So, if you feel that this piece of
936
+ software has helped you out enough to warrant a reward, please PayPal a
937
+ donation to now@disu.se¹. Thanks! Your support won’t go unnoticed!
938
+
939
+ ¹ Send a donation:
940
+ https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Nikolai%20Weibull%20Software%20Services
941
+
942
+ § Reporting Bugs
943
+
944
+ Please report any bugs that you encounter to the {issue tracker}¹.
945
+
946
+ ¹ See https://github.com/now/lookout/issues
947
+
948
+ § Contributors
949
+
950
+ Contributors to the original expectations codebase are mentioned there. We
951
+ hope no one on that list feels left out of this list. Please
952
+ {let us know}¹ if you do.
953
+
954
+ • Nikolai Weibull
955
+
956
+ ¹ Add an issue to the Lookout issue tracker at https://github.com/now/lookout/issues
957
+
958
+ § License
959
+
960
+ You may use, copy, and redistribute this library under the same terms¹
961
+ as Ruby itself.
962
+
963
+ ¹ Read the Ruby licensing terms at http://www.ruby-lang.org/en/LICENSE.txt
336
964
  email: now@bitwi.se
337
965
  executables: []
338
966
  extensions: []
339
967
  extra_rdoc_files: []
340
968
  files:
341
- - lib/lookout/aphonic.rb
342
- - lib/lookout/diff/algorithms/difflib/position/to.rb
343
- - lib/lookout/diff/algorithms/difflib/position.rb
344
- - lib/lookout/diff/algorithms/difflib.rb
345
- - lib/lookout/diff/algorithms.rb
346
- - lib/lookout/diff/formats/hash.rb
347
- - lib/lookout/diff/formats/inline.rb
348
- - lib/lookout/diff/formats/unified.rb
349
- - lib/lookout/diff/formats.rb
350
- - lib/lookout/diff/group.rb
351
- - lib/lookout/diff/groups.rb
352
- - lib/lookout/diff/match.rb
353
- - lib/lookout/diff/operation.rb
354
- - lib/lookout/diff/operations/delete.rb
355
- - lib/lookout/diff/operations/equal.rb
356
- - lib/lookout/diff/operations/insert.rb
357
- - lib/lookout/diff/operations/replace.rb
358
- - lib/lookout/diff/operations.rb
359
- - lib/lookout/diff/range.rb
360
- - lib/lookout/diff.rb
361
- - lib/lookout/equalities/array.rb
362
- - lib/lookout/equalities/boolean.rb
363
- - lib/lookout/equalities/hash.rb
364
- - lib/lookout/equalities/include.rb
365
- - lib/lookout/equalities/object.rb
366
- - lib/lookout/equalities/output.rb
367
- - lib/lookout/equalities/standarderror.rb
368
- - lib/lookout/equalities/string.rb
369
- - lib/lookout/equalities/warning.rb
370
- - lib/lookout/equalities.rb
371
- - lib/lookout/equality.rb
372
- - lib/lookout/expectation.rb
373
- - lib/lookout/expectations/behavior.rb
374
- - lib/lookout/expectations/line.rb
375
- - lib/lookout/expectations/state/warning.rb
376
- - lib/lookout/expectations/state.rb
377
- - lib/lookout/expectations.rb
378
- - lib/lookout/mock/method/arguments/any.rb
379
- - lib/lookout/mock/method/arguments/anything.rb
380
- - lib/lookout/mock/method/arguments/list.rb
381
- - lib/lookout/mock/method/arguments/none.rb
382
- - lib/lookout/mock/method/arguments/one.rb
383
- - lib/lookout/mock/method/arguments.rb
384
- - lib/lookout/mock/method/calls/class.rb
385
- - lib/lookout/mock/method/calls/exactly.rb
386
- - lib/lookout/mock/method/calls/instance.rb
387
- - lib/lookout/mock/method/calls/lower.rb
388
- - lib/lookout/mock/method/calls/upper.rb
389
- - lib/lookout/mock/method/calls.rb
390
- - lib/lookout/mock/method.rb
391
- - lib/lookout/mock/methods.rb
392
- - lib/lookout/mock/object.rb
393
- - lib/lookout/mock.rb
394
- - lib/lookout/object.rb
395
- - lib/lookout/output.rb
396
- - lib/lookout/rake/tasks/gem.rb
397
- - lib/lookout/rake/tasks/tags.rb
398
- - lib/lookout/rake/tasks/test/loader.rb
399
- - lib/lookout/rake/tasks/test.rb
400
- - lib/lookout/rake/tasks.rb
401
- - lib/lookout/recorder/not.rb
402
- - lib/lookout/recorder/tape.rb
403
- - lib/lookout/recorder.rb
404
- - lib/lookout/recorders/reception.rb
405
- - lib/lookout/recorders/state.rb
406
- - lib/lookout/recorders.rb
407
- - lib/lookout/result.rb
408
- - lib/lookout/results/error/exception/backtrace.rb
409
- - lib/lookout/results/error/exception.rb
410
- - lib/lookout/results/error.rb
411
- - lib/lookout/results/failure.rb
412
- - lib/lookout/results/failures/behavior.rb
413
- - lib/lookout/results/failures/state.rb
414
- - lib/lookout/results/failures.rb
415
- - lib/lookout/results/fulfilled.rb
416
- - lib/lookout/results/unsuccessful.rb
417
- - lib/lookout/results.rb
418
- - lib/lookout/runners/console.rb
419
- - lib/lookout/runners/trackers/failure.rb
420
- - lib/lookout/runners/trackers.rb
421
- - lib/lookout/runners.rb
422
- - lib/lookout/stub/method.rb
423
- - lib/lookout/stub/methods.rb
424
- - lib/lookout/stub/object.rb
425
- - lib/lookout/stub.rb
426
- - lib/lookout/ui/console.rb
427
- - lib/lookout/ui/silent.rb
428
- - lib/lookout/ui.rb
429
- - lib/lookout/version.rb
430
- - lib/lookout/warning.rb
431
- - lib/lookout/xml.rb
432
- - lib/lookout.rb
969
+ - lib/lookout-3.0/object.rb
970
+ - lib/lookout-3.0/aphonic.rb
971
+ - lib/lookout-3.0/actual.rb
972
+ - lib/lookout-3.0/actual/method.rb
973
+ - lib/lookout-3.0/actual/not.rb
974
+ - lib/lookout-3.0/actual/not/method.rb
975
+ - lib/lookout-3.0/diff.rb
976
+ - lib/lookout-3.0/diff/slice.rb
977
+ - lib/lookout-3.0/diff/algorithms.rb
978
+ - lib/lookout-3.0/diff/algorithms/difflib.rb
979
+ - lib/lookout-3.0/diff/algorithms/difflib/position.rb
980
+ - lib/lookout-3.0/diff/algorithms/difflib/position/new.rb
981
+ - lib/lookout-3.0/diff/formats.rb
982
+ - lib/lookout-3.0/diff/formats/inline.rb
983
+ - lib/lookout-3.0/diff/formats/set.rb
984
+ - lib/lookout-3.0/diff/formats/unified.rb
985
+ - lib/lookout-3.0/diff/group.rb
986
+ - lib/lookout-3.0/diff/groups.rb
987
+ - lib/lookout-3.0/diff/match.rb
988
+ - lib/lookout-3.0/diff/operation.rb
989
+ - lib/lookout-3.0/diff/operations.rb
990
+ - lib/lookout-3.0/diff/operations/delete.rb
991
+ - lib/lookout-3.0/diff/operations/copy.rb
992
+ - lib/lookout-3.0/diff/operations/insert.rb
993
+ - lib/lookout-3.0/diff/operations/replace.rb
994
+ - lib/lookout-3.0/difference.rb
995
+ - lib/lookout-3.0/difference/object.rb
996
+ - lib/lookout-3.0/difference/array.rb
997
+ - lib/lookout-3.0/difference/exception.rb
998
+ - lib/lookout-3.0/difference/hash.rb
999
+ - lib/lookout-3.0/difference/range.rb
1000
+ - lib/lookout-3.0/difference/lookout.rb
1001
+ - lib/lookout-3.0/difference/lookout/actual.rb
1002
+ - lib/lookout-3.0/difference/lookout/actual/method.rb
1003
+ - lib/lookout-3.0/difference/lookout/actual/not.rb
1004
+ - lib/lookout-3.0/difference/lookout/actual/not/method.rb
1005
+ - lib/lookout-3.0/difference/lookout/output.rb
1006
+ - lib/lookout-3.0/difference/lookout/reception.rb
1007
+ - lib/lookout-3.0/difference/lookout/warning.rb
1008
+ - lib/lookout-3.0/difference/module.rb
1009
+ - lib/lookout-3.0/difference/regexp.rb
1010
+ - lib/lookout-3.0/difference/string.rb
1011
+ - lib/lookout-3.0/difference/symbol.rb
1012
+ - lib/lookout-3.0/encode.rb
1013
+ - lib/lookout-3.0/exception.rb
1014
+ - lib/lookout-3.0/exception/backtrace.rb
1015
+ - lib/lookout-3.0/exception/unknown.rb
1016
+ - lib/lookout-3.0/expect.rb
1017
+ - lib/lookout-3.0/expect/object.rb
1018
+ - lib/lookout-3.0/expect/object/context.rb
1019
+ - lib/lookout-3.0/expect/classes.rb
1020
+ - lib/lookout-3.0/expect/classes/exception.rb
1021
+ - lib/lookout-3.0/expect/exception.rb
1022
+ - lib/lookout-3.0/expected.rb
1023
+ - lib/lookout-3.0/expected/object.rb
1024
+ - lib/lookout-3.0/expected/array.rb
1025
+ - lib/lookout-3.0/expected/classes.rb
1026
+ - lib/lookout-3.0/expected/classes/exception.rb
1027
+ - lib/lookout-3.0/expected/exception.rb
1028
+ - lib/lookout-3.0/expected/falseclass.rb
1029
+ - lib/lookout-3.0/expected/hash.rb
1030
+ - lib/lookout-3.0/expected/lookout.rb
1031
+ - lib/lookout-3.0/expected/lookout/actual.rb
1032
+ - lib/lookout-3.0/expected/lookout/actual/method.rb
1033
+ - lib/lookout-3.0/expected/lookout/actual/not.rb
1034
+ - lib/lookout-3.0/expected/lookout/actual/not/method.rb
1035
+ - lib/lookout-3.0/expected/lookout/output.rb
1036
+ - lib/lookout-3.0/expected/lookout/reception.rb
1037
+ - lib/lookout-3.0/expected/lookout/warning.rb
1038
+ - lib/lookout-3.0/expected/module.rb
1039
+ - lib/lookout-3.0/expected/range.rb
1040
+ - lib/lookout-3.0/expected/regexp.rb
1041
+ - lib/lookout-3.0/expected/string.rb
1042
+ - lib/lookout-3.0/expected/symbol.rb
1043
+ - lib/lookout-3.0/expected/trueclass.rb
1044
+ - lib/lookout-3.0/expectations.rb
1045
+ - lib/lookout-3.0/expectations/context.rb
1046
+ - lib/lookout-3.0/inspect.rb
1047
+ - lib/lookout-3.0/interfaces.rb
1048
+ - lib/lookout-3.0/interfaces/commandline.rb
1049
+ - lib/lookout-3.0/literal.rb
1050
+ - lib/lookout-3.0/stub.rb
1051
+ - lib/lookout-3.0/mock.rb
1052
+ - lib/lookout-3.0/output.rb
1053
+ - lib/lookout-3.0/plugins.rb
1054
+ - lib/lookout-3.0/reception.rb
1055
+ - lib/lookout-3.0/reception/arguments.rb
1056
+ - lib/lookout-3.0/reception/arguments/any.rb
1057
+ - lib/lookout-3.0/reception/arguments/error.rb
1058
+ - lib/lookout-3.0/reception/arguments/list.rb
1059
+ - lib/lookout-3.0/reception/arguments/none.rb
1060
+ - lib/lookout-3.0/reception/error.rb
1061
+ - lib/lookout-3.0/object/not.rb
1062
+ - lib/lookout-3.0/object/not/receive.rb
1063
+ - lib/lookout-3.0/object/to.rb
1064
+ - lib/lookout-3.0/object/to/receive.rb
1065
+ - lib/lookout-3.0/result.rb
1066
+ - lib/lookout-3.0/results.rb
1067
+ - lib/lookout-3.0/results/error.rb
1068
+ - lib/lookout-3.0/results/failure.rb
1069
+ - lib/lookout-3.0/results/success.rb
1070
+ - lib/lookout-3.0/warning.rb
1071
+ - lib/lookout-3.0.rb
1072
+ - lib/lookout-3.0/version.rb
1073
+ - test/unit/lookout-3.0/object.rb
1074
+ - test/unit/lookout-3.0/aphonic.rb
1075
+ - test/unit/lookout-3.0/actual.rb
1076
+ - test/unit/lookout-3.0/actual/method.rb
1077
+ - test/unit/lookout-3.0/actual/not.rb
1078
+ - test/unit/lookout-3.0/actual/not/method.rb
1079
+ - test/unit/lookout-3.0/diff.rb
1080
+ - test/unit/lookout-3.0/diff/slice.rb
1081
+ - test/unit/lookout-3.0/diff/algorithms.rb
1082
+ - test/unit/lookout-3.0/diff/algorithms/difflib.rb
1083
+ - test/unit/lookout-3.0/diff/algorithms/difflib/position.rb
1084
+ - test/unit/lookout-3.0/diff/algorithms/difflib/position/new.rb
1085
+ - test/unit/lookout-3.0/diff/formats.rb
1086
+ - test/unit/lookout-3.0/diff/formats/inline.rb
1087
+ - test/unit/lookout-3.0/diff/formats/set.rb
1088
+ - test/unit/lookout-3.0/diff/formats/unified.rb
1089
+ - test/unit/lookout-3.0/diff/group.rb
1090
+ - test/unit/lookout-3.0/diff/groups.rb
1091
+ - test/unit/lookout-3.0/diff/match.rb
1092
+ - test/unit/lookout-3.0/diff/operation.rb
1093
+ - test/unit/lookout-3.0/diff/operations.rb
1094
+ - test/unit/lookout-3.0/diff/operations/delete.rb
1095
+ - test/unit/lookout-3.0/diff/operations/copy.rb
1096
+ - test/unit/lookout-3.0/diff/operations/insert.rb
1097
+ - test/unit/lookout-3.0/diff/operations/replace.rb
1098
+ - test/unit/lookout-3.0/difference.rb
1099
+ - test/unit/lookout-3.0/difference/object.rb
1100
+ - test/unit/lookout-3.0/difference/array.rb
1101
+ - test/unit/lookout-3.0/difference/exception.rb
1102
+ - test/unit/lookout-3.0/difference/hash.rb
1103
+ - test/unit/lookout-3.0/difference/range.rb
1104
+ - test/unit/lookout-3.0/difference/lookout.rb
1105
+ - test/unit/lookout-3.0/difference/lookout/actual.rb
1106
+ - test/unit/lookout-3.0/difference/lookout/actual/method.rb
1107
+ - test/unit/lookout-3.0/difference/lookout/actual/not.rb
1108
+ - test/unit/lookout-3.0/difference/lookout/actual/not/method.rb
1109
+ - test/unit/lookout-3.0/difference/lookout/output.rb
1110
+ - test/unit/lookout-3.0/difference/lookout/reception.rb
1111
+ - test/unit/lookout-3.0/difference/lookout/warning.rb
1112
+ - test/unit/lookout-3.0/difference/module.rb
1113
+ - test/unit/lookout-3.0/difference/regexp.rb
1114
+ - test/unit/lookout-3.0/difference/string.rb
1115
+ - test/unit/lookout-3.0/difference/symbol.rb
1116
+ - test/unit/lookout-3.0/encode.rb
1117
+ - test/unit/lookout-3.0/exception.rb
1118
+ - test/unit/lookout-3.0/exception/backtrace.rb
1119
+ - test/unit/lookout-3.0/exception/unknown.rb
1120
+ - test/unit/lookout-3.0/expect.rb
1121
+ - test/unit/lookout-3.0/expect/object.rb
1122
+ - test/unit/lookout-3.0/expect/object/context.rb
1123
+ - test/unit/lookout-3.0/expect/classes.rb
1124
+ - test/unit/lookout-3.0/expect/classes/exception.rb
1125
+ - test/unit/lookout-3.0/expect/exception.rb
1126
+ - test/unit/lookout-3.0/expected.rb
1127
+ - test/unit/lookout-3.0/expected/object.rb
1128
+ - test/unit/lookout-3.0/expected/array.rb
1129
+ - test/unit/lookout-3.0/expected/classes.rb
1130
+ - test/unit/lookout-3.0/expected/classes/exception.rb
1131
+ - test/unit/lookout-3.0/expected/exception.rb
1132
+ - test/unit/lookout-3.0/expected/falseclass.rb
1133
+ - test/unit/lookout-3.0/expected/hash.rb
1134
+ - test/unit/lookout-3.0/expected/lookout.rb
1135
+ - test/unit/lookout-3.0/expected/lookout/actual.rb
1136
+ - test/unit/lookout-3.0/expected/lookout/actual/method.rb
1137
+ - test/unit/lookout-3.0/expected/lookout/actual/not.rb
1138
+ - test/unit/lookout-3.0/expected/lookout/actual/not/method.rb
1139
+ - test/unit/lookout-3.0/expected/lookout/output.rb
1140
+ - test/unit/lookout-3.0/expected/lookout/reception.rb
1141
+ - test/unit/lookout-3.0/expected/lookout/warning.rb
1142
+ - test/unit/lookout-3.0/expected/module.rb
1143
+ - test/unit/lookout-3.0/expected/range.rb
1144
+ - test/unit/lookout-3.0/expected/regexp.rb
1145
+ - test/unit/lookout-3.0/expected/string.rb
1146
+ - test/unit/lookout-3.0/expected/symbol.rb
1147
+ - test/unit/lookout-3.0/expected/trueclass.rb
1148
+ - test/unit/lookout-3.0/expectations.rb
1149
+ - test/unit/lookout-3.0/expectations/context.rb
1150
+ - test/unit/lookout-3.0/inspect.rb
1151
+ - test/unit/lookout-3.0/interfaces.rb
1152
+ - test/unit/lookout-3.0/interfaces/commandline.rb
1153
+ - test/unit/lookout-3.0/literal.rb
1154
+ - test/unit/lookout-3.0/stub.rb
1155
+ - test/unit/lookout-3.0/mock.rb
1156
+ - test/unit/lookout-3.0/output.rb
1157
+ - test/unit/lookout-3.0/plugins.rb
1158
+ - test/unit/lookout-3.0/reception.rb
1159
+ - test/unit/lookout-3.0/reception/arguments.rb
1160
+ - test/unit/lookout-3.0/reception/arguments/any.rb
1161
+ - test/unit/lookout-3.0/reception/arguments/error.rb
1162
+ - test/unit/lookout-3.0/reception/arguments/list.rb
1163
+ - test/unit/lookout-3.0/reception/arguments/none.rb
1164
+ - test/unit/lookout-3.0/reception/error.rb
1165
+ - test/unit/lookout-3.0/object/not.rb
1166
+ - test/unit/lookout-3.0/object/not/receive.rb
1167
+ - test/unit/lookout-3.0/object/to.rb
1168
+ - test/unit/lookout-3.0/object/to/receive.rb
1169
+ - test/unit/lookout-3.0/result.rb
1170
+ - test/unit/lookout-3.0/results.rb
1171
+ - test/unit/lookout-3.0/results/error.rb
1172
+ - test/unit/lookout-3.0/results/failure.rb
1173
+ - test/unit/lookout-3.0/results/success.rb
1174
+ - test/unit/lookout-3.0/warning.rb
1175
+ - test/unit/lookout-3.0.rb
1176
+ - test/unit/lookout-3.0/version.rb
433
1177
  - test/unit/examples.rb
434
- - test/unit/lookout/diff/algorithms/difflib/position/to.rb
435
- - test/unit/lookout/diff/algorithms/difflib/position.rb
436
- - test/unit/lookout/diff/algorithms/difflib.rb
437
- - test/unit/lookout/diff/formats/inline.rb
438
- - test/unit/lookout/diff/formats/unified.rb
439
- - test/unit/lookout/diff/group.rb
440
- - test/unit/lookout/diff/groups.rb
441
- - test/unit/lookout/diff/match.rb
442
- - test/unit/lookout/diff/operations/delete.rb
443
- - test/unit/lookout/diff/operations/equal.rb
444
- - test/unit/lookout/diff/operations/insert.rb
445
- - test/unit/lookout/diff/operations/replace.rb
446
- - test/unit/lookout/diff/operations.rb
447
- - test/unit/lookout/diff/range.rb
448
- - test/unit/lookout/diff.rb
449
- - test/unit/lookout/equality.rb
450
- - test/unit/lookout/expectation.rb
451
- - test/unit/lookout/expectations/behavior.rb
452
- - test/unit/lookout/expectations/line.rb
453
- - test/unit/lookout/expectations/state.rb
454
- - test/unit/lookout/expectations.rb
455
- - test/unit/lookout/mock/method/arguments/any.rb
456
- - test/unit/lookout/mock/method/arguments.rb
457
- - test/unit/lookout/mock/method.rb
458
- - test/unit/lookout/recorder.rb
459
- - test/unit/lookout/results/error/exception/backtrace.rb
460
- - test/unit/lookout/results/error.rb
461
- - test/unit/lookout/results/failures/behavior.rb
462
- - test/unit/lookout/results/failures/state.rb
463
- - test/unit/lookout/results/fulfilled.rb
464
- - test/unit/lookout/results/unsuccessful.rb
465
- - test/unit/lookout/results.rb
466
- - test/unit/lookout/runners/console.rb
467
- - test/unit/lookout/runners/trackers/failure.rb
468
- - test/unit/lookout/stub/method.rb
469
- - test/unit/lookout/stub/methods.rb
470
- - test/unit/lookout/ui/console.rb
471
- - test/unit/lookout/xml.rb
472
- - test/unit/lookout.rb
473
1178
  - README
474
1179
  - Rakefile
475
- homepage: http://github.com/now/lookout
1180
+ homepage: https://github.com/now/lookout
476
1181
  licenses: []
477
1182
  metadata: {}
478
1183
  post_install_message:
@@ -480,21 +1185,19 @@ rdoc_options: []
480
1185
  require_paths:
481
1186
  - lib
482
1187
  required_ruby_version: !ruby/object:Gem::Requirement
483
- none: false
484
1188
  requirements:
485
- - - ! '>='
1189
+ - - '>='
486
1190
  - !ruby/object:Gem::Version
487
1191
  version: '0'
488
1192
  required_rubygems_version: !ruby/object:Gem::Requirement
489
- none: false
490
1193
  requirements:
491
- - - ! '>='
1194
+ - - '>='
492
1195
  - !ruby/object:Gem::Version
493
1196
  version: '0'
494
1197
  requirements: []
495
1198
  rubyforge_project:
496
- rubygems_version: 1.8.10
1199
+ rubygems_version: 2.0.0
497
1200
  signing_key:
498
1201
  specification_version: 4
499
- summary: Lookout is a lightweight unit testing framework.
1202
+ summary: focus.
500
1203
  test_files: []