lookout 2.3.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Slice of the old sequence that should be replaced with one from the new
4
+ # sequence.
5
+ class Lookout::Diff::Operations::Replace < Lookout::Diff::Operation
6
+ end
@@ -0,0 +1,97 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Slice (subsequence) of a sequence being “diffed”.
4
+ class Lookout::Diff::Slice
5
+ # Initializes a slice of ITEMS encompassing RANGE.
6
+ # @param [Enumerable] items
7
+ # @param [Range] range
8
+ Value(:items, :range)
9
+ def initialize(items, range = 0...items.size)
10
+ super items, range.exclude_end? ? range.begin..range.end - 1 : range
11
+ end
12
+ include Enumerable, Comparable
13
+
14
+ # @return True if {#size} < 1
15
+ def empty?; size < 1 end
16
+
17
+ # @return The number of encompassed elements
18
+ def size; self.end - self.begin + 1 end
19
+
20
+ # @return True if {#end} + 1 = OTHER{#begin}
21
+ def touch?(other) self.end + 1 == other.begin end
22
+
23
+ # @return True if {#begin} < OTHER{#begin}
24
+ def begin_before?(other) self.begin < other.begin end
25
+
26
+ # @return True if {#end} > OTHER{#end}
27
+ def end_after?(other) self.end > other.end end
28
+
29
+ # @return [Slice] A new slice beginning at OTHER{#end} + 1
30
+ def begin_after(other) begin_at(other.end + 1) end
31
+
32
+ # @return [Slice] A new slice ending at OTHER{#begin} - 1
33
+ def end_before(other) end_at(other.begin - 1) end
34
+
35
+ # @return [Slice] A new slice encompassing RANGE
36
+ def at(range) self.class.new(items, range) end
37
+
38
+ # @return A new slice encompassing the receiver and OTHER
39
+ # @note Logically, the receiver should {#touch?} OTHER, but this isn’t
40
+ # enforced.
41
+ def +(other) at(self.begin..other.end) end
42
+
43
+ # @return [Slice] A new slice beginning at INDEX
44
+ def begin_at(index) at(index..self.end) end
45
+
46
+ # @return [Slice] A new slice ending at INDEX
47
+ def end_at(index) at(self.begin..index) end
48
+
49
+ # @overload
50
+ # Enumerates the encompassed elements.
51
+ #
52
+ # @yieldparam element
53
+ # @overload
54
+ # @return [Enumerator<Object>] An Enumerator over the encompassed elements
55
+ def each
56
+ return enum_for(__method__) unless block_given?
57
+ range.each do |index| yield items[index] end
58
+ self
59
+ end
60
+
61
+ # @overload
62
+ # Enumerates the encompassed elements and their indexes.
63
+ #
64
+ # @yieldparam element
65
+ # @yieldparam [Integer] index
66
+ # @overload
67
+ # @return [Enumerator<Object, Integer>] An Enumerator over the encompassed
68
+ # elements and their indexes
69
+ def each_with_index
70
+ return enum_for(__method__) unless block_given?
71
+ range.each do |index| yield items[index], index end
72
+ self
73
+ end
74
+
75
+ # @return [Enumerable<Object>] The encompassed elements
76
+ def to_items; items[range] end
77
+
78
+ # @return The INDEXth element
79
+ def [](index) items[index] end
80
+
81
+ # @return [Integer] The index of the first element
82
+ def begin; range.begin end
83
+
84
+ # @return [Integer] The index of the last element
85
+ def end; range.end end
86
+
87
+ # @return The comparison of the receiver’s {#begin} and {#end}
88
+ # against those of OTHER
89
+ def <=>(other)
90
+ return nil unless self.class == other.class and items == other.items
91
+ (self.begin <=> other.begin).nonzero? or
92
+ (self.end <=> other.end).nonzero? or
93
+ 0
94
+ end
95
+
96
+ alias eql? ==
97
+ end
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Function-like namespace for type-specific difference reports. Used by
4
+ # {Expected} and {Expect} to generate difference reports between their expected
5
+ # values and actual results.
6
+ #
7
+ # {Object} is the base class for all classes defined under this namespace, so
8
+ # look to it for guidance.
9
+ module Lookout::Difference
10
+ end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Array}s.
4
+ class Lookout::Difference::Array < Lookout::Difference::Object
5
+ # @return [Diff::Formats::Unified, super] A unified “diff” between {#actual}
6
+ # and {#expected} unless {#expected} contains one element or {#actual}
7
+ # isn’t an Array, {super} otherwise
8
+ def diff
9
+ return super if expected.size == 1 or not Array === actual
10
+ Lookout::Diff::Formats::Unified.
11
+ new(Lookout::Diff::Groups.
12
+ new(Lookout::Diff::Operations.
13
+ new(Lookout::Diff::Algorithms::Difflib.
14
+ new(actual, expected))))
15
+ end
16
+
17
+ private
18
+
19
+ # @return [::String, super] The symbol ‘≉’ if {#actual} is an Array of the
20
+ # same #size as {#expected}, {super} otherwise
21
+ def symbol; Array === actual && expected.size == actual.size ? '≉' : super end
22
+ end
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Exception}s. The report differs from that of
4
+ # {Object} in that it tries to “diff” the exception messages and that it uses
5
+ # ‘≉’ instead of ‘≠’ to show that the actual result doesn’t match an expected
6
+ # Regexp.
7
+ class Lookout::Difference::Exception < Lookout::Difference::Object
8
+ # Initializes a difference report between the ACTUAL result and the EXPECTED
9
+ # value, where REGEXP is the {::Regexp} found inside EXPECTED, if any.
10
+ # @param [::Exception] actual
11
+ # @param [::Exception] expected
12
+ # @param [::Regexp, nil] regexp
13
+ def initialize(actual, expected, regexp = nil)
14
+ @regexp = regexp
15
+ super actual, expected
16
+ end
17
+
18
+ # @return [Enumerable<String>, super] The result of {String#diff} between
19
+ # {#expected}’s message and {#actual}’s message if {#actual} and
20
+ # {#expected} are of the same class and {#expected} and {#actual}’s
21
+ # messages are Strings, {super} otherwise
22
+ def diff
23
+ return super unless expected.class == actual.class and
24
+ String === expected.message and
25
+ not @regexp and
26
+ (m = actual.message rescue nil) and
27
+ String === m
28
+ expected.message.to_lookout_expected.difference(m).diff
29
+ end
30
+
31
+ private
32
+
33
+ # @return [::String, super] A specially crafted inspection String containing
34
+ # the Regexp if {#expected} contains a Regexp, {super} otherwise
35
+ def inspect_expected; @regexp ? '#<%s: %p>' % [expected.class, @regexp] : super end
36
+
37
+ # @return [::String, super] The symbol ‘≉’ if a Regexp was found inside
38
+ # {#expected}, {super} otherwise
39
+ def symbol; @regexp ? '≉' : super end
40
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Hash}es. These reports are generated by
4
+ # turning the Hashes into {::Array}s, sorting them by key, and finally mapping
5
+ # the keys and values to their String inspections.
6
+ class Lookout::Difference::Hash < Lookout::Difference::Object
7
+ # @return [Lookout::Diff::Formats::Set, super] A set “diff” unless
8
+ # {#expected} contains one element or {#actual} isn’t a Hash, {super}
9
+ # otherwise
10
+ def diff
11
+ return super if expected.size == 1 or not Hash === actual
12
+ Lookout::Diff::Formats::Set.
13
+ new(Lookout::Diff::Operations.
14
+ new(Lookout::Diff::Algorithms::Difflib.
15
+ new(array(actual), array(expected))))
16
+ end
17
+
18
+ private
19
+
20
+ # @return [::String, super] The symbol ‘≉’ if {#actual} is a Hash of the
21
+ # same #size as {#expected}, {super} otherwise
22
+ def symbol; Hash === actual && expected.size == actual.size ? '≉' : super end
23
+
24
+ def array(hash)
25
+ hash.to_a.sort_by{ |key, _| key }.map{ |key, value|
26
+ [Lookout::Inspect.new(key, 'key'),
27
+ ' => ',
28
+ Lookout::Inspect.new(value, 'value')].join('')
29
+ }
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for difference report generators for under the {Lookout} namespace.
4
+ module Lookout::Difference::Lookout
5
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for difference report generators for objects under the
4
+ # {Lookout::Actual} namespace.
5
+ module Lookout::Difference::Lookout::Actual
6
+ end
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Lookout::Actual::Method}s.
4
+ class Lookout::Difference::Lookout::Actual::Method < Lookout::Difference::Object
5
+ # @return [::String] A String of the form ¬{#actual}#{#expected}, where
6
+ # {#actual} is the object that the query method {#expected} was invoked upon
7
+ def message; [symbol, inspect_actual, inspect_expected].join('') end
8
+
9
+ private
10
+
11
+ # @return [::String] The inequality symbol ‘¬’
12
+ def symbol; '¬' end
13
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for difference report generators for objects under the
4
+ # {::Lookout::Actual::Not} namespace.
5
+ module Lookout::Difference::Lookout::Actual::Not
6
+ end
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Lookout::Actual::Not::Method}s.
4
+ class Lookout::Difference::Lookout::Actual::Not::Method < Lookout::Difference::Lookout::Actual::Method
5
+ private
6
+
7
+ # @return [::String] The inequality symbol ‘’
8
+ def symbol; '' end
9
+ end
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Lookout::Output}s.
4
+ class Lookout::Difference::Lookout::Output < Lookout::Difference::Object
5
+ # @return [Enumerable<::String>] The result of
6
+ # {#expected}{::Lookout::Output#diff #diff}({#actual})
7
+ def diff; expected.diff(actual) end
8
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Lookout::Reception}s. Differences are seen
4
+ # when the number of times a method call is received isn’t within the range of
5
+ # expected number of receptions.
6
+ class Lookout::Difference::Lookout::Reception < Lookout::Difference::Range
7
+ # Initializes a difference report between the ACTUAL number of receptions
8
+ # against the range of EXPECTED number of receptions.
9
+ # @param [Integer] actual
10
+ # @param [Range] expected
11
+ def initialize(actual, expected)
12
+ super actual, expected.range
13
+ @reception = expected
14
+ end
15
+
16
+ # @return [Enumerable<::String>] An Enumerable containing the difference
17
+ # report message generated from the method mock
18
+ def diff
19
+ [Lookout::Reception::Error.from(@reception, actual, expected).message]
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Lookout::Warning}s.
4
+ class Lookout::Difference::Lookout::Warning < Lookout::Difference::Lookout::Output
5
+ private
6
+
7
+ # @return [::String] The inequality symbol ‘≉’
8
+ def symbol; '≉' end
9
+ end
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Module}s. The report differs from that of
4
+ # {Object} in that it uses ‘≉’ instead of ‘≠’ to show that the actual result
5
+ # isn’t an instance of (doesn’t case match) the expected Module.
6
+ class Lookout::Difference::Module < Lookout::Difference::Object
7
+ private
8
+
9
+ # @return [::String, super] The symbol ‘≉’ unless {#actual} is a Module,
10
+ # {super} otherwise
11
+ def symbol; Module === actual ? super : '≉' end
12
+ end
@@ -0,0 +1,73 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Object}s. This is the base difference report
4
+ # class and should be subclassed if something more specific fits the bill. The
5
+ # actual result and expected value are assumed to differ and you’ll surely get
6
+ # confused if they don’t. Determining if the objects differ is up to the
7
+ # caller.
8
+ class Lookout::Difference::Object
9
+ # Initializes a difference report between the ACTUAL result and the EXPECTED
10
+ # value.
11
+ # @param [::Object] actual
12
+ # @param [::Object] expected
13
+ def initialize(actual, expected) @actual, @expected = actual, expected end
14
+
15
+ # @return [::String] The concatenation of {#inspect_actual}, {#symbol}, and
16
+ # {#inspect_expected}, explaining how {#actual} differs from {#expected}
17
+ # @note Subclasses may override this method to provide more specific
18
+ # messages for their specific types.
19
+ def message; [inspect_actual, symbol, inspect_expected].join('') end
20
+
21
+ # @return [Enumerable<String>] An Enumerable over the formatted operations
22
+ # that would have to be applied to {#actual} to get {#expected}
23
+ # @note The Enumerable returned by this specific implementation is empty.
24
+ # Subclasses may provide more detailed information for their specific
25
+ # types.
26
+ def diff; [] end
27
+
28
+ # @return [::String] The concatenation of {#message} and {#diff}
29
+ # @note This method should not be overridden by subclasses, as it goes to
30
+ # some lengths to safely return a String for display.
31
+ def to_s
32
+ begin
33
+ m = message
34
+ rescue => e
35
+ raise if self.class == Lookout::Difference::Object rescue true
36
+ return '%s (cannot generate more specific failure message: %s)' %
37
+ [Lookout::Difference::Object.new(actual, expected).message, e]
38
+ end
39
+ begin
40
+ d = diff.to_a.join("\n")
41
+ rescue => e
42
+ d = '(cannot diff expected value and actual result: %s)' % e
43
+ end
44
+ d.empty? ? m : [m, d].join(d.include?("\n") ? "\n" : ': ')
45
+ end
46
+
47
+ # @return True if the receiver’s class, {#message}, and {#diff} equal those
48
+ # of OTHER
49
+ def ==(other)
50
+ self.class == other.class and
51
+ message == other.message and diff.to_s == other.diff.to_s
52
+ end
53
+
54
+ # @return a hash value based on {#message} and {#diff}
55
+ def hash; @hash ||= [message, diff.to_s].hash end
56
+
57
+ # @return [::Object] The actual result
58
+ attr_reader :actual
59
+
60
+ # @return [::Object] The expected value
61
+ attr_reader :expected
62
+
63
+ private
64
+
65
+ # @return [::String] The safely inspected value of {#actual}, see {Inspect}
66
+ def inspect_actual; Lookout::Inspect.new(actual, 'actual result').call end
67
+
68
+ # @return [::String] The safely inspected value of {#expected}, see {Inspect}
69
+ def inspect_expected; Lookout::Inspect.new(expected, 'expected value').call end
70
+
71
+ # @return [::String] The inequality symbol to use (‘≠’)
72
+ def symbol; '≠' end
73
+ end
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Range}s. The report differs from
4
+ # that of {Object} in that it uses ‘∉’ instead of ‘≠’ to show that the actual
5
+ # result isn’t a member of the expected Range.
6
+ class Lookout::Difference::Range < Lookout::Difference::Object
7
+ private
8
+
9
+ # @return [::String, super] The symbol ‘∉’ unless {#actual} is a Range,
10
+ # {super} otherwise
11
+ def symbol; Range === actual ? super : '∉' end
12
+ end
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Regexp}s. The report differs from that of
4
+ # {Object} in that it uses ‘≉’ instead of ‘≠’ to show that the actual result
5
+ # doesn’t match the expected Regexp.
6
+ class Lookout::Difference::Regexp < Lookout::Difference::Object
7
+ private
8
+
9
+ # @return [::String, super] The symbol ‘≉’ unless {#actual} is a Regexp,
10
+ # {super} otherwise
11
+ def symbol; Regexp === actual ? super : '≉' end
12
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::String}s.
4
+ class Lookout::Difference::String < Lookout::Difference::Object
5
+ # @return [Diff::Formats::Unified, Diff::Formats::Inline, super] A unified
6
+ # “diff” if {#actual} or {#expected} include a newline, an inline “diff”
7
+ # otherwise, or {super} if {#actual} isn’t a String
8
+ def diff
9
+ return super unless String === actual
10
+ (actual.include? "\n" or expected.include? "\n") ?
11
+ Lookout::Diff::Formats::Unified.
12
+ new(Lookout::Diff::Groups.
13
+ new(Lookout::Diff::Operations.
14
+ new(Lookout::Diff::Algorithms::Difflib.
15
+ new(actual.split("\n"), expected.split("\n"))))) :
16
+ Lookout::Diff::Formats::Inline.
17
+ new(Lookout::Diff::Operations.
18
+ new(Lookout::Diff::Algorithms::Difflib.
19
+ new(actual, expected)))
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Difference reports between {::Symbol}s.
4
+ class Lookout::Difference::Symbol < Lookout::Difference::Object
5
+ # Initializes a difference report between the ACTUAL result Symbol and the
6
+ # EXPECTED value Symbol, with QUERY being the name of the query method
7
+ # that EXPECTED represents, if any, whose result may be NEGATED.
8
+ # @param (see Object#initialize)
9
+ # @param [::String, nil] query
10
+ # @param [Boolean] negated
11
+ def initialize(actual, expected, query, negated)
12
+ super actual, expected
13
+ @query, @negated = query, negated
14
+ end
15
+
16
+ # @return [::String, super] A String of the form {#actual}#QUERY, prefixed
17
+ # by ‘¬’ if the query was negated, if there was a query, {super} otherwise
18
+ def message
19
+ @query ? [@negated ? '' : '¬', inspect_actual, '#', @query].join('') : super
20
+ end
21
+ end