sublimetheme 1.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 (276) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +230 -0
  9. data/Rakefile +8 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/lib/sublimetheme.rb +6832 -0
  13. data/lib/sublimetheme/version.rb +3 -0
  14. data/path/bin/htmldiff +25 -0
  15. data/path/bin/htmldiff.bat +6 -0
  16. data/path/bin/ldiff +25 -0
  17. data/path/bin/ldiff.bat +6 -0
  18. data/path/bin/rspec +23 -0
  19. data/path/bin/rspec.bat +6 -0
  20. data/path/cache/diff-lcs-1.2.5.gem +0 -0
  21. data/path/cache/rspec-3.3.0.gem +0 -0
  22. data/path/cache/rspec-core-3.3.2.gem +0 -0
  23. data/path/cache/rspec-expectations-3.3.1.gem +0 -0
  24. data/path/cache/rspec-mocks-3.3.2.gem +0 -0
  25. data/path/cache/rspec-support-3.3.0.gem +0 -0
  26. data/path/gems/diff-lcs-1.2.5/.autotest +3 -0
  27. data/path/gems/diff-lcs-1.2.5/.gemtest +0 -0
  28. data/path/gems/diff-lcs-1.2.5/.hoerc +2 -0
  29. data/path/gems/diff-lcs-1.2.5/.rspec +2 -0
  30. data/path/gems/diff-lcs-1.2.5/.travis.yml +22 -0
  31. data/path/gems/diff-lcs-1.2.5/Contributing.rdoc +64 -0
  32. data/path/gems/diff-lcs-1.2.5/Gemfile +20 -0
  33. data/path/gems/diff-lcs-1.2.5/History.rdoc +152 -0
  34. data/path/gems/diff-lcs-1.2.5/License.rdoc +39 -0
  35. data/path/gems/diff-lcs-1.2.5/Manifest.txt +38 -0
  36. data/path/gems/diff-lcs-1.2.5/README.rdoc +85 -0
  37. data/path/gems/diff-lcs-1.2.5/Rakefile +41 -0
  38. data/path/gems/diff-lcs-1.2.5/autotest/discover.rb +1 -0
  39. data/path/gems/diff-lcs-1.2.5/bin/htmldiff +32 -0
  40. data/path/gems/diff-lcs-1.2.5/bin/ldiff +6 -0
  41. data/path/gems/diff-lcs-1.2.5/docs/COPYING.txt +339 -0
  42. data/path/gems/diff-lcs-1.2.5/docs/artistic.txt +127 -0
  43. data/path/gems/diff-lcs-1.2.5/lib/diff-lcs.rb +3 -0
  44. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs.rb +805 -0
  45. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb +7 -0
  46. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb +37 -0
  47. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb +322 -0
  48. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb +177 -0
  49. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb +149 -0
  50. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb +276 -0
  51. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb +301 -0
  52. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb +195 -0
  53. data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb +5 -0
  54. data/path/gems/diff-lcs-1.2.5/spec/change_spec.rb +65 -0
  55. data/path/gems/diff-lcs-1.2.5/spec/diff_spec.rb +47 -0
  56. data/path/gems/diff-lcs-1.2.5/spec/hunk_spec.rb +72 -0
  57. data/path/gems/diff-lcs-1.2.5/spec/issues_spec.rb +24 -0
  58. data/path/gems/diff-lcs-1.2.5/spec/lcs_spec.rb +54 -0
  59. data/path/gems/diff-lcs-1.2.5/spec/patch_spec.rb +414 -0
  60. data/path/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb +214 -0
  61. data/path/gems/diff-lcs-1.2.5/spec/spec_helper.rb +290 -0
  62. data/path/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb +310 -0
  63. data/path/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb +139 -0
  64. data/path/gems/rspec-3.3.0/License.txt +24 -0
  65. data/path/gems/rspec-3.3.0/README.md +34 -0
  66. data/path/gems/rspec-3.3.0/lib/rspec.rb +3 -0
  67. data/path/gems/rspec-3.3.0/lib/rspec/version.rb +5 -0
  68. data/path/gems/rspec-core-3.3.2/.document +5 -0
  69. data/path/gems/rspec-core-3.3.2/.yardopts +8 -0
  70. data/path/gems/rspec-core-3.3.2/Changelog.md +1856 -0
  71. data/path/gems/rspec-core-3.3.2/License.txt +25 -0
  72. data/path/gems/rspec-core-3.3.2/README.md +369 -0
  73. data/path/gems/rspec-core-3.3.2/exe/rspec +4 -0
  74. data/path/gems/rspec-core-3.3.2/lib/rspec/autorun.rb +3 -0
  75. data/path/gems/rspec-core-3.3.2/lib/rspec/core.rb +181 -0
  76. data/path/gems/rspec-core-3.3.2/lib/rspec/core/backtrace_formatter.rb +64 -0
  77. data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/coordinator.rb +66 -0
  78. data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/example_minimizer.rb +130 -0
  79. data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/runner.rb +139 -0
  80. data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/server.rb +61 -0
  81. data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/subset_enumerator.rb +39 -0
  82. data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb +1807 -0
  83. data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration_options.rb +191 -0
  84. data/path/gems/rspec-core-3.3.2/lib/rspec/core/drb.rb +111 -0
  85. data/path/gems/rspec-core-3.3.2/lib/rspec/core/dsl.rb +96 -0
  86. data/path/gems/rspec-core-3.3.2/lib/rspec/core/example.rb +573 -0
  87. data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb +796 -0
  88. data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_status_persister.rb +235 -0
  89. data/path/gems/rspec-core-3.3.2/lib/rspec/core/filter_manager.rb +231 -0
  90. data/path/gems/rspec-core-3.3.2/lib/rspec/core/flat_map.rb +20 -0
  91. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters.rb +254 -0
  92. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_formatter.rb +70 -0
  93. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_text_formatter.rb +77 -0
  94. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_formatter.rb +68 -0
  95. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_progress_formatter.rb +115 -0
  96. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/console_codes.rb +65 -0
  97. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
  98. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/documentation_formatter.rb +70 -0
  99. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/exception_presenter.rb +393 -0
  100. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
  101. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/helpers.rb +109 -0
  102. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_formatter.rb +151 -0
  103. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_printer.rb +415 -0
  104. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/json_formatter.rb +96 -0
  105. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/profile_formatter.rb +68 -0
  106. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/progress_formatter.rb +28 -0
  107. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/protocol.rb +172 -0
  108. data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/snippet_extractor.rb +116 -0
  109. data/path/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb +638 -0
  110. data/path/gems/rspec-core-3.3.2/lib/rspec/core/memoized_helpers.rb +532 -0
  111. data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata.rb +490 -0
  112. data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata_filter.rb +235 -0
  113. data/path/gems/rspec-core-3.3.2/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
  114. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
  115. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
  116. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/null.rb +14 -0
  117. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rr.rb +31 -0
  118. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
  119. data/path/gems/rspec-core-3.3.2/lib/rspec/core/mutex.rb +63 -0
  120. data/path/gems/rspec-core-3.3.2/lib/rspec/core/notifications.rb +498 -0
  121. data/path/gems/rspec-core-3.3.2/lib/rspec/core/option_parser.rb +301 -0
  122. data/path/gems/rspec-core-3.3.2/lib/rspec/core/ordering.rb +158 -0
  123. data/path/gems/rspec-core-3.3.2/lib/rspec/core/pending.rb +165 -0
  124. data/path/gems/rspec-core-3.3.2/lib/rspec/core/profiler.rb +32 -0
  125. data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer.rb +48 -0
  126. data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/.rspec +2 -0
  127. data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/spec/spec_helper.rb +96 -0
  128. data/path/gems/rspec-core-3.3.2/lib/rspec/core/rake_task.rb +158 -0
  129. data/path/gems/rspec-core-3.3.2/lib/rspec/core/reentrant_mutex.rb +52 -0
  130. data/path/gems/rspec-core-3.3.2/lib/rspec/core/reporter.rb +220 -0
  131. data/path/gems/rspec-core-3.3.2/lib/rspec/core/ruby_project.rb +53 -0
  132. data/path/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb +179 -0
  133. data/path/gems/rspec-core-3.3.2/lib/rspec/core/sandbox.rb +37 -0
  134. data/path/gems/rspec-core-3.3.2/lib/rspec/core/set.rb +49 -0
  135. data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_context.rb +55 -0
  136. data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_example_group.rb +210 -0
  137. data/path/gems/rspec-core-3.3.2/lib/rspec/core/shell_escape.rb +49 -0
  138. data/path/gems/rspec-core-3.3.2/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  139. data/path/gems/rspec-core-3.3.2/lib/rspec/core/version.rb +9 -0
  140. data/path/gems/rspec-core-3.3.2/lib/rspec/core/warnings.rb +40 -0
  141. data/path/gems/rspec-core-3.3.2/lib/rspec/core/world.rb +178 -0
  142. data/path/gems/rspec-expectations-3.3.1/.document +5 -0
  143. data/path/gems/rspec-expectations-3.3.1/.yardopts +6 -0
  144. data/path/gems/rspec-expectations-3.3.1/Changelog.md +953 -0
  145. data/path/gems/rspec-expectations-3.3.1/License.txt +24 -0
  146. data/path/gems/rspec-expectations-3.3.1/README.md +289 -0
  147. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations.rb +81 -0
  148. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/configuration.rb +164 -0
  149. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/expectation_target.rb +113 -0
  150. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/fail_with.rb +31 -0
  151. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/failure_aggregator.rb +194 -0
  152. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/handler.rb +170 -0
  153. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/minitest_integration.rb +31 -0
  154. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/syntax.rb +132 -0
  155. data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/version.rb +8 -0
  156. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers.rb +1009 -0
  157. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/aliased_matcher.rb +116 -0
  158. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in.rb +52 -0
  159. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/all.rb +85 -0
  160. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/base_matcher.rb +181 -0
  161. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be.rb +285 -0
  162. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_between.rb +77 -0
  163. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_instance_of.rb +22 -0
  164. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_kind_of.rb +16 -0
  165. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_within.rb +72 -0
  166. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/change.rb +337 -0
  167. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/compound.rb +293 -0
  168. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/contain_exactly.rb +253 -0
  169. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/cover.rb +24 -0
  170. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eq.rb +40 -0
  171. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eql.rb +34 -0
  172. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/equal.rb +81 -0
  173. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/exist.rb +86 -0
  174. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/has.rb +103 -0
  175. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
  176. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/include.rb +130 -0
  177. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb +37 -0
  178. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/operators.rb +128 -0
  179. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/output.rb +200 -0
  180. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/raise_error.rb +216 -0
  181. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/respond_to.rb +90 -0
  182. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/satisfy.rb +37 -0
  183. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
  184. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/throw_symbol.rb +132 -0
  185. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/yield.rb +418 -0
  186. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/composable.rb +184 -0
  187. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/dsl.rb +453 -0
  188. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/english_phrasing.rb +42 -0
  189. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +73 -0
  190. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/fail_matchers.rb +42 -0
  191. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/generated_descriptions.rb +42 -0
  192. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_delegator.rb +35 -0
  193. data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_protocol.rb +99 -0
  194. data/path/gems/rspec-mocks-3.3.2/.document +5 -0
  195. data/path/gems/rspec-mocks-3.3.2/.yardopts +6 -0
  196. data/path/gems/rspec-mocks-3.3.2/Changelog.md +965 -0
  197. data/path/gems/rspec-mocks-3.3.2/License.txt +24 -0
  198. data/path/gems/rspec-mocks-3.3.2/README.md +430 -0
  199. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks.rb +126 -0
  200. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance.rb +11 -0
  201. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/chain.rb +110 -0
  202. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
  203. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
  204. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expectation_chain.rb +48 -0
  205. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/message_chains.rb +83 -0
  206. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/proxy.rb +116 -0
  207. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/recorder.rb +264 -0
  208. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain.rb +46 -0
  209. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain_chain.rb +27 -0
  210. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_list_matcher.rb +100 -0
  211. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_matchers.rb +320 -0
  212. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/configuration.rb +188 -0
  213. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/error_generator.rb +362 -0
  214. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/example_methods.rb +421 -0
  215. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/instance_method_stasher.rb +135 -0
  216. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/marshal_extension.rb +41 -0
  217. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
  218. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/have_received.rb +116 -0
  219. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive.rb +130 -0
  220. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_message_chain.rb +80 -0
  221. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_messages.rb +75 -0
  222. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_chain.rb +87 -0
  223. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_expectation.rb +717 -0
  224. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_double.rb +287 -0
  225. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_reference.rb +192 -0
  226. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutate_const.rb +335 -0
  227. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutex.rb +73 -0
  228. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/object_reference.rb +149 -0
  229. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/order_group.rb +81 -0
  230. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/proxy.rb +439 -0
  231. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/reentrant_mutex.rb +53 -0
  232. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/space.rb +238 -0
  233. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/standalone.rb +3 -0
  234. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/syntax.rb +325 -0
  235. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/targets.rb +97 -0
  236. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/test_double.rb +170 -0
  237. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_double.rb +129 -0
  238. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_message_expecation.rb +54 -0
  239. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_proxy.rb +213 -0
  240. data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/version.rb +9 -0
  241. data/path/gems/rspec-support-3.3.0/Changelog.md +125 -0
  242. data/path/gems/rspec-support-3.3.0/LICENSE.txt +22 -0
  243. data/path/gems/rspec-support-3.3.0/README.md +26 -0
  244. data/path/gems/rspec-support-3.3.0/lib/rspec/support.rb +111 -0
  245. data/path/gems/rspec-support-3.3.0/lib/rspec/support/caller_filter.rb +83 -0
  246. data/path/gems/rspec-support-3.3.0/lib/rspec/support/differ.rb +215 -0
  247. data/path/gems/rspec-support-3.3.0/lib/rspec/support/directory_maker.rb +63 -0
  248. data/path/gems/rspec-support-3.3.0/lib/rspec/support/encoded_string.rb +155 -0
  249. data/path/gems/rspec-support-3.3.0/lib/rspec/support/fuzzy_matcher.rb +48 -0
  250. data/path/gems/rspec-support-3.3.0/lib/rspec/support/hunk_generator.rb +47 -0
  251. data/path/gems/rspec-support-3.3.0/lib/rspec/support/matcher_definition.rb +42 -0
  252. data/path/gems/rspec-support-3.3.0/lib/rspec/support/method_signature_verifier.rb +273 -0
  253. data/path/gems/rspec-support-3.3.0/lib/rspec/support/object_formatter.rb +93 -0
  254. data/path/gems/rspec-support-3.3.0/lib/rspec/support/recursive_const_methods.rb +76 -0
  255. data/path/gems/rspec-support-3.3.0/lib/rspec/support/ruby_features.rb +118 -0
  256. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec.rb +81 -0
  257. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
  258. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/formatting_support.rb +9 -0
  259. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/in_sub_process.rb +52 -0
  260. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/library_wide_checks.rb +145 -0
  261. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/shell_out.rb +71 -0
  262. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/stderr_splitter.rb +63 -0
  263. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/string_matcher.rb +46 -0
  264. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_directory.rb +9 -0
  265. data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  266. data/path/gems/rspec-support-3.3.0/lib/rspec/support/version.rb +7 -0
  267. data/path/gems/rspec-support-3.3.0/lib/rspec/support/version_checker.rb +53 -0
  268. data/path/gems/rspec-support-3.3.0/lib/rspec/support/warnings.rb +39 -0
  269. data/path/specifications/diff-lcs-1.2.5.gemspec +68 -0
  270. data/path/specifications/rspec-3.3.0.gemspec +42 -0
  271. data/path/specifications/rspec-core-3.3.2.gemspec +68 -0
  272. data/path/specifications/rspec-expectations-3.3.1.gemspec +50 -0
  273. data/path/specifications/rspec-mocks-3.3.2.gemspec +53 -0
  274. data/path/specifications/rspec-support-3.3.0.gemspec +38 -0
  275. data/sublimetheme.gemspec +32 -0
  276. metadata +363 -0
@@ -0,0 +1,362 @@
1
+ RSpec::Support.require_rspec_support "object_formatter"
2
+
3
+ module RSpec
4
+ module Mocks
5
+ # Raised when a message expectation is not satisfied.
6
+ MockExpectationError = Class.new(Exception)
7
+
8
+ # Raised when a test double is used after it has been torn
9
+ # down (typically at the end of an rspec-core example).
10
+ ExpiredTestDoubleError = Class.new(MockExpectationError)
11
+
12
+ # Raised when doubles or partial doubles are used outside of the per-test lifecycle.
13
+ OutsideOfExampleError = Class.new(StandardError)
14
+
15
+ # Raised when an expectation customization method (e.g. `with`,
16
+ # `and_return`) is called on a message expectation which has already been
17
+ # invoked.
18
+ MockExpectationAlreadyInvokedError = Class.new(Exception)
19
+
20
+ # Raised for situations that RSpec cannot support due to mutations made
21
+ # externally on arguments that RSpec is holding onto to use for later
22
+ # comparisons.
23
+ #
24
+ # @deprecated We no longer raise this error but the constant remains until
25
+ # RSpec 4 for SemVer reasons.
26
+ CannotSupportArgMutationsError = Class.new(StandardError)
27
+
28
+ # @private
29
+ UnsupportedMatcherError = Class.new(StandardError)
30
+ # @private
31
+ NegationUnsupportedError = Class.new(StandardError)
32
+ # @private
33
+ VerifyingDoubleNotDefinedError = Class.new(StandardError)
34
+
35
+ # @private
36
+ class ErrorGenerator
37
+ attr_writer :opts
38
+
39
+ def initialize(target=nil)
40
+ @target = target
41
+ end
42
+
43
+ # @private
44
+ def opts
45
+ @opts ||= {}
46
+ end
47
+
48
+ # @private
49
+ def raise_unexpected_message_error(message, args)
50
+ __raise "#{intro} received unexpected message :#{message} with #{format_args(args)}"
51
+ end
52
+
53
+ # @private
54
+ def raise_unexpected_message_args_error(expectation, args_for_multiple_calls, source_id=nil)
55
+ __raise error_message(expectation, args_for_multiple_calls), nil, source_id
56
+ end
57
+
58
+ # @private
59
+ def raise_missing_default_stub_error(expectation, args_for_multiple_calls)
60
+ message = error_message(expectation, args_for_multiple_calls)
61
+ message << "\n Please stub a default value first if message might be received with other args as well. \n"
62
+
63
+ __raise message
64
+ end
65
+
66
+ # @private
67
+ def raise_similar_message_args_error(expectation, args_for_multiple_calls, backtrace_line=nil)
68
+ __raise error_message(expectation, args_for_multiple_calls), backtrace_line
69
+ end
70
+
71
+ def default_error_message(expectation, expected_args, actual_args)
72
+ [
73
+ intro,
74
+ "received",
75
+ expectation.message.inspect,
76
+ unexpected_arguments_message(expected_args, actual_args),
77
+ ].join(" ")
78
+ end
79
+
80
+ # rubocop:disable Style/ParameterLists
81
+ # @private
82
+ def raise_expectation_error(message, expected_received_count, argument_list_matcher,
83
+ actual_received_count, expectation_count_type, args,
84
+ backtrace_line=nil, source_id=nil)
85
+ expected_part = expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher)
86
+ received_part = received_part_of_expectation_error(actual_received_count, args)
87
+ __raise "(#{intro(:unwrapped)}).#{message}#{format_args(args)}\n #{expected_part}\n #{received_part}", backtrace_line, source_id
88
+ end
89
+ # rubocop:enable Style/ParameterLists
90
+
91
+ # @private
92
+ def raise_unimplemented_error(doubled_module, method_name, object)
93
+ message = case object
94
+ when InstanceVerifyingDouble
95
+ "the %s class does not implement the instance method: %s" <<
96
+ if ObjectMethodReference.for(doubled_module, method_name).implemented?
97
+ ". Perhaps you meant to use `class_double` instead?"
98
+ else
99
+ ""
100
+ end
101
+ when ClassVerifyingDouble
102
+ "the %s class does not implement the class method: %s" <<
103
+ if InstanceMethodReference.for(doubled_module, method_name).implemented?
104
+ ". Perhaps you meant to use `instance_double` instead?"
105
+ else
106
+ ""
107
+ end
108
+ else
109
+ "%s does not implement: %s"
110
+ end
111
+
112
+ __raise message % [doubled_module.description, method_name]
113
+ end
114
+
115
+ # @private
116
+ def raise_non_public_error(method_name, visibility)
117
+ raise NoMethodError, "%s method `%s' called on %s" % [
118
+ visibility, method_name, intro
119
+ ]
120
+ end
121
+
122
+ # @private
123
+ def raise_invalid_arguments_error(verifier)
124
+ __raise verifier.error_message
125
+ end
126
+
127
+ # @private
128
+ def raise_expired_test_double_error
129
+ raise ExpiredTestDoubleError,
130
+ "#{intro} was originally created in one example but has leaked into " \
131
+ "another example and can no longer be used. rspec-mocks' doubles are " \
132
+ "designed to only last for one example, and you need to create a new " \
133
+ "one in each example you wish to use it for."
134
+ end
135
+
136
+ # @private
137
+ def describe_expectation(verb, message, expected_received_count, _actual_received_count, args)
138
+ "#{verb} #{message}#{format_args(args)} #{count_message(expected_received_count)}"
139
+ end
140
+
141
+ # @private
142
+ def raise_out_of_order_error(message)
143
+ __raise "#{intro} received :#{message} out of order"
144
+ end
145
+
146
+ # @private
147
+ def raise_missing_block_error(args_to_yield)
148
+ __raise "#{intro} asked to yield |#{arg_list(args_to_yield)}| but no block was passed"
149
+ end
150
+
151
+ # @private
152
+ def raise_wrong_arity_error(args_to_yield, signature)
153
+ __raise "#{intro} yielded |#{arg_list(args_to_yield)}| to block with #{signature.description}"
154
+ end
155
+
156
+ # @private
157
+ def raise_only_valid_on_a_partial_double(method)
158
+ __raise "#{intro} is a pure test double. `#{method}` is only " \
159
+ "available on a partial double."
160
+ end
161
+
162
+ # @private
163
+ def raise_expectation_on_unstubbed_method(method)
164
+ __raise "#{intro} expected to have received #{method}, but that " \
165
+ "object is not a spy or method has not been stubbed."
166
+ end
167
+
168
+ # @private
169
+ def raise_expectation_on_mocked_method(method)
170
+ __raise "#{intro} expected to have received #{method}, but that " \
171
+ "method has been mocked instead of stubbed or spied."
172
+ end
173
+
174
+ # @private
175
+ def raise_double_negation_error(wrapped_expression)
176
+ __raise "Isn't life confusing enough? You've already set a " \
177
+ "negative message expectation and now you are trying to " \
178
+ "negate it again with `never`. What does an expression like " \
179
+ "`#{wrapped_expression}.not_to receive(:msg).never` even mean?"
180
+ end
181
+
182
+ # @private
183
+ def raise_verifying_double_not_defined_error(ref)
184
+ notify(VerifyingDoubleNotDefinedError.new(
185
+ "#{ref.description.inspect} is not a defined constant. " \
186
+ "Perhaps you misspelt it? " \
187
+ "Disable check with `verify_doubled_constant_names` configuration option."
188
+ ))
189
+ end
190
+
191
+ # @private
192
+ def raise_have_received_disallowed(type, reason)
193
+ __raise "Using #{type}(...) with the `have_received` " \
194
+ "matcher is not supported#{reason}."
195
+ end
196
+
197
+ # @private
198
+ def raise_cant_constrain_count_for_negated_have_received_error(count_constraint)
199
+ __raise "can't use #{count_constraint} when negative"
200
+ end
201
+
202
+ # @private
203
+ def raise_method_not_stubbed_error(method_name)
204
+ __raise "The method `#{method_name}` was not stubbed or was already unstubbed"
205
+ end
206
+
207
+ # @private
208
+ def raise_already_invoked_error(message, calling_customization)
209
+ error_message = "The message expectation for #{intro}.#{message} has already been invoked " \
210
+ "and cannot be modified further (e.g. using `#{calling_customization}`). All message expectation " \
211
+ "customizations must be applied before it is used for the first time."
212
+
213
+ notify MockExpectationAlreadyInvokedError.new(error_message)
214
+ end
215
+
216
+ private
217
+
218
+ def received_part_of_expectation_error(actual_received_count, args)
219
+ "received: #{count_message(actual_received_count)}" +
220
+ method_call_args_description(args) do
221
+ actual_received_count > 0 && args.length > 0
222
+ end
223
+ end
224
+
225
+ def expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher)
226
+ "expected: #{count_message(expected_received_count, expectation_count_type)}" +
227
+ method_call_args_description(argument_list_matcher.expected_args) do
228
+ argument_list_matcher.expected_args.length > 0
229
+ end
230
+ end
231
+
232
+ def method_call_args_description(args)
233
+ case args.first
234
+ when ArgumentMatchers::AnyArgsMatcher then " with any arguments"
235
+ when ArgumentMatchers::NoArgsMatcher then " with no arguments"
236
+ else
237
+ if yield
238
+ " with arguments: #{format_args(args)}"
239
+ else
240
+ ""
241
+ end
242
+ end
243
+ end
244
+
245
+ def unexpected_arguments_message(expected_args_string, actual_args_string)
246
+ "with unexpected arguments\n expected: #{expected_args_string}\n got: #{actual_args_string}"
247
+ end
248
+
249
+ def error_message(expectation, args_for_multiple_calls)
250
+ expected_args = format_args(expectation.expected_args)
251
+ actual_args = format_received_args(args_for_multiple_calls)
252
+ message = default_error_message(expectation, expected_args, actual_args)
253
+
254
+ if args_for_multiple_calls.one?
255
+ diff = diff_message(expectation.expected_args, args_for_multiple_calls.first)
256
+ message << "\nDiff:#{diff}" unless diff.strip.empty?
257
+ end
258
+
259
+ message
260
+ end
261
+
262
+ def diff_message(expected_args, actual_args)
263
+ formatted_expected_args = expected_args.map do |x|
264
+ RSpec::Support.rspec_description_for_object(x)
265
+ end
266
+
267
+ formatted_expected_args, actual_args = unpack_string_args(formatted_expected_args, actual_args)
268
+
269
+ differ.diff(actual_args, formatted_expected_args)
270
+ end
271
+
272
+ def unpack_string_args(formatted_expected_args, actual_args)
273
+ if [formatted_expected_args, actual_args].all? { |x| list_of_exactly_one_string?(x) }
274
+ [formatted_expected_args.first, actual_args.first]
275
+ else
276
+ [formatted_expected_args, actual_args]
277
+ end
278
+ end
279
+
280
+ def list_of_exactly_one_string?(args)
281
+ Array === args && args.count == 1 && String === args.first
282
+ end
283
+
284
+ def differ
285
+ RSpec::Support::Differ.new(:color => RSpec::Mocks.configuration.color?)
286
+ end
287
+
288
+ def intro(unwrapped=false)
289
+ case @target
290
+ when TestDouble then TestDoubleFormatter.format(@target, unwrapped)
291
+ when Class then
292
+ formatted = "#{@target.inspect} (class)"
293
+ return formatted if unwrapped
294
+ "#<#{formatted}>"
295
+ when NilClass then "nil"
296
+ else @target
297
+ end
298
+ end
299
+
300
+ def __raise(message, backtrace_line=nil, source_id=nil)
301
+ message = opts[:message] unless opts[:message].nil?
302
+ exception = RSpec::Mocks::MockExpectationError.new(message)
303
+ prepend_to_backtrace(exception, backtrace_line) if backtrace_line
304
+ notify exception, :source_id => source_id
305
+ end
306
+
307
+ if RSpec::Support::Ruby.jruby?
308
+ def prepend_to_backtrace(exception, line)
309
+ raise exception
310
+ rescue RSpec::Mocks::MockExpectationError => with_backtrace
311
+ with_backtrace.backtrace.unshift(line)
312
+ end
313
+ else
314
+ def prepend_to_backtrace(exception, line)
315
+ exception.set_backtrace(caller.unshift line)
316
+ end
317
+ end
318
+
319
+ def notify(*args)
320
+ RSpec::Support.notify_failure(*args)
321
+ end
322
+
323
+ def format_args(args)
324
+ return "(no args)" if args.empty?
325
+ "(#{arg_list(args)})"
326
+ end
327
+
328
+ def arg_list(args)
329
+ args.map { |arg| RSpec::Support::ObjectFormatter.format(arg) }.join(", ")
330
+ end
331
+
332
+ def format_received_args(args_for_multiple_calls)
333
+ grouped_args(args_for_multiple_calls).map do |args_for_one_call, index|
334
+ "#{format_args(args_for_one_call)}#{group_count(index, args_for_multiple_calls)}"
335
+ end.join("\n ")
336
+ end
337
+
338
+ def count_message(count, expectation_count_type=nil)
339
+ return "at least #{times(count.abs)}" if count < 0 || expectation_count_type == :at_least
340
+ return "at most #{times(count)}" if expectation_count_type == :at_most
341
+ times(count)
342
+ end
343
+
344
+ def times(count)
345
+ "#{count} time#{count == 1 ? '' : 's'}"
346
+ end
347
+
348
+ def grouped_args(args)
349
+ Hash[args.group_by { |x| x }.map { |k, v| [k, v.count] }]
350
+ end
351
+
352
+ def group_count(index, args)
353
+ " (#{times(index)})" if args.size > 1 || index > 1
354
+ end
355
+ end
356
+
357
+ # @private
358
+ def self.error_generator
359
+ @error_generator ||= ErrorGenerator.new
360
+ end
361
+ end
362
+ end
@@ -0,0 +1,421 @@
1
+ RSpec::Support.require_rspec_mocks 'object_reference'
2
+
3
+ module RSpec
4
+ module Mocks
5
+ # Contains methods intended to be used from within code examples.
6
+ # Mix this in to your test context (such as a test framework base class)
7
+ # to use rspec-mocks with your test framework. If you're using rspec-core,
8
+ # it'll take care of doing this for you.
9
+ module ExampleMethods
10
+ include RSpec::Mocks::ArgumentMatchers
11
+
12
+ # @overload double()
13
+ # @overload double(name)
14
+ # @param name [String/Symbol] name or description to be used in failure messages
15
+ # @overload double(stubs)
16
+ # @param stubs (Hash) hash of message/return-value pairs
17
+ # @overload double(name, stubs)
18
+ # @param name [String/Symbol] name or description to be used in failure messages
19
+ # @param stubs (Hash) hash of message/return-value pairs
20
+ # @return (Double)
21
+ #
22
+ # Constructs an instance of [RSpec::Mocks::Double](RSpec::Mocks::Double) configured
23
+ # with an optional name, used for reporting in failure messages, and an optional
24
+ # hash of message/return-value pairs.
25
+ #
26
+ # @example
27
+ # book = double("book", :title => "The RSpec Book")
28
+ # book.title #=> "The RSpec Book"
29
+ #
30
+ # card = double("card", :suit => "Spades", :rank => "A")
31
+ # card.suit #=> "Spades"
32
+ # card.rank #=> "A"
33
+ #
34
+ def double(*args)
35
+ ExampleMethods.declare_double(Double, *args)
36
+ end
37
+
38
+ # @overload instance_double(doubled_class)
39
+ # @param doubled_class [String, Class]
40
+ # @overload instance_double(doubled_class, name)
41
+ # @param doubled_class [String, Class]
42
+ # @param name [String/Symbol] name or description to be used in failure messages
43
+ # @overload instance_double(doubled_class, stubs)
44
+ # @param doubled_class [String, Class]
45
+ # @param stubs [Hash] hash of message/return-value pairs
46
+ # @overload instance_double(doubled_class, name, stubs)
47
+ # @param doubled_class [String, Class]
48
+ # @param name [String/Symbol] name or description to be used in failure messages
49
+ # @param stubs [Hash] hash of message/return-value pairs
50
+ # @return InstanceVerifyingDouble
51
+ #
52
+ # Constructs a test double against a specific class. If the given class
53
+ # name has been loaded, only instance methods defined on the class are
54
+ # allowed to be stubbed. In all other ways it behaves like a
55
+ # [double](double).
56
+ def instance_double(doubled_class, *args)
57
+ ref = ObjectReference.for(doubled_class)
58
+ ExampleMethods.declare_verifying_double(InstanceVerifyingDouble, ref, *args)
59
+ end
60
+
61
+ # @overload class_double(doubled_class)
62
+ # @param doubled_class [String, Module]
63
+ # @overload class_double(doubled_class, name)
64
+ # @param doubled_class [String, Module]
65
+ # @param name [String/Symbol] name or description to be used in failure messages
66
+ # @overload class_double(doubled_class, stubs)
67
+ # @param doubled_class [String, Module]
68
+ # @param stubs [Hash] hash of message/return-value pairs
69
+ # @overload class_double(doubled_class, name, stubs)
70
+ # @param doubled_class [String, Module]
71
+ # @param name [String/Symbol] name or description to be used in failure messages
72
+ # @param stubs [Hash] hash of message/return-value pairs
73
+ # @return ClassVerifyingDouble
74
+ #
75
+ # Constructs a test double against a specific class. If the given class
76
+ # name has been loaded, only class methods defined on the class are
77
+ # allowed to be stubbed. In all other ways it behaves like a
78
+ # [double](double).
79
+ def class_double(doubled_class, *args)
80
+ ref = ObjectReference.for(doubled_class)
81
+ ExampleMethods.declare_verifying_double(ClassVerifyingDouble, ref, *args)
82
+ end
83
+
84
+ # @overload object_double(object_or_name)
85
+ # @param object_or_name [String, Object]
86
+ # @overload object_double(object_or_name, name)
87
+ # @param object_or_name [String, Object]
88
+ # @param name [String/Symbol] name or description to be used in failure messages
89
+ # @overload object_double(object_or_name, stubs)
90
+ # @param object_or_name [String, Object]
91
+ # @param stubs [Hash] hash of message/return-value pairs
92
+ # @overload object_double(object_or_name, name, stubs)
93
+ # @param object_or_name [String, Object]
94
+ # @param name [String/Symbol] name or description to be used in failure messages
95
+ # @param stubs [Hash] hash of message/return-value pairs
96
+ # @return ObjectVerifyingDouble
97
+ #
98
+ # Constructs a test double against a specific object. Only the methods
99
+ # the object responds to are allowed to be stubbed. If a String argument
100
+ # is provided, it is assumed to reference a constant object which is used
101
+ # for verification. In all other ways it behaves like a [double](double).
102
+ def object_double(object_or_name, *args)
103
+ ref = ObjectReference.for(object_or_name, :allow_direct_object_refs)
104
+ ExampleMethods.declare_verifying_double(ObjectVerifyingDouble, ref, *args)
105
+ end
106
+
107
+ # @overload spy()
108
+ # @overload spy(name)
109
+ # @param name [String/Symbol] name or description to be used in failure messages
110
+ # @overload spy(stubs)
111
+ # @param stubs (Hash) hash of message/return-value pairs
112
+ # @overload spy(name, stubs)
113
+ # @param name [String/Symbol] name or description to be used in failure messages
114
+ # @param stubs (Hash) hash of message/return-value pairs
115
+ # @return (Double)
116
+ #
117
+ # Constructs a test double that is optimized for use with
118
+ # `have_received`. With a normal double one has to stub methods in order
119
+ # to be able to spy them. A spy automatically spies on all methods.
120
+ def spy(*args)
121
+ double(*args).as_null_object
122
+ end
123
+
124
+ # @overload instance_spy(doubled_class)
125
+ # @param doubled_class [String, Class]
126
+ # @overload instance_spy(doubled_class, name)
127
+ # @param doubled_class [String, Class]
128
+ # @param name [String/Symbol] name or description to be used in failure messages
129
+ # @overload instance_spy(doubled_class, stubs)
130
+ # @param doubled_class [String, Class]
131
+ # @param stubs [Hash] hash of message/return-value pairs
132
+ # @overload instance_spy(doubled_class, name, stubs)
133
+ # @param doubled_class [String, Class]
134
+ # @param name [String/Symbol] name or description to be used in failure messages
135
+ # @param stubs [Hash] hash of message/return-value pairs
136
+ # @return InstanceVerifyingDouble
137
+ #
138
+ # Constructs a test double that is optimized for use with `have_received`
139
+ # against a specific class. If the given class name has been loaded, only
140
+ # instance methods defined on the class are allowed to be stubbed. With
141
+ # a normal double one has to stub methods in order to be able to spy
142
+ # them. An instance_spy automatically spies on all instance methods to
143
+ # which the class responds.
144
+ def instance_spy(*args)
145
+ instance_double(*args).as_null_object
146
+ end
147
+
148
+ # @overload object_spy(object_or_name)
149
+ # @param object_or_name [String, Object]
150
+ # @overload object_spy(object_or_name, name)
151
+ # @param object_or_name [String, Class]
152
+ # @param name [String/Symbol] name or description to be used in failure messages
153
+ # @overload object_spy(object_or_name, stubs)
154
+ # @param object_or_name [String, Object]
155
+ # @param stubs [Hash] hash of message/return-value pairs
156
+ # @overload object_spy(object_or_name, name, stubs)
157
+ # @param object_or_name [String, Class]
158
+ # @param name [String/Symbol] name or description to be used in failure messages
159
+ # @param stubs [Hash] hash of message/return-value pairs
160
+ # @return ObjectVerifyingDouble
161
+ #
162
+ # Constructs a test double that is optimized for use with `have_received`
163
+ # against a specific object. Only instance methods defined on the object
164
+ # are allowed to be stubbed. With a normal double one has to stub
165
+ # methods in order to be able to spy them. An object_spy automatically
166
+ # spies on all methods to which the object responds.
167
+ def object_spy(*args)
168
+ object_double(*args).as_null_object
169
+ end
170
+
171
+ # @overload class_spy(doubled_class)
172
+ # @param doubled_class [String, Module]
173
+ # @overload class_spy(doubled_class, name)
174
+ # @param doubled_class [String, Class]
175
+ # @param name [String/Symbol] name or description to be used in failure messages
176
+ # @overload class_spy(doubled_class, stubs)
177
+ # @param doubled_class [String, Module]
178
+ # @param stubs [Hash] hash of message/return-value pairs
179
+ # @overload class_spy(doubled_class, name, stubs)
180
+ # @param doubled_class [String, Class]
181
+ # @param name [String/Symbol] name or description to be used in failure messages
182
+ # @param stubs [Hash] hash of message/return-value pairs
183
+ # @return ClassVerifyingDouble
184
+ #
185
+ # Constructs a test double that is optimized for use with `have_received`
186
+ # against a specific class. If the given class name has been loaded,
187
+ # only class methods defined on the class are allowed to be stubbed.
188
+ # With a normal double one has to stub methods in order to be able to spy
189
+ # them. An class_spy automatically spies on all class methods to which the
190
+ # class responds.
191
+ def class_spy(*args)
192
+ class_double(*args).as_null_object
193
+ end
194
+
195
+ # Disables warning messages about expectations being set on nil.
196
+ #
197
+ # By default warning messages are issued when expectations are set on
198
+ # nil. This is to prevent false-positives and to catch potential bugs
199
+ # early on.
200
+ def allow_message_expectations_on_nil
201
+ RSpec::Mocks.space.proxy_for(nil).warn_about_expectations = false
202
+ end
203
+
204
+ # Stubs the named constant with the given value.
205
+ # Like method stubs, the constant will be restored
206
+ # to its original value (or lack of one, if it was
207
+ # undefined) when the example completes.
208
+ #
209
+ # @param constant_name [String] The fully qualified name of the constant. The current
210
+ # constant scoping at the point of call is not considered.
211
+ # @param value [Object] The value to make the constant refer to. When the
212
+ # example completes, the constant will be restored to its prior state.
213
+ # @param options [Hash] Stubbing options.
214
+ # @option options :transfer_nested_constants [Boolean, Array<Symbol>] Determines
215
+ # what nested constants, if any, will be transferred from the original value
216
+ # of the constant to the new value of the constant. This only works if both
217
+ # the original and new values are modules (or classes).
218
+ # @return [Object] the stubbed value of the constant
219
+ #
220
+ # @example
221
+ # stub_const("MyClass", Class.new) # => Replaces (or defines) MyClass with a new class object.
222
+ # stub_const("SomeModel::PER_PAGE", 5) # => Sets SomeModel::PER_PAGE to 5.
223
+ #
224
+ # class CardDeck
225
+ # SUITS = [:Spades, :Diamonds, :Clubs, :Hearts]
226
+ # NUM_CARDS = 52
227
+ # end
228
+ #
229
+ # stub_const("CardDeck", Class.new)
230
+ # CardDeck::SUITS # => uninitialized constant error
231
+ # CardDeck::NUM_CARDS # => uninitialized constant error
232
+ #
233
+ # stub_const("CardDeck", Class.new, :transfer_nested_constants => true)
234
+ # CardDeck::SUITS # => our suits array
235
+ # CardDeck::NUM_CARDS # => 52
236
+ #
237
+ # stub_const("CardDeck", Class.new, :transfer_nested_constants => [:SUITS])
238
+ # CardDeck::SUITS # => our suits array
239
+ # CardDeck::NUM_CARDS # => uninitialized constant error
240
+ def stub_const(constant_name, value, options={})
241
+ ConstantMutator.stub(constant_name, value, options)
242
+ end
243
+
244
+ # Hides the named constant with the given value. The constant will be
245
+ # undefined for the duration of the test.
246
+ #
247
+ # Like method stubs, the constant will be restored to its original value
248
+ # when the example completes.
249
+ #
250
+ # @param constant_name [String] The fully qualified name of the constant.
251
+ # The current constant scoping at the point of call is not considered.
252
+ #
253
+ # @example
254
+ # hide_const("MyClass") # => MyClass is now an undefined constant
255
+ def hide_const(constant_name)
256
+ ConstantMutator.hide(constant_name)
257
+ end
258
+
259
+ # Verifies that the given object received the expected message during the
260
+ # course of the test. On a spy objects or as null object doubles this
261
+ # works for any method, on other objects the method must have
262
+ # been stubbed beforehand in order for messages to be verified.
263
+ #
264
+ # Stubbing and verifying messages received in this way implements the
265
+ # Test Spy pattern.
266
+ #
267
+ # @param method_name [Symbol] name of the method expected to have been
268
+ # called.
269
+ #
270
+ # @example
271
+ # invitation = double('invitation', accept: true)
272
+ # user.accept_invitation(invitation)
273
+ # expect(invitation).to have_received(:accept)
274
+ #
275
+ # # You can also use most message expectations:
276
+ # expect(invitation).to have_received(:accept).with(mailer).once
277
+ #
278
+ # @note `have_received(...).with(...)` is unable to work properly when
279
+ # passed arguments are mutated after the spy records the received message.
280
+ def have_received(method_name, &block)
281
+ Matchers::HaveReceived.new(method_name, &block)
282
+ end
283
+
284
+ # @method expect
285
+ # Used to wrap an object in preparation for setting a mock expectation
286
+ # on it.
287
+ #
288
+ # @example
289
+ # expect(obj).to receive(:foo).with(5).and_return(:return_value)
290
+ #
291
+ # @note This method is usually provided by rspec-expectations. However,
292
+ # if you use rspec-mocks without rspec-expectations, there's a definition
293
+ # of it that is made available here. If you disable the `:expect` syntax
294
+ # this method will be undefined.
295
+
296
+ # @method allow
297
+ # Used to wrap an object in preparation for stubbing a method
298
+ # on it.
299
+ #
300
+ # @example
301
+ # allow(dbl).to receive(:foo).with(5).and_return(:return_value)
302
+ #
303
+ # @note If you disable the `:expect` syntax this method will be undefined.
304
+
305
+ # @method expect_any_instance_of
306
+ # Used to wrap a class in preparation for setting a mock expectation
307
+ # on instances of it.
308
+ #
309
+ # @example
310
+ # expect_any_instance_of(MyClass).to receive(:foo)
311
+ #
312
+ # @note If you disable the `:expect` syntax this method will be undefined.
313
+
314
+ # @method allow_any_instance_of
315
+ # Used to wrap a class in preparation for stubbing a method
316
+ # on instances of it.
317
+ #
318
+ # @example
319
+ # allow_any_instance_of(MyClass).to receive(:foo)
320
+ #
321
+ # @note This is only available when you have enabled the `expect` syntax.
322
+
323
+ # @method receive
324
+ # Used to specify a message that you expect or allow an object
325
+ # to receive. The object returned by `receive` supports the same
326
+ # fluent interface that `should_receive` and `stub` have always
327
+ # supported, allowing you to constrain the arguments or number of
328
+ # times, and configure how the object should respond to the message.
329
+ #
330
+ # @example
331
+ # expect(obj).to receive(:hello).with("world").exactly(3).times
332
+ #
333
+ # @note If you disable the `:expect` syntax this method will be undefined.
334
+
335
+ # @method receive_messages
336
+ # Shorthand syntax used to setup message(s), and their return value(s),
337
+ # that you expect or allow an object to receive. The method takes a hash
338
+ # of messages and their respective return values. Unlike with `receive`,
339
+ # you cannot apply further customizations using a block or the fluent
340
+ # interface.
341
+ #
342
+ # @example
343
+ # allow(obj).to receive_messages(:speak => "Hello World")
344
+ # allow(obj).to receive_messages(:speak => "Hello", :meow => "Meow")
345
+ #
346
+ # @note If you disable the `:expect` syntax this method will be undefined.
347
+
348
+ # @method receive_message_chain
349
+ # @overload receive_message_chain(method1, method2)
350
+ # @overload receive_message_chain("method1.method2")
351
+ # @overload receive_message_chain(method1, method_to_value_hash)
352
+ #
353
+ # stubs/mocks a chain of messages on an object or test double.
354
+ #
355
+ # ## Warning:
356
+ #
357
+ # Chains can be arbitrarily long, which makes it quite painless to
358
+ # violate the Law of Demeter in violent ways, so you should consider any
359
+ # use of `receive_message_chain` a code smell. Even though not all code smells
360
+ # indicate real problems (think fluent interfaces), `receive_message_chain` still
361
+ # results in brittle examples. For example, if you write
362
+ # `allow(foo).to receive_message_chain(:bar, :baz => 37)` in a spec and then the
363
+ # implementation calls `foo.baz.bar`, the stub will not work.
364
+ #
365
+ # @example
366
+ # allow(double).to receive_message_chain("foo.bar") { :baz }
367
+ # allow(double).to receive_message_chain(:foo, :bar => :baz)
368
+ # allow(double).to receive_message_chain(:foo, :bar) { :baz }
369
+ #
370
+ # # Given any of ^^ these three forms ^^:
371
+ # double.foo.bar # => :baz
372
+ #
373
+ # # Common use in Rails/ActiveRecord:
374
+ # allow(Article).to receive_message_chain("recent.published") { [Article.new] }
375
+ #
376
+ # @note If you disable the `:expect` syntax this method will be undefined.
377
+
378
+ # @private
379
+ def self.included(klass)
380
+ klass.class_exec do
381
+ # This gets mixed in so that if `RSpec::Matchers` is included in
382
+ # `klass` later, it's definition of `expect` will take precedence.
383
+ include ExpectHost unless method_defined?(:expect)
384
+ end
385
+ end
386
+
387
+ # @private
388
+ def self.extended(object)
389
+ # This gets extended in so that if `RSpec::Matchers` is included in
390
+ # `klass` later, it's definition of `expect` will take precedence.
391
+ object.extend ExpectHost unless object.respond_to?(:expect)
392
+ end
393
+
394
+ # @private
395
+ def self.declare_verifying_double(type, ref, *args)
396
+ if RSpec::Mocks.configuration.verify_doubled_constant_names? &&
397
+ !ref.defined?
398
+
399
+ RSpec::Mocks.error_generator.raise_verifying_double_not_defined_error(ref)
400
+ end
401
+
402
+ RSpec::Mocks.configuration.verifying_double_callbacks.each do |block|
403
+ block.call(ref)
404
+ end
405
+
406
+ declare_double(type, ref, *args)
407
+ end
408
+
409
+ # @private
410
+ def self.declare_double(type, *args)
411
+ args << {} unless Hash === args.last
412
+ type.new(*args)
413
+ end
414
+
415
+ # This module exists to host the `expect` method for cases where
416
+ # rspec-mocks is used w/o rspec-expectations.
417
+ module ExpectHost
418
+ end
419
+ end
420
+ end
421
+ end