test_gem2_dh 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (449) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +35 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +43 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/test_gem2_dh.rb +9 -0
  14. data/lib/test_gem2_dh/version.rb +3 -0
  15. data/test_gem2_dh.gemspec +27 -0
  16. data/vendor/bundle/bin/htmldiff +24 -0
  17. data/vendor/bundle/bin/ldiff +24 -0
  18. data/vendor/bundle/bin/rake +22 -0
  19. data/vendor/bundle/bin/rspec +22 -0
  20. data/vendor/bundle/cache/diff-lcs-1.3.gem +0 -0
  21. data/vendor/bundle/cache/rake-10.5.0.gem +0 -0
  22. data/vendor/bundle/cache/rspec-3.6.0.gem +0 -0
  23. data/vendor/bundle/cache/rspec-core-3.6.0.gem +0 -0
  24. data/vendor/bundle/cache/rspec-expectations-3.6.0.gem +0 -0
  25. data/vendor/bundle/cache/rspec-mocks-3.6.0.gem +0 -0
  26. data/vendor/bundle/cache/rspec-support-3.6.0.gem +0 -0
  27. data/vendor/bundle/gems/diff-lcs-1.3/.rspec +1 -0
  28. data/vendor/bundle/gems/diff-lcs-1.3/Code-of-Conduct.md +74 -0
  29. data/vendor/bundle/gems/diff-lcs-1.3/Contributing.md +83 -0
  30. data/vendor/bundle/gems/diff-lcs-1.3/History.md +220 -0
  31. data/vendor/bundle/gems/diff-lcs-1.3/License.md +39 -0
  32. data/vendor/bundle/gems/diff-lcs-1.3/Manifest.txt +37 -0
  33. data/vendor/bundle/gems/diff-lcs-1.3/README.rdoc +84 -0
  34. data/vendor/bundle/gems/diff-lcs-1.3/Rakefile +57 -0
  35. data/vendor/bundle/gems/diff-lcs-1.3/autotest/discover.rb +1 -0
  36. data/vendor/bundle/gems/diff-lcs-1.3/bin/htmldiff +32 -0
  37. data/vendor/bundle/gems/diff-lcs-1.3/bin/ldiff +6 -0
  38. data/vendor/bundle/gems/diff-lcs-1.3/docs/COPYING.txt +339 -0
  39. data/vendor/bundle/gems/diff-lcs-1.3/docs/artistic.txt +127 -0
  40. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff-lcs.rb +3 -0
  41. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs.rb +725 -0
  42. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/array.rb +7 -0
  43. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/block.rb +37 -0
  44. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/callbacks.rb +322 -0
  45. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/change.rb +181 -0
  46. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/htmldiff.rb +149 -0
  47. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/hunk.rb +276 -0
  48. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/internals.rb +307 -0
  49. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/ldiff.rb +167 -0
  50. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/string.rb +5 -0
  51. data/vendor/bundle/gems/diff-lcs-1.3/spec/change_spec.rb +65 -0
  52. data/vendor/bundle/gems/diff-lcs-1.3/spec/diff_spec.rb +47 -0
  53. data/vendor/bundle/gems/diff-lcs-1.3/spec/fixtures/ds1.csv +50 -0
  54. data/vendor/bundle/gems/diff-lcs-1.3/spec/fixtures/ds2.csv +51 -0
  55. data/vendor/bundle/gems/diff-lcs-1.3/spec/hunk_spec.rb +72 -0
  56. data/vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb +49 -0
  57. data/vendor/bundle/gems/diff-lcs-1.3/spec/lcs_spec.rb +56 -0
  58. data/vendor/bundle/gems/diff-lcs-1.3/spec/ldiff_spec.rb +47 -0
  59. data/vendor/bundle/gems/diff-lcs-1.3/spec/patch_spec.rb +422 -0
  60. data/vendor/bundle/gems/diff-lcs-1.3/spec/sdiff_spec.rb +214 -0
  61. data/vendor/bundle/gems/diff-lcs-1.3/spec/spec_helper.rb +321 -0
  62. data/vendor/bundle/gems/diff-lcs-1.3/spec/traverse_balanced_spec.rb +310 -0
  63. data/vendor/bundle/gems/diff-lcs-1.3/spec/traverse_sequences_spec.rb +139 -0
  64. data/vendor/bundle/gems/rake-10.5.0/.autotest +7 -0
  65. data/vendor/bundle/gems/rake-10.5.0/.rubocop.yml +27 -0
  66. data/vendor/bundle/gems/rake-10.5.0/.togglerc +7 -0
  67. data/vendor/bundle/gems/rake-10.5.0/CONTRIBUTING.rdoc +38 -0
  68. data/vendor/bundle/gems/rake-10.5.0/History.rdoc +659 -0
  69. data/vendor/bundle/gems/rake-10.5.0/MIT-LICENSE +21 -0
  70. data/vendor/bundle/gems/rake-10.5.0/Manifest.txt +166 -0
  71. data/vendor/bundle/gems/rake-10.5.0/README.rdoc +139 -0
  72. data/vendor/bundle/gems/rake-10.5.0/Rakefile +81 -0
  73. data/vendor/bundle/gems/rake-10.5.0/bin/rake +33 -0
  74. data/vendor/bundle/gems/rake-10.5.0/doc/command_line_usage.rdoc +158 -0
  75. data/vendor/bundle/gems/rake-10.5.0/doc/example/Rakefile1 +38 -0
  76. data/vendor/bundle/gems/rake-10.5.0/doc/example/Rakefile2 +35 -0
  77. data/vendor/bundle/gems/rake-10.5.0/doc/example/a.c +6 -0
  78. data/vendor/bundle/gems/rake-10.5.0/doc/example/b.c +6 -0
  79. data/vendor/bundle/gems/rake-10.5.0/doc/example/main.c +11 -0
  80. data/vendor/bundle/gems/rake-10.5.0/doc/glossary.rdoc +42 -0
  81. data/vendor/bundle/gems/rake-10.5.0/doc/jamis.rb +591 -0
  82. data/vendor/bundle/gems/rake-10.5.0/doc/proto_rake.rdoc +127 -0
  83. data/vendor/bundle/gems/rake-10.5.0/doc/rake.1 +141 -0
  84. data/vendor/bundle/gems/rake-10.5.0/doc/rakefile.rdoc +624 -0
  85. data/vendor/bundle/gems/rake-10.5.0/doc/rational.rdoc +151 -0
  86. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.4.14.rdoc +23 -0
  87. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.4.15.rdoc +35 -0
  88. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.5.0.rdoc +53 -0
  89. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.5.3.rdoc +78 -0
  90. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.5.4.rdoc +46 -0
  91. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.6.0.rdoc +141 -0
  92. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.7.0.rdoc +119 -0
  93. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.7.1.rdoc +59 -0
  94. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.7.2.rdoc +121 -0
  95. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.7.3.rdoc +47 -0
  96. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.0.rdoc +114 -0
  97. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.2.rdoc +165 -0
  98. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.3.rdoc +112 -0
  99. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.4.rdoc +147 -0
  100. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.5.rdoc +53 -0
  101. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.6.rdoc +37 -0
  102. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.8.7.rdoc +55 -0
  103. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.0.rdoc +112 -0
  104. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.1.rdoc +52 -0
  105. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.2.2.rdoc +55 -0
  106. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.2.rdoc +49 -0
  107. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.3.rdoc +102 -0
  108. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.4.rdoc +60 -0
  109. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.5.rdoc +55 -0
  110. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-0.9.6.rdoc +64 -0
  111. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-10.0.0.rdoc +178 -0
  112. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-10.0.1.rdoc +58 -0
  113. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-10.0.2.rdoc +53 -0
  114. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-10.0.3.rdoc +191 -0
  115. data/vendor/bundle/gems/rake-10.5.0/doc/release_notes/rake-10.1.0.rdoc +61 -0
  116. data/vendor/bundle/gems/rake-10.5.0/lib/rake.rb +79 -0
  117. data/vendor/bundle/gems/rake-10.5.0/lib/rake/alt_system.rb +110 -0
  118. data/vendor/bundle/gems/rake-10.5.0/lib/rake/application.rb +790 -0
  119. data/vendor/bundle/gems/rake-10.5.0/lib/rake/backtrace.rb +23 -0
  120. data/vendor/bundle/gems/rake-10.5.0/lib/rake/clean.rb +76 -0
  121. data/vendor/bundle/gems/rake-10.5.0/lib/rake/cloneable.rb +16 -0
  122. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/.document +1 -0
  123. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/compositepublisher.rb +21 -0
  124. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/ftptools.rb +137 -0
  125. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/publisher.rb +81 -0
  126. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  127. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/sshpublisher.rb +61 -0
  128. data/vendor/bundle/gems/rake-10.5.0/lib/rake/contrib/sys.rb +4 -0
  129. data/vendor/bundle/gems/rake-10.5.0/lib/rake/cpu_counter.rb +125 -0
  130. data/vendor/bundle/gems/rake-10.5.0/lib/rake/default_loader.rb +14 -0
  131. data/vendor/bundle/gems/rake-10.5.0/lib/rake/dsl_definition.rb +201 -0
  132. data/vendor/bundle/gems/rake-10.5.0/lib/rake/early_time.rb +21 -0
  133. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ext/core.rb +25 -0
  134. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ext/module.rb +2 -0
  135. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ext/pathname.rb +25 -0
  136. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ext/string.rb +175 -0
  137. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ext/time.rb +18 -0
  138. data/vendor/bundle/gems/rake-10.5.0/lib/rake/file_creation_task.rb +24 -0
  139. data/vendor/bundle/gems/rake-10.5.0/lib/rake/file_list.rb +428 -0
  140. data/vendor/bundle/gems/rake-10.5.0/lib/rake/file_task.rb +46 -0
  141. data/vendor/bundle/gems/rake-10.5.0/lib/rake/file_utils.rb +128 -0
  142. data/vendor/bundle/gems/rake-10.5.0/lib/rake/file_utils_ext.rb +144 -0
  143. data/vendor/bundle/gems/rake-10.5.0/lib/rake/gempackagetask.rb +4 -0
  144. data/vendor/bundle/gems/rake-10.5.0/lib/rake/invocation_chain.rb +56 -0
  145. data/vendor/bundle/gems/rake-10.5.0/lib/rake/invocation_exception_mixin.rb +16 -0
  146. data/vendor/bundle/gems/rake-10.5.0/lib/rake/late_time.rb +17 -0
  147. data/vendor/bundle/gems/rake-10.5.0/lib/rake/linked_list.rb +103 -0
  148. data/vendor/bundle/gems/rake-10.5.0/lib/rake/loaders/makefile.rb +53 -0
  149. data/vendor/bundle/gems/rake-10.5.0/lib/rake/multi_task.rb +13 -0
  150. data/vendor/bundle/gems/rake-10.5.0/lib/rake/name_space.rb +38 -0
  151. data/vendor/bundle/gems/rake-10.5.0/lib/rake/packagetask.rb +199 -0
  152. data/vendor/bundle/gems/rake-10.5.0/lib/rake/pathmap.rb +3 -0
  153. data/vendor/bundle/gems/rake-10.5.0/lib/rake/phony.rb +15 -0
  154. data/vendor/bundle/gems/rake-10.5.0/lib/rake/private_reader.rb +20 -0
  155. data/vendor/bundle/gems/rake-10.5.0/lib/rake/promise.rb +99 -0
  156. data/vendor/bundle/gems/rake-10.5.0/lib/rake/pseudo_status.rb +29 -0
  157. data/vendor/bundle/gems/rake-10.5.0/lib/rake/rake_module.rb +38 -0
  158. data/vendor/bundle/gems/rake-10.5.0/lib/rake/rake_test_loader.rb +22 -0
  159. data/vendor/bundle/gems/rake-10.5.0/lib/rake/rdoctask.rb +4 -0
  160. data/vendor/bundle/gems/rake-10.5.0/lib/rake/ruby182_test_unit_fix.rb +29 -0
  161. data/vendor/bundle/gems/rake-10.5.0/lib/rake/rule_recursion_overflow_error.rb +20 -0
  162. data/vendor/bundle/gems/rake-10.5.0/lib/rake/runtest.rb +27 -0
  163. data/vendor/bundle/gems/rake-10.5.0/lib/rake/scope.rb +42 -0
  164. data/vendor/bundle/gems/rake-10.5.0/lib/rake/task.rb +383 -0
  165. data/vendor/bundle/gems/rake-10.5.0/lib/rake/task_argument_error.rb +7 -0
  166. data/vendor/bundle/gems/rake-10.5.0/lib/rake/task_arguments.rb +98 -0
  167. data/vendor/bundle/gems/rake-10.5.0/lib/rake/task_manager.rb +307 -0
  168. data/vendor/bundle/gems/rake-10.5.0/lib/rake/tasklib.rb +24 -0
  169. data/vendor/bundle/gems/rake-10.5.0/lib/rake/testtask.rb +213 -0
  170. data/vendor/bundle/gems/rake-10.5.0/lib/rake/thread_history_display.rb +48 -0
  171. data/vendor/bundle/gems/rake-10.5.0/lib/rake/thread_pool.rb +164 -0
  172. data/vendor/bundle/gems/rake-10.5.0/lib/rake/trace_output.rb +22 -0
  173. data/vendor/bundle/gems/rake-10.5.0/lib/rake/version.rb +7 -0
  174. data/vendor/bundle/gems/rake-10.5.0/lib/rake/win32.rb +56 -0
  175. data/vendor/bundle/gems/rake-10.5.0/rakelib/publish.rake +20 -0
  176. data/vendor/bundle/gems/rake-10.5.0/rakelib/test_times.rake +25 -0
  177. data/vendor/bundle/gems/rake-10.5.0/test/file_creation.rb +34 -0
  178. data/vendor/bundle/gems/rake-10.5.0/test/helper.rb +129 -0
  179. data/vendor/bundle/gems/rake-10.5.0/test/support/rakefile_definitions.rb +478 -0
  180. data/vendor/bundle/gems/rake-10.5.0/test/support/ruby_runner.rb +34 -0
  181. data/vendor/bundle/gems/rake-10.5.0/test/test_private_reader.rb +42 -0
  182. data/vendor/bundle/gems/rake-10.5.0/test/test_rake.rb +40 -0
  183. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_application.rb +643 -0
  184. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_application_options.rb +468 -0
  185. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_backtrace.rb +119 -0
  186. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_clean.rb +61 -0
  187. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_cpu_counter.rb +68 -0
  188. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_definitions.rb +84 -0
  189. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_directory_task.rb +76 -0
  190. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_dsl.rb +40 -0
  191. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_early_time.rb +31 -0
  192. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_extension.rb +59 -0
  193. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_file_creation_task.rb +56 -0
  194. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_file_list.rb +670 -0
  195. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_file_list_path_map.rb +8 -0
  196. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_file_task.rb +197 -0
  197. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_file_utils.rb +314 -0
  198. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_ftp_file.rb +74 -0
  199. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_functional.rb +482 -0
  200. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_invocation_chain.rb +64 -0
  201. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_late_time.rb +18 -0
  202. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_linked_list.rb +84 -0
  203. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_makefile_loader.rb +46 -0
  204. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_multi_task.rb +64 -0
  205. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_name_space.rb +57 -0
  206. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_package_task.rb +79 -0
  207. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_path_map.rb +168 -0
  208. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_path_map_explode.rb +34 -0
  209. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_path_map_partial.rb +18 -0
  210. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_pathname_extensions.rb +15 -0
  211. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_pseudo_status.rb +21 -0
  212. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_rake_test_loader.rb +20 -0
  213. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_reduce_compat.rb +26 -0
  214. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_require.rb +40 -0
  215. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_rules.rb +388 -0
  216. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_scope.rb +44 -0
  217. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task.rb +393 -0
  218. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_argument_parsing.rb +119 -0
  219. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_arguments.rb +127 -0
  220. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_lib.rb +9 -0
  221. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_manager.rb +178 -0
  222. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_manager_argument_resolution.rb +19 -0
  223. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_task_with_arguments.rb +172 -0
  224. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_test_task.rb +146 -0
  225. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_thread_pool.rb +145 -0
  226. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_top_level_functions.rb +71 -0
  227. data/vendor/bundle/gems/rake-10.5.0/test/test_rake_win32.rb +72 -0
  228. data/vendor/bundle/gems/rake-10.5.0/test/test_thread_history_display.rb +101 -0
  229. data/vendor/bundle/gems/rake-10.5.0/test/test_trace_output.rb +52 -0
  230. data/vendor/bundle/gems/rspec-3.6.0/LICENSE.md +27 -0
  231. data/vendor/bundle/gems/rspec-3.6.0/README.md +39 -0
  232. data/vendor/bundle/gems/rspec-3.6.0/lib/rspec.rb +3 -0
  233. data/vendor/bundle/gems/rspec-3.6.0/lib/rspec/version.rb +5 -0
  234. data/vendor/bundle/gems/rspec-core-3.6.0/.document +5 -0
  235. data/vendor/bundle/gems/rspec-core-3.6.0/.yardopts +8 -0
  236. data/vendor/bundle/gems/rspec-core-3.6.0/Changelog.md +2167 -0
  237. data/vendor/bundle/gems/rspec-core-3.6.0/LICENSE.md +26 -0
  238. data/vendor/bundle/gems/rspec-core-3.6.0/README.md +384 -0
  239. data/vendor/bundle/gems/rspec-core-3.6.0/exe/rspec +4 -0
  240. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/autorun.rb +3 -0
  241. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core.rb +185 -0
  242. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/backtrace_formatter.rb +65 -0
  243. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb +66 -0
  244. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb +169 -0
  245. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb +169 -0
  246. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/server.rb +70 -0
  247. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb +2177 -0
  248. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/configuration_options.rb +196 -0
  249. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/drb.rb +113 -0
  250. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/dsl.rb +98 -0
  251. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example.rb +653 -0
  252. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb +883 -0
  253. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example_status_persister.rb +235 -0
  254. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/filter_manager.rb +231 -0
  255. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/flat_map.rb +20 -0
  256. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters.rb +265 -0
  257. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/base_formatter.rb +70 -0
  258. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/base_text_formatter.rb +75 -0
  259. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/bisect_formatter.rb +69 -0
  260. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/bisect_progress_formatter.rb +144 -0
  261. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/console_codes.rb +68 -0
  262. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
  263. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/documentation_formatter.rb +70 -0
  264. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/exception_presenter.rb +496 -0
  265. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
  266. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/helpers.rb +110 -0
  267. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_formatter.rb +153 -0
  268. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_printer.rb +414 -0
  269. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_snippet_extractor.rb +118 -0
  270. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/json_formatter.rb +101 -0
  271. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/profile_formatter.rb +68 -0
  272. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/progress_formatter.rb +29 -0
  273. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/protocol.rb +182 -0
  274. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/snippet_extractor.rb +134 -0
  275. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
  276. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb +624 -0
  277. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/invocations.rb +85 -0
  278. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/memoized_helpers.rb +535 -0
  279. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/metadata.rb +499 -0
  280. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/metadata_filter.rb +255 -0
  281. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
  282. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
  283. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
  284. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/null.rb +14 -0
  285. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/rr.rb +31 -0
  286. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
  287. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/notifications.rb +514 -0
  288. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/option_parser.rb +309 -0
  289. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/ordering.rb +158 -0
  290. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/output_wrapper.rb +29 -0
  291. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/pending.rb +165 -0
  292. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/profiler.rb +32 -0
  293. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer.rb +48 -0
  294. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer/.rspec +1 -0
  295. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer/spec/spec_helper.rb +100 -0
  296. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/rake_task.rb +168 -0
  297. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb +260 -0
  298. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/ruby_project.rb +53 -0
  299. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb +193 -0
  300. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/sandbox.rb +37 -0
  301. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/set.rb +54 -0
  302. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shared_context.rb +55 -0
  303. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shared_example_group.rb +271 -0
  304. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shell_escape.rb +49 -0
  305. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  306. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/version.rb +9 -0
  307. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/warnings.rb +40 -0
  308. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/world.rb +264 -0
  309. data/vendor/bundle/gems/rspec-expectations-3.6.0/.document +5 -0
  310. data/vendor/bundle/gems/rspec-expectations-3.6.0/.yardopts +6 -0
  311. data/vendor/bundle/gems/rspec-expectations-3.6.0/Changelog.md +1072 -0
  312. data/vendor/bundle/gems/rspec-expectations-3.6.0/LICENSE.md +25 -0
  313. data/vendor/bundle/gems/rspec-expectations-3.6.0/README.md +305 -0
  314. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations.rb +82 -0
  315. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
  316. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/configuration.rb +201 -0
  317. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/expectation_target.rb +127 -0
  318. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/fail_with.rb +39 -0
  319. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/failure_aggregator.rb +194 -0
  320. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb +170 -0
  321. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/minitest_integration.rb +58 -0
  322. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/syntax.rb +132 -0
  323. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/version.rb +8 -0
  324. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers.rb +1025 -0
  325. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/aliased_matcher.rb +116 -0
  326. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in.rb +52 -0
  327. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/all.rb +85 -0
  328. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/base_matcher.rb +193 -0
  329. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be.rb +288 -0
  330. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_between.rb +77 -0
  331. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_instance_of.rb +22 -0
  332. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_kind_of.rb +16 -0
  333. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_within.rb +72 -0
  334. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/change.rb +387 -0
  335. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/compound.rb +272 -0
  336. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/contain_exactly.rb +301 -0
  337. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/cover.rb +24 -0
  338. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/eq.rb +40 -0
  339. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/eql.rb +34 -0
  340. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/equal.rb +81 -0
  341. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/exist.rb +90 -0
  342. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/has.rb +103 -0
  343. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
  344. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/include.rb +143 -0
  345. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/match.rb +106 -0
  346. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/operators.rb +128 -0
  347. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/output.rb +200 -0
  348. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/raise_error.rb +230 -0
  349. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/respond_to.rb +165 -0
  350. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/satisfy.rb +60 -0
  351. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
  352. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/throw_symbol.rb +132 -0
  353. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/yield.rb +432 -0
  354. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/composable.rb +169 -0
  355. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/dsl.rb +527 -0
  356. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/english_phrasing.rb +58 -0
  357. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +73 -0
  358. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/fail_matchers.rb +42 -0
  359. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/generated_descriptions.rb +42 -0
  360. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/matcher_delegator.rb +35 -0
  361. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/matcher_protocol.rb +99 -0
  362. data/vendor/bundle/gems/rspec-mocks-3.6.0/.document +5 -0
  363. data/vendor/bundle/gems/rspec-mocks-3.6.0/.yardopts +6 -0
  364. data/vendor/bundle/gems/rspec-mocks-3.6.0/Changelog.md +1073 -0
  365. data/vendor/bundle/gems/rspec-mocks-3.6.0/LICENSE.md +25 -0
  366. data/vendor/bundle/gems/rspec-mocks-3.6.0/README.md +460 -0
  367. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks.rb +130 -0
  368. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance.rb +11 -0
  369. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/chain.rb +110 -0
  370. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
  371. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/expect_chain_chain.rb +31 -0
  372. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/expectation_chain.rb +50 -0
  373. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/message_chains.rb +83 -0
  374. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/proxy.rb +116 -0
  375. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/recorder.rb +289 -0
  376. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/stub_chain.rb +51 -0
  377. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
  378. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/argument_list_matcher.rb +100 -0
  379. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/argument_matchers.rb +320 -0
  380. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/configuration.rb +212 -0
  381. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/error_generator.rb +369 -0
  382. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/example_methods.rb +434 -0
  383. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/instance_method_stasher.rb +146 -0
  384. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/marshal_extension.rb +41 -0
  385. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
  386. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/have_received.rb +130 -0
  387. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive.rb +132 -0
  388. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive_message_chain.rb +82 -0
  389. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive_messages.rb +77 -0
  390. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/message_chain.rb +87 -0
  391. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/message_expectation.rb +740 -0
  392. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/method_double.rb +287 -0
  393. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/method_reference.rb +202 -0
  394. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/minitest_integration.rb +68 -0
  395. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/mutate_const.rb +339 -0
  396. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/object_reference.rb +149 -0
  397. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/order_group.rb +81 -0
  398. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/proxy.rb +484 -0
  399. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/space.rb +238 -0
  400. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/standalone.rb +3 -0
  401. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/syntax.rb +325 -0
  402. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/targets.rb +124 -0
  403. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/test_double.rb +171 -0
  404. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_double.rb +129 -0
  405. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_message_expectation.rb +54 -0
  406. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_proxy.rb +220 -0
  407. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/version.rb +9 -0
  408. data/vendor/bundle/gems/rspec-support-3.6.0/Changelog.md +211 -0
  409. data/vendor/bundle/gems/rspec-support-3.6.0/LICENSE.md +23 -0
  410. data/vendor/bundle/gems/rspec-support-3.6.0/README.md +40 -0
  411. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support.rb +139 -0
  412. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/caller_filter.rb +83 -0
  413. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/comparable_version.rb +46 -0
  414. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/differ.rb +215 -0
  415. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/directory_maker.rb +63 -0
  416. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/encoded_string.rb +165 -0
  417. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/fuzzy_matcher.rb +48 -0
  418. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/hunk_generator.rb +47 -0
  419. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/matcher_definition.rb +42 -0
  420. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/method_signature_verifier.rb +392 -0
  421. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/mutex.rb +73 -0
  422. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/object_formatter.rb +268 -0
  423. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/recursive_const_methods.rb +76 -0
  424. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/reentrant_mutex.rb +53 -0
  425. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/ruby_features.rb +162 -0
  426. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source.rb +75 -0
  427. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/location.rb +21 -0
  428. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/node.rb +107 -0
  429. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/token.rb +87 -0
  430. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec.rb +81 -0
  431. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
  432. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/formatting_support.rb +9 -0
  433. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/in_sub_process.rb +69 -0
  434. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/library_wide_checks.rb +150 -0
  435. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/shell_out.rb +84 -0
  436. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/stderr_splitter.rb +63 -0
  437. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/string_matcher.rb +46 -0
  438. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/with_isolated_directory.rb +13 -0
  439. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  440. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/version.rb +7 -0
  441. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/warnings.rb +39 -0
  442. data/vendor/bundle/specifications/diff-lcs-1.3.gemspec +61 -0
  443. data/vendor/bundle/specifications/rake-10.5.0.gemspec +43 -0
  444. data/vendor/bundle/specifications/rspec-3.6.0.gemspec +42 -0
  445. data/vendor/bundle/specifications/rspec-core-3.6.0.gemspec +62 -0
  446. data/vendor/bundle/specifications/rspec-expectations-3.6.0.gemspec +50 -0
  447. data/vendor/bundle/specifications/rspec-mocks-3.6.0.gemspec +50 -0
  448. data/vendor/bundle/specifications/rspec-support-3.6.0.gemspec +41 -0
  449. metadata +533 -0
@@ -0,0 +1,70 @@
1
+ require 'drb/drb'
2
+ require 'drb/acl'
3
+
4
+ module RSpec
5
+ module Core
6
+ # @private
7
+ module Bisect
8
+ # @private
9
+ BisectFailedError = Class.new(StandardError)
10
+
11
+ # @private
12
+ # A DRb server that receives run results from a separate RSpec process
13
+ # started by the bisect process.
14
+ class Server
15
+ def self.run
16
+ server = new
17
+ server.start
18
+ yield server
19
+ ensure
20
+ server.stop
21
+ end
22
+
23
+ def capture_run_results(files_or_directories_to_run=[], expected_failures=[])
24
+ self.expected_failures = expected_failures
25
+ self.files_or_directories_to_run = files_or_directories_to_run
26
+ self.latest_run_results = nil
27
+ run_output = yield
28
+
29
+ if latest_run_results.nil? || latest_run_results.all_example_ids.empty?
30
+ raise_bisect_failed(run_output)
31
+ end
32
+
33
+ latest_run_results
34
+ end
35
+
36
+ def start
37
+ # Only allow remote DRb requests from this machine.
38
+ DRb.install_acl ACL.new(%w[ deny all allow localhost allow 127.0.0.1 ])
39
+
40
+ # We pass `nil` as the first arg to allow it to pick a DRb port.
41
+ @drb = DRb.start_service(nil, self)
42
+ end
43
+
44
+ def stop
45
+ @drb.stop_service
46
+ end
47
+
48
+ def drb_port
49
+ @drb_port ||= Integer(@drb.uri[/\d+$/])
50
+ end
51
+
52
+ # Fetched via DRb by the BisectFormatter to determine when to abort.
53
+ attr_accessor :expected_failures
54
+
55
+ # Set via DRb by the BisectFormatter with the results of the run.
56
+ attr_accessor :latest_run_results
57
+
58
+ # Fetched via DRb to tell clients which files to run
59
+ attr_accessor :files_or_directories_to_run
60
+
61
+ private
62
+
63
+ def raise_bisect_failed(run_output)
64
+ raise BisectFailedError, "Failed to get results from the spec " \
65
+ "run. Spec run output:\n\n#{run_output}"
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,2177 @@
1
+ RSpec::Support.require_rspec_core "backtrace_formatter"
2
+ RSpec::Support.require_rspec_core "ruby_project"
3
+ RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
4
+ RSpec::Support.require_rspec_core "output_wrapper"
5
+
6
+ module RSpec
7
+ module Core
8
+ # rubocop:disable Metrics/ClassLength
9
+
10
+ # Stores runtime configuration information.
11
+ #
12
+ # Configuration options are loaded from `~/.rspec`, `.rspec`,
13
+ # `.rspec-local`, command line switches, and the `SPEC_OPTS` environment
14
+ # variable (listed in lowest to highest precedence; for example, an option
15
+ # in `~/.rspec` can be overridden by an option in `.rspec-local`).
16
+ #
17
+ # @example Standard settings
18
+ # RSpec.configure do |c|
19
+ # c.drb = true
20
+ # c.drb_port = 1234
21
+ # c.default_path = 'behavior'
22
+ # end
23
+ #
24
+ # @example Hooks
25
+ # RSpec.configure do |c|
26
+ # c.before(:suite) { establish_connection }
27
+ # c.before(:example) { log_in_as :authorized }
28
+ # c.around(:example) { |ex| Database.transaction(&ex) }
29
+ # end
30
+ #
31
+ # @see RSpec.configure
32
+ # @see Hooks
33
+ class Configuration
34
+ include RSpec::Core::Hooks
35
+
36
+ # Module that holds `attr_reader` declarations. It's in a separate
37
+ # module to allow us to override those methods and use `super`.
38
+ # @private
39
+ Readers = Module.new
40
+ include Readers
41
+
42
+ # @private
43
+ class MustBeConfiguredBeforeExampleGroupsError < StandardError; end
44
+
45
+ # @private
46
+ def self.define_reader(name)
47
+ Readers.class_eval do
48
+ remove_method name if method_defined?(name)
49
+ attr_reader name
50
+ end
51
+
52
+ define_method(name) { value_for(name) { super() } }
53
+ end
54
+
55
+ # @private
56
+ def self.define_aliases(name, alias_name)
57
+ alias_method alias_name, name
58
+ alias_method "#{alias_name}=", "#{name}="
59
+ define_predicate_for alias_name
60
+ end
61
+
62
+ # @private
63
+ def self.define_predicate_for(*names)
64
+ names.each { |name| alias_method "#{name}?", name }
65
+ end
66
+
67
+ # @private
68
+ #
69
+ # Invoked by the `add_setting` instance method. Use that method on a
70
+ # `Configuration` instance rather than this class method.
71
+ def self.add_setting(name, opts={})
72
+ raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
73
+ attr_writer name
74
+ add_read_only_setting name
75
+
76
+ Array(opts[:alias_with]).each do |alias_name|
77
+ define_aliases(name, alias_name)
78
+ end
79
+ end
80
+
81
+ # @private
82
+ #
83
+ # As `add_setting` but only add the reader.
84
+ def self.add_read_only_setting(name, opts={})
85
+ raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
86
+ define_reader name
87
+ define_predicate_for name
88
+ end
89
+
90
+ # @macro [attach] add_setting
91
+ # @!attribute [rw] $1
92
+ # @!method $1=(value)
93
+ #
94
+ # @macro [attach] define_reader
95
+ # @!attribute [r] $1
96
+
97
+ # @macro add_setting
98
+ # Path to use if no path is provided to the `rspec` command (default:
99
+ # `"spec"`). Allows you to just type `rspec` instead of `rspec spec` to
100
+ # run all the examples in the `spec` directory.
101
+ #
102
+ # @note Other scripts invoking `rspec` indirectly will ignore this
103
+ # setting.
104
+ add_read_only_setting :default_path
105
+ def default_path=(path)
106
+ project_source_dirs << path
107
+ @default_path = path
108
+ end
109
+
110
+ # @macro add_setting
111
+ # Run examples over DRb (default: `false`). RSpec doesn't supply the DRb
112
+ # server, but you can use tools like spork.
113
+ add_setting :drb
114
+
115
+ # @macro add_setting
116
+ # The drb_port (default: nil).
117
+ add_setting :drb_port
118
+
119
+ # @macro add_setting
120
+ # Default: `$stderr`.
121
+ add_setting :error_stream
122
+
123
+ # Indicates if the DSL has been exposed off of modules and `main`.
124
+ # Default: true
125
+ def expose_dsl_globally?
126
+ Core::DSL.exposed_globally?
127
+ end
128
+
129
+ # Use this to expose the core RSpec DSL via `Module` and the `main`
130
+ # object. It will be set automatically but you can override it to
131
+ # remove the DSL.
132
+ # Default: true
133
+ def expose_dsl_globally=(value)
134
+ if value
135
+ Core::DSL.expose_globally!
136
+ Core::SharedExampleGroup::TopLevelDSL.expose_globally!
137
+ else
138
+ Core::DSL.remove_globally!
139
+ Core::SharedExampleGroup::TopLevelDSL.remove_globally!
140
+ end
141
+ end
142
+
143
+ # Determines where deprecation warnings are printed.
144
+ # Defaults to `$stderr`.
145
+ # @return [IO, String] IO or filename to write to
146
+ define_reader :deprecation_stream
147
+
148
+ # Determines where deprecation warnings are printed.
149
+ # @param value [IO, String] IO to write to or filename to write to
150
+ def deprecation_stream=(value)
151
+ if @reporter && !value.equal?(@deprecation_stream)
152
+ warn "RSpec's reporter has already been initialized with " \
153
+ "#{deprecation_stream.inspect} as the deprecation stream, so your change to "\
154
+ "`deprecation_stream` will be ignored. You should configure it earlier for " \
155
+ "it to take effect, or use the `--deprecation-out` CLI option. " \
156
+ "(Called from #{CallerFilter.first_non_rspec_line})"
157
+ else
158
+ @deprecation_stream = value
159
+ end
160
+ end
161
+
162
+ # @macro define_reader
163
+ # The file path to use for persisting example statuses. Necessary for the
164
+ # `--only-failures` and `--next-failures` CLI options.
165
+ #
166
+ # @overload example_status_persistence_file_path
167
+ # @return [String] the file path
168
+ # @overload example_status_persistence_file_path=(value)
169
+ # @param value [String] the file path
170
+ define_reader :example_status_persistence_file_path
171
+
172
+ # Sets the file path to use for persisting example statuses. Necessary for the
173
+ # `--only-failures` and `--next-failures` CLI options.
174
+ def example_status_persistence_file_path=(value)
175
+ @example_status_persistence_file_path = value
176
+ clear_values_derived_from_example_status_persistence_file_path
177
+ end
178
+
179
+ # @macro define_reader
180
+ # Indicates if the `--only-failures` (or `--next-failure`) flag is being used.
181
+ define_reader :only_failures
182
+ alias_method :only_failures?, :only_failures
183
+
184
+ # @private
185
+ def only_failures_but_not_configured?
186
+ only_failures? && !example_status_persistence_file_path
187
+ end
188
+
189
+ # @macro add_setting
190
+ # If specified, indicates the number of failures required before cleaning
191
+ # up and exit (default: `nil`).
192
+ add_setting :fail_fast
193
+
194
+ # @macro add_setting
195
+ # Prints the formatter output of your suite without running any
196
+ # examples or hooks.
197
+ add_setting :dry_run
198
+
199
+ # @macro add_setting
200
+ # The exit code to return if there are any failures (default: 1).
201
+ add_setting :failure_exit_code
202
+
203
+ # @macro add_setting
204
+ # Whether or not to fail when there are no RSpec examples (default: false).
205
+ add_setting :fail_if_no_examples
206
+
207
+ # @macro define_reader
208
+ # Indicates files configured to be required.
209
+ define_reader :requires
210
+
211
+ # @macro define_reader
212
+ # Returns dirs that have been prepended to the load path by the `-I`
213
+ # command line option.
214
+ define_reader :libs
215
+
216
+ # @macro add_setting
217
+ # Determines where RSpec will send its output.
218
+ # Default: `$stdout`.
219
+ define_reader :output_stream
220
+
221
+ # Set the output stream for reporter.
222
+ # @attr value [IO, String] IO to write to or filename to write to, defaults to $stdout
223
+ def output_stream=(value)
224
+ if @reporter && !value.equal?(@output_stream)
225
+ warn "RSpec's reporter has already been initialized with " \
226
+ "#{output_stream.inspect} as the output stream, so your change to "\
227
+ "`output_stream` will be ignored. You should configure it earlier for " \
228
+ "it to take effect. (Called from #{CallerFilter.first_non_rspec_line})"
229
+ else
230
+ @output_stream = value
231
+ output_wrapper.output = @output_stream
232
+ end
233
+ end
234
+
235
+ # @macro define_reader
236
+ # Load files matching this pattern (default: `'**{,/*/**}/*_spec.rb'`).
237
+ define_reader :pattern
238
+
239
+ # Set pattern to match files to load.
240
+ # @attr value [String] the filename pattern to filter spec files by
241
+ def pattern=(value)
242
+ update_pattern_attr :pattern, value
243
+ end
244
+
245
+ # @macro define_reader
246
+ # Exclude files matching this pattern.
247
+ define_reader :exclude_pattern
248
+
249
+ # Set pattern to match files to exclude.
250
+ # @attr value [String] the filename pattern to exclude spec files by
251
+ def exclude_pattern=(value)
252
+ update_pattern_attr :exclude_pattern, value
253
+ end
254
+
255
+ # @macro add_setting
256
+ # Specifies which directories contain the source code for your project.
257
+ # When a failure occurs, RSpec looks through the backtrace to find a
258
+ # a line of source to print. It first looks for a line coming from
259
+ # one of the project source directories so that, for example, it prints
260
+ # the expectation or assertion call rather than the source code from
261
+ # the expectation or assertion framework.
262
+ # @return [Array<String>]
263
+ add_setting :project_source_dirs
264
+
265
+ # @macro add_setting
266
+ # Report the times for the slowest examples (default: `false`).
267
+ # Use this to specify the number of examples to include in the profile.
268
+ add_setting :profile_examples
269
+
270
+ # @macro add_setting
271
+ # Run all examples if none match the configured filters
272
+ # (default: `false`).
273
+ # @deprecated Use {#filter_run_when_matching} instead for the specific
274
+ # filters that you want to be ignored if none match.
275
+ add_setting :run_all_when_everything_filtered
276
+
277
+ # @macro add_setting
278
+ # Color to use to indicate success.
279
+ # @param color [Symbol] defaults to `:green` but can be set to one of the
280
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
281
+ # :cyan]`
282
+ add_setting :success_color
283
+
284
+ # @macro add_setting
285
+ # Color to use to print pending examples.
286
+ # @param color [Symbol] defaults to `:yellow` but can be set to one of the
287
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
288
+ # :cyan]`
289
+ add_setting :pending_color
290
+
291
+ # @macro add_setting
292
+ # Color to use to indicate failure.
293
+ # @param color [Symbol] defaults to `:red` but can be set to one of the
294
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
295
+ # :cyan]`
296
+ add_setting :failure_color
297
+
298
+ # @macro add_setting
299
+ # The default output color.
300
+ # @param color [Symbol] defaults to `:white` but can be set to one of the
301
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
302
+ # :cyan]`
303
+ add_setting :default_color
304
+
305
+ # @macro add_setting
306
+ # Color used when a pending example is fixed.
307
+ # @param color [Symbol] defaults to `:blue` but can be set to one of the
308
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
309
+ # :cyan]`
310
+ add_setting :fixed_color
311
+
312
+ # @macro add_setting
313
+ # Color used to print details.
314
+ # @param color [Symbol] defaults to `:cyan` but can be set to one of the
315
+ # following: `[:black, :white, :red, :green, :yellow, :blue, :magenta,
316
+ # :cyan]`
317
+ add_setting :detail_color
318
+
319
+ # @macro add_setting
320
+ # Don't print filter info i.e. "Run options: include {:focus=>true}"
321
+ # (default `false`).
322
+ add_setting :silence_filter_announcements
323
+
324
+ # Deprecated. This config option was added in RSpec 2 to pave the way
325
+ # for this being the default behavior in RSpec 3. Now this option is
326
+ # a no-op.
327
+ def treat_symbols_as_metadata_keys_with_true_values=(_value)
328
+ RSpec.deprecate(
329
+ "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
330
+ :message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \
331
+ "is deprecated, it is now set to true as default and " \
332
+ "setting it to false has no effect."
333
+ )
334
+ end
335
+
336
+ # @macro define_reader
337
+ # Configures how RSpec treats metadata passed as part of a shared example
338
+ # group definition. For example, given this shared example group definition:
339
+ #
340
+ # RSpec.shared_context "uses DB", :db => true do
341
+ # around(:example) do |ex|
342
+ # MyORM.transaction(:rollback => true, &ex)
343
+ # end
344
+ # end
345
+ #
346
+ # ...there are two ways RSpec can treat the `:db => true` metadata, each
347
+ # of which has a corresponding config option:
348
+ #
349
+ # 1. `:trigger_inclusion`: this shared context will be implicitly included
350
+ # in any groups (or examples) that have `:db => true` metadata.
351
+ # 2. `:apply_to_host_groups`: the metadata will be inherited by the metadata
352
+ # hash of all host groups and examples.
353
+ #
354
+ # `:trigger_inclusion` is the legacy behavior from before RSpec 3.5 but should
355
+ # be considered deprecated. Instead, you can explicitly include a group with
356
+ # `include_context`:
357
+ #
358
+ # RSpec.describe "My model" do
359
+ # include_context "uses DB"
360
+ # end
361
+ #
362
+ # ...or you can configure RSpec to include the context based on matching metadata
363
+ # using an API that mirrors configured module inclusion:
364
+ #
365
+ # RSpec.configure do |rspec|
366
+ # rspec.include_context "uses DB", :db => true
367
+ # end
368
+ #
369
+ # `:apply_to_host_groups` is a new feature of RSpec 3.5 and will be the only
370
+ # supported behavior in RSpec 4.
371
+ #
372
+ # @overload shared_context_metadata_behavior
373
+ # @return [:trigger_inclusion, :apply_to_host_groups] the configured behavior
374
+ # @overload shared_context_metadata_behavior=(value)
375
+ # @param value [:trigger_inclusion, :apply_to_host_groups] sets the configured behavior
376
+ define_reader :shared_context_metadata_behavior
377
+ # @see shared_context_metadata_behavior
378
+ def shared_context_metadata_behavior=(value)
379
+ case value
380
+ when :trigger_inclusion, :apply_to_host_groups
381
+ @shared_context_metadata_behavior = value
382
+ else
383
+ raise ArgumentError, "Cannot set `RSpec.configuration." \
384
+ "shared_context_metadata_behavior` to `#{value.inspect}`. Only " \
385
+ "`:trigger_inclusion` and `:apply_to_host_groups` are valid values."
386
+ end
387
+ end
388
+
389
+ # Record the start time of the spec suite to measure load time.
390
+ add_setting :start_time
391
+
392
+ # @macro add_setting
393
+ # Use threadsafe options where available.
394
+ # Currently this will place a mutex around memoized values such as let blocks.
395
+ add_setting :threadsafe
396
+
397
+ # @macro add_setting
398
+ # Maximum count of failed source lines to display in the failure reports.
399
+ # (default `10`).
400
+ add_setting :max_displayed_failure_line_count
401
+
402
+ # @private
403
+ # @deprecated Use {#color_mode} = :on, instead of {#color} with {#tty}
404
+ add_setting :tty
405
+ # @private
406
+ attr_writer :files_to_run
407
+ # @private
408
+ attr_accessor :filter_manager, :world
409
+ # @private
410
+ attr_accessor :static_config_filter_manager
411
+ # @private
412
+ attr_reader :backtrace_formatter, :ordering_manager, :loaded_spec_files
413
+
414
+ # rubocop:disable Metrics/AbcSize
415
+ # rubocop:disable Metrics/MethodLength
416
+ def initialize
417
+ # rubocop:disable Style/GlobalVars
418
+ @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
419
+ # rubocop:enable Style/GlobalVars
420
+ @expectation_frameworks = []
421
+ @include_modules = FilterableItemRepository::QueryOptimized.new(:any?)
422
+ @extend_modules = FilterableItemRepository::QueryOptimized.new(:any?)
423
+ @prepend_modules = FilterableItemRepository::QueryOptimized.new(:any?)
424
+
425
+ @before_suite_hooks = []
426
+ @after_suite_hooks = []
427
+
428
+ @mock_framework = nil
429
+ @files_or_directories_to_run = []
430
+ @loaded_spec_files = Set.new
431
+ @color = false
432
+ @color_mode = :automatic
433
+ @pattern = '**{,/*/**}/*_spec.rb'
434
+ @exclude_pattern = ''
435
+ @failure_exit_code = 1
436
+ @fail_if_no_examples = false
437
+ @spec_files_loaded = false
438
+
439
+ @backtrace_formatter = BacktraceFormatter.new
440
+
441
+ @default_path = 'spec'
442
+ @project_source_dirs = %w[ spec lib app ]
443
+ @deprecation_stream = $stderr
444
+ @output_stream = $stdout
445
+ @reporter = nil
446
+ @reporter_buffer = nil
447
+ @filter_manager = FilterManager.new
448
+ @static_config_filter_manager = FilterManager.new
449
+ @ordering_manager = Ordering::ConfigurationManager.new
450
+ @preferred_options = {}
451
+ @failure_color = :red
452
+ @success_color = :green
453
+ @pending_color = :yellow
454
+ @default_color = :white
455
+ @fixed_color = :blue
456
+ @detail_color = :cyan
457
+ @profile_examples = false
458
+ @requires = []
459
+ @libs = []
460
+ @derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
461
+ @threadsafe = true
462
+ @max_displayed_failure_line_count = 10
463
+ @world = World::Null
464
+ @shared_context_metadata_behavior = :trigger_inclusion
465
+
466
+ define_built_in_hooks
467
+ end
468
+ # rubocop:enable Metrics/MethodLength
469
+ # rubocop:enable Metrics/AbcSize
470
+
471
+ # @private
472
+ #
473
+ # Used to set higher priority option values from the command line.
474
+ def force(hash)
475
+ ordering_manager.force(hash)
476
+ @preferred_options.merge!(hash)
477
+
478
+ return unless hash.key?(:example_status_persistence_file_path)
479
+ clear_values_derived_from_example_status_persistence_file_path
480
+ end
481
+
482
+ # @private
483
+ def reset
484
+ @spec_files_loaded = false
485
+ reset_reporter
486
+ end
487
+
488
+ # @private
489
+ def reset_reporter
490
+ @reporter = nil
491
+ @formatter_loader = nil
492
+ @output_wrapper = nil
493
+ end
494
+
495
+ # @private
496
+ def reset_filters
497
+ self.filter_manager = FilterManager.new
498
+ filter_manager.include_only(
499
+ Metadata.deep_hash_dup(static_config_filter_manager.inclusions.rules)
500
+ )
501
+ filter_manager.exclude_only(
502
+ Metadata.deep_hash_dup(static_config_filter_manager.exclusions.rules)
503
+ )
504
+ end
505
+
506
+ # @overload add_setting(name)
507
+ # @overload add_setting(name, opts)
508
+ # @option opts [Symbol] :default
509
+ #
510
+ # Set a default value for the generated getter and predicate methods:
511
+ #
512
+ # add_setting(:foo, :default => "default value")
513
+ #
514
+ # @option opts [Symbol] :alias_with
515
+ #
516
+ # Use `:alias_with` to alias the setter, getter, and predicate to
517
+ # another name, or names:
518
+ #
519
+ # add_setting(:foo, :alias_with => :bar)
520
+ # add_setting(:foo, :alias_with => [:bar, :baz])
521
+ #
522
+ # Adds a custom setting to the RSpec.configuration object.
523
+ #
524
+ # RSpec.configuration.add_setting :foo
525
+ #
526
+ # Used internally and by extension frameworks like rspec-rails, so they
527
+ # can add config settings that are domain specific. For example:
528
+ #
529
+ # RSpec.configure do |c|
530
+ # c.add_setting :use_transactional_fixtures,
531
+ # :default => true,
532
+ # :alias_with => :use_transactional_examples
533
+ # end
534
+ #
535
+ # `add_setting` creates three methods on the configuration object, a
536
+ # setter, a getter, and a predicate:
537
+ #
538
+ # RSpec.configuration.foo=(value)
539
+ # RSpec.configuration.foo
540
+ # RSpec.configuration.foo? # Returns true if foo returns anything but nil or false.
541
+ def add_setting(name, opts={})
542
+ default = opts.delete(:default)
543
+ (class << self; self; end).class_exec do
544
+ add_setting(name, opts)
545
+ end
546
+ __send__("#{name}=", default) if default
547
+ end
548
+
549
+ # Returns the configured mock framework adapter module.
550
+ def mock_framework
551
+ if @mock_framework.nil?
552
+ begin
553
+ mock_with :rspec
554
+ rescue LoadError
555
+ mock_with :nothing
556
+ end
557
+ end
558
+ @mock_framework
559
+ end
560
+
561
+ # Delegates to mock_framework=(framework).
562
+ def mock_framework=(framework)
563
+ mock_with framework
564
+ end
565
+
566
+ # Regexps used to exclude lines from backtraces.
567
+ #
568
+ # Excludes lines from ruby (and jruby) source, installed gems, anything
569
+ # in any "bin" directory, and any of the RSpec libs (outside gem
570
+ # installs) by default.
571
+ #
572
+ # You can modify the list via the getter, or replace it with the setter.
573
+ #
574
+ # To override this behaviour and display a full backtrace, use
575
+ # `--backtrace` on the command line, in a `.rspec` file, or in the
576
+ # `rspec_options` attribute of RSpec's rake task.
577
+ def backtrace_exclusion_patterns
578
+ @backtrace_formatter.exclusion_patterns
579
+ end
580
+
581
+ # Set regular expressions used to exclude lines in backtrace.
582
+ # @param patterns [Regexp] set the backtrace exlusion pattern
583
+ def backtrace_exclusion_patterns=(patterns)
584
+ @backtrace_formatter.exclusion_patterns = patterns
585
+ end
586
+
587
+ # Regexps used to include lines in backtraces.
588
+ #
589
+ # Defaults to [Regexp.new Dir.getwd].
590
+ #
591
+ # Lines that match an exclusion _and_ an inclusion pattern
592
+ # will be included.
593
+ #
594
+ # You can modify the list via the getter, or replace it with the setter.
595
+ def backtrace_inclusion_patterns
596
+ @backtrace_formatter.inclusion_patterns
597
+ end
598
+
599
+ # Set regular expressions used to include lines in backtrace.
600
+ # @attr patterns [Regexp] set backtrace_formatter inclusion_patterns
601
+ def backtrace_inclusion_patterns=(patterns)
602
+ @backtrace_formatter.inclusion_patterns = patterns
603
+ end
604
+
605
+ # Adds {#backtrace_exclusion_patterns} that will filter lines from
606
+ # the named gems from backtraces.
607
+ #
608
+ # @param gem_names [Array<String>] Names of the gems to filter
609
+ #
610
+ # @example
611
+ # RSpec.configure do |config|
612
+ # config.filter_gems_from_backtrace "rack", "rake"
613
+ # end
614
+ #
615
+ # @note The patterns this adds will match the named gems in their common
616
+ # locations (e.g. system gems, vendored with bundler, installed as a
617
+ # :git dependency with bundler, etc) but is not guaranteed to work for
618
+ # all possible gem locations. For example, if you have the gem source
619
+ # in a directory with a completely unrelated name, and use bundler's
620
+ # :path option, this will not filter it.
621
+ def filter_gems_from_backtrace(*gem_names)
622
+ gem_names.each do |name|
623
+ @backtrace_formatter.filter_gem(name)
624
+ end
625
+ end
626
+
627
+ # @private
628
+ MOCKING_ADAPTERS = {
629
+ :rspec => :RSpec,
630
+ :flexmock => :Flexmock,
631
+ :rr => :RR,
632
+ :mocha => :Mocha,
633
+ :nothing => :Null
634
+ }
635
+
636
+ # Sets the mock framework adapter module.
637
+ #
638
+ # `framework` can be a Symbol or a Module.
639
+ #
640
+ # Given any of `:rspec`, `:mocha`, `:flexmock`, or `:rr`, configures the
641
+ # named framework.
642
+ #
643
+ # Given `:nothing`, configures no framework. Use this if you don't use
644
+ # any mocking framework to save a little bit of overhead.
645
+ #
646
+ # Given a Module, includes that module in every example group. The module
647
+ # should adhere to RSpec's mock framework adapter API:
648
+ #
649
+ # setup_mocks_for_rspec
650
+ # - called before each example
651
+ #
652
+ # verify_mocks_for_rspec
653
+ # - called after each example if the example hasn't yet failed.
654
+ # Framework should raise an exception when expectations fail
655
+ #
656
+ # teardown_mocks_for_rspec
657
+ # - called after verify_mocks_for_rspec (even if there are errors)
658
+ #
659
+ # If the module responds to `configuration` and `mock_with` receives a
660
+ # block, it will yield the configuration object to the block e.g.
661
+ #
662
+ # config.mock_with OtherMockFrameworkAdapter do |mod_config|
663
+ # mod_config.custom_setting = true
664
+ # end
665
+ def mock_with(framework)
666
+ framework_module =
667
+ if framework.is_a?(Module)
668
+ framework
669
+ else
670
+ const_name = MOCKING_ADAPTERS.fetch(framework) do
671
+ raise ArgumentError,
672
+ "Unknown mocking framework: #{framework.inspect}. " \
673
+ "Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}"
674
+ end
675
+
676
+ RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
677
+ RSpec::Core::MockingAdapters.const_get(const_name)
678
+ end
679
+
680
+ new_name, old_name = [framework_module, @mock_framework].map do |mod|
681
+ mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
682
+ end
683
+
684
+ unless new_name == old_name
685
+ assert_no_example_groups_defined(:mock_framework)
686
+ end
687
+
688
+ if block_given?
689
+ raise "#{framework_module} must respond to `configuration` so that " \
690
+ "mock_with can yield it." unless framework_module.respond_to?(:configuration)
691
+ yield framework_module.configuration
692
+ end
693
+
694
+ @mock_framework = framework_module
695
+ end
696
+
697
+ # Returns the configured expectation framework adapter module(s)
698
+ def expectation_frameworks
699
+ if @expectation_frameworks.empty?
700
+ begin
701
+ expect_with :rspec
702
+ rescue LoadError
703
+ expect_with Module.new
704
+ end
705
+ end
706
+ @expectation_frameworks
707
+ end
708
+
709
+ # Delegates to expect_with(framework).
710
+ def expectation_framework=(framework)
711
+ expect_with(framework)
712
+ end
713
+
714
+ # Sets the expectation framework module(s) to be included in each example
715
+ # group.
716
+ #
717
+ # `frameworks` can be `:rspec`, `:test_unit`, `:minitest`, a custom
718
+ # module, or any combination thereof:
719
+ #
720
+ # config.expect_with :rspec
721
+ # config.expect_with :test_unit
722
+ # config.expect_with :minitest
723
+ # config.expect_with :rspec, :minitest
724
+ # config.expect_with OtherExpectationFramework
725
+ #
726
+ # RSpec will translate `:rspec`, `:minitest`, and `:test_unit` into the
727
+ # appropriate modules.
728
+ #
729
+ # ## Configuration
730
+ #
731
+ # If the module responds to `configuration`, `expect_with` will
732
+ # yield the `configuration` object if given a block:
733
+ #
734
+ # config.expect_with OtherExpectationFramework do |custom_config|
735
+ # custom_config.custom_setting = true
736
+ # end
737
+ def expect_with(*frameworks)
738
+ modules = frameworks.map do |framework|
739
+ case framework
740
+ when Module
741
+ framework
742
+ when :rspec
743
+ require 'rspec/expectations'
744
+
745
+ # Tag this exception class so our exception formatting logic knows
746
+ # that it satisfies the `MultipleExceptionError` interface.
747
+ ::RSpec::Expectations::MultipleExpectationsNotMetError.__send__(
748
+ :include, MultipleExceptionError::InterfaceTag
749
+ )
750
+
751
+ ::RSpec::Matchers
752
+ when :test_unit
753
+ require 'rspec/core/test_unit_assertions_adapter'
754
+ ::RSpec::Core::TestUnitAssertionsAdapter
755
+ when :minitest
756
+ require 'rspec/core/minitest_assertions_adapter'
757
+ ::RSpec::Core::MinitestAssertionsAdapter
758
+ else
759
+ raise ArgumentError, "#{framework.inspect} is not supported"
760
+ end
761
+ end
762
+
763
+ if (modules - @expectation_frameworks).any?
764
+ assert_no_example_groups_defined(:expect_with)
765
+ end
766
+
767
+ if block_given?
768
+ raise "expect_with only accepts a block with a single argument. " \
769
+ "Call expect_with #{modules.length} times, " \
770
+ "once with each argument, instead." if modules.length > 1
771
+ raise "#{modules.first} must respond to `configuration` so that " \
772
+ "expect_with can yield it." unless modules.first.respond_to?(:configuration)
773
+ yield modules.first.configuration
774
+ end
775
+
776
+ @expectation_frameworks.push(*modules)
777
+ end
778
+
779
+ # Check if full backtrace is enabled.
780
+ # @return [Boolean] is full backtrace enabled
781
+ def full_backtrace?
782
+ @backtrace_formatter.full_backtrace?
783
+ end
784
+
785
+ # Toggle full backtrace.
786
+ # @attr true_or_false [Boolean] toggle full backtrace display
787
+ def full_backtrace=(true_or_false)
788
+ @backtrace_formatter.full_backtrace = true_or_false
789
+ end
790
+
791
+ # Enables color output if the output is a TTY. As of RSpec 3.6, this is
792
+ # the default behavior and this option is retained only for backwards
793
+ # compatibility.
794
+ #
795
+ # @deprecated No longer recommended because of complex behavior. Instead,
796
+ # rely on the fact that TTYs will display color by default, or set
797
+ # {#color_mode} to :on to display color on a non-TTY output.
798
+ # @see color_mode
799
+ # @see color_enabled?
800
+ # @return [Boolean]
801
+ def color
802
+ value_for(:color) { @color }
803
+ end
804
+
805
+ # The mode for determining whether to display output in color. One of:
806
+ #
807
+ # - :automatic - the output will be in color if the output is a TTY (the
808
+ # default)
809
+ # - :on - the output will be in color, whether or not the output is a TTY
810
+ # - :off - the output will not be in color
811
+ #
812
+ # @see color_enabled?
813
+ # @return [Boolean]
814
+ def color_mode
815
+ value_for(:color_mode) { @color_mode }
816
+ end
817
+
818
+ # Check if color is enabled for a particular output.
819
+ # @param output [IO] an output stream to use, defaults to the current
820
+ # `output_stream`
821
+ # @return [Boolean]
822
+ def color_enabled?(output=output_stream)
823
+ case color_mode
824
+ when :on then true
825
+ when :off then false
826
+ else # automatic
827
+ output_to_tty?(output) || (color && tty?)
828
+ end
829
+ end
830
+
831
+ # Set the color mode.
832
+ attr_writer :color_mode
833
+
834
+ # Toggle output color.
835
+ #
836
+ # @deprecated No longer recommended because of complex behavior. Instead,
837
+ # rely on the fact that TTYs will display color by default, or set
838
+ # {:color_mode} to :on to display color on a non-TTY output.
839
+ attr_writer :color
840
+
841
+ # @private
842
+ def libs=(libs)
843
+ libs.map do |lib|
844
+ @libs.unshift lib
845
+ $LOAD_PATH.unshift lib
846
+ end
847
+ end
848
+
849
+ # Run examples matching on `description` in all files to run.
850
+ # @param description [String, Regexp] the pattern to filter on
851
+ def full_description=(description)
852
+ filter_run :full_description => Regexp.union(*Array(description).map { |d| Regexp.new(d) })
853
+ end
854
+
855
+ # @return [Array] full description filter
856
+ def full_description
857
+ filter.fetch :full_description, nil
858
+ end
859
+
860
+ # @overload add_formatter(formatter)
861
+ # @overload add_formatter(formatter, output)
862
+ #
863
+ # @param formatter [Class, String] formatter to use. Can be any of the
864
+ # string values supported from the CLI (`p`/`progress`,
865
+ # `d`/`doc`/`documentation`, `h`/`html`, or `j`/`json`) or any
866
+ # class that implements the formatter protocol and has registered
867
+ # itself with RSpec as a formatter.
868
+ # @param output [String, IO] where the formatter will write its output.
869
+ # Can be an IO object or a string path to a file. If not provided,
870
+ # the configured `output_stream` (`$stdout`, by default) will be used.
871
+ #
872
+ # Adds a formatter to the set RSpec will use for this run.
873
+ #
874
+ # @see RSpec::Core::Formatters::Protocol
875
+ def add_formatter(formatter, output=output_wrapper)
876
+ formatter_loader.add(formatter, output)
877
+ end
878
+ alias_method :formatter=, :add_formatter
879
+
880
+ # The formatter that will be used if no formatter has been set.
881
+ # Defaults to 'progress'.
882
+ def default_formatter
883
+ formatter_loader.default_formatter
884
+ end
885
+
886
+ # Sets a fallback formatter to use if none other has been set.
887
+ #
888
+ # @example
889
+ #
890
+ # RSpec.configure do |rspec|
891
+ # rspec.default_formatter = 'doc'
892
+ # end
893
+ def default_formatter=(value)
894
+ formatter_loader.default_formatter = value
895
+ end
896
+
897
+ # Returns a duplicate of the formatters currently loaded in
898
+ # the `FormatterLoader` for introspection.
899
+ #
900
+ # Note as this is a duplicate, any mutations will be disregarded.
901
+ #
902
+ # @return [Array] the formatters currently loaded
903
+ def formatters
904
+ formatter_loader.formatters.dup
905
+ end
906
+
907
+ # @private
908
+ def formatter_loader
909
+ @formatter_loader ||= Formatters::Loader.new(Reporter.new(self))
910
+ end
911
+
912
+ # @private
913
+ #
914
+ # This buffer is used to capture all messages sent to the reporter during
915
+ # reporter initialization. It can then replay those messages after the
916
+ # formatter is correctly initialized. Otherwise, deprecation warnings
917
+ # during formatter initialization can cause an infinite loop.
918
+ class DeprecationReporterBuffer
919
+ def initialize
920
+ @calls = []
921
+ end
922
+
923
+ def deprecation(*args)
924
+ @calls << args
925
+ end
926
+
927
+ def play_onto(reporter)
928
+ @calls.each do |args|
929
+ reporter.deprecation(*args)
930
+ end
931
+ end
932
+ end
933
+
934
+ # @return [RSpec::Core::Reporter] the currently configured reporter
935
+ def reporter
936
+ # @reporter_buffer should only ever be set in this method to cover
937
+ # initialization of @reporter.
938
+ @reporter_buffer || @reporter ||=
939
+ begin
940
+ @reporter_buffer = DeprecationReporterBuffer.new
941
+ formatter_loader.prepare_default output_wrapper, deprecation_stream
942
+ @reporter_buffer.play_onto(formatter_loader.reporter)
943
+ @reporter_buffer = nil
944
+ formatter_loader.reporter
945
+ end
946
+ end
947
+
948
+ # @api private
949
+ #
950
+ # Defaults `profile_examples` to 10 examples when `@profile_examples` is
951
+ # `true`.
952
+ def profile_examples
953
+ profile = value_for(:profile_examples) { @profile_examples }
954
+ if profile && !profile.is_a?(Integer)
955
+ 10
956
+ else
957
+ profile
958
+ end
959
+ end
960
+
961
+ # @private
962
+ def files_or_directories_to_run=(*files)
963
+ files = files.flatten
964
+
965
+ if (command == 'rspec' || Runner.running_in_drb?) && default_path && files.empty?
966
+ files << default_path
967
+ end
968
+
969
+ @files_or_directories_to_run = files
970
+ @files_to_run = nil
971
+ end
972
+
973
+ # The spec files RSpec will run.
974
+ # @return [Array] specified files about to run
975
+ def files_to_run
976
+ @files_to_run ||= get_files_to_run(@files_or_directories_to_run)
977
+ end
978
+
979
+ # @private
980
+ def last_run_statuses
981
+ @last_run_statuses ||= Hash.new(UNKNOWN_STATUS).tap do |statuses|
982
+ if (path = example_status_persistence_file_path)
983
+ begin
984
+ ExampleStatusPersister.load_from(path).inject(statuses) do |hash, example|
985
+ status = example[:status]
986
+ status = UNKNOWN_STATUS unless VALID_STATUSES.include?(status)
987
+ hash[example.fetch(:example_id)] = status
988
+ hash
989
+ end
990
+ rescue SystemCallError => e
991
+ RSpec.warning "Could not read from #{path.inspect} (configured as " \
992
+ "`config.example_status_persistence_file_path`) due " \
993
+ "to a system error: #{e.inspect}. Please check that " \
994
+ "the config option is set to an accessible, valid " \
995
+ "file path", :call_site => nil
996
+ end
997
+ end
998
+ end
999
+ end
1000
+
1001
+ # @private
1002
+ UNKNOWN_STATUS = "unknown".freeze
1003
+
1004
+ # @private
1005
+ FAILED_STATUS = "failed".freeze
1006
+
1007
+ # @private
1008
+ PASSED_STATUS = "passed".freeze
1009
+
1010
+ # @private
1011
+ PENDING_STATUS = "pending".freeze
1012
+
1013
+ # @private
1014
+ VALID_STATUSES = [UNKNOWN_STATUS, FAILED_STATUS, PASSED_STATUS, PENDING_STATUS]
1015
+
1016
+ # @private
1017
+ def spec_files_with_failures
1018
+ @spec_files_with_failures ||= last_run_statuses.inject(Set.new) do |files, (id, status)|
1019
+ files << Example.parse_id(id).first if status == FAILED_STATUS
1020
+ files
1021
+ end.to_a
1022
+ end
1023
+
1024
+ # Creates a method that delegates to `example` including the submitted
1025
+ # `args`. Used internally to add variants of `example` like `pending`:
1026
+ # @param name [String] example name alias
1027
+ # @param args [Array<Symbol>, Hash] metadata for the generated example
1028
+ #
1029
+ # @note The specific example alias below (`pending`) is already
1030
+ # defined for you.
1031
+ # @note Use with caution. This extends the language used in your
1032
+ # specs, but does not add any additional documentation. We use this
1033
+ # in RSpec to define methods like `focus` and `xit`, but we also add
1034
+ # docs for those methods.
1035
+ #
1036
+ # @example
1037
+ # RSpec.configure do |config|
1038
+ # config.alias_example_to :pending, :pending => true
1039
+ # end
1040
+ #
1041
+ # # This lets you do this:
1042
+ #
1043
+ # describe Thing do
1044
+ # pending "does something" do
1045
+ # thing = Thing.new
1046
+ # end
1047
+ # end
1048
+ #
1049
+ # # ... which is the equivalent of
1050
+ #
1051
+ # describe Thing do
1052
+ # it "does something", :pending => true do
1053
+ # thing = Thing.new
1054
+ # end
1055
+ # end
1056
+ def alias_example_to(name, *args)
1057
+ extra_options = Metadata.build_hash_from(args)
1058
+ RSpec::Core::ExampleGroup.define_example_method(name, extra_options)
1059
+ end
1060
+
1061
+ # Creates a method that defines an example group with the provided
1062
+ # metadata. Can be used to define example group/metadata shortcuts.
1063
+ #
1064
+ # @example
1065
+ # RSpec.configure do |config|
1066
+ # config.alias_example_group_to :describe_model, :type => :model
1067
+ # end
1068
+ #
1069
+ # shared_context_for "model tests", :type => :model do
1070
+ # # define common model test helper methods, `let` declarations, etc
1071
+ # end
1072
+ #
1073
+ # # This lets you do this:
1074
+ #
1075
+ # RSpec.describe_model User do
1076
+ # end
1077
+ #
1078
+ # # ... which is the equivalent of
1079
+ #
1080
+ # RSpec.describe User, :type => :model do
1081
+ # end
1082
+ #
1083
+ # @note The defined aliased will also be added to the top level
1084
+ # (e.g. `main` and from within modules) if
1085
+ # `expose_dsl_globally` is set to true.
1086
+ # @see #alias_example_to
1087
+ # @see #expose_dsl_globally=
1088
+ def alias_example_group_to(new_name, *args)
1089
+ extra_options = Metadata.build_hash_from(args)
1090
+ RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options)
1091
+ end
1092
+
1093
+ # Define an alias for it_should_behave_like that allows different
1094
+ # language (like "it_has_behavior" or "it_behaves_like") to be
1095
+ # employed when including shared examples.
1096
+ #
1097
+ # @example
1098
+ # RSpec.configure do |config|
1099
+ # config.alias_it_behaves_like_to(:it_has_behavior, 'has behavior:')
1100
+ # end
1101
+ #
1102
+ # # allows the user to include a shared example group like:
1103
+ #
1104
+ # describe Entity do
1105
+ # it_has_behavior 'sortability' do
1106
+ # let(:sortable) { Entity.new }
1107
+ # end
1108
+ # end
1109
+ #
1110
+ # # which is reported in the output as:
1111
+ # # Entity
1112
+ # # has behavior: sortability
1113
+ # # ...sortability examples here
1114
+ #
1115
+ # @note Use with caution. This extends the language used in your
1116
+ # specs, but does not add any additional documentation. We use this
1117
+ # in RSpec to define `it_should_behave_like` (for backward
1118
+ # compatibility), but we also add docs for that method.
1119
+ def alias_it_behaves_like_to(new_name, report_label='')
1120
+ RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
1121
+ end
1122
+ alias_method :alias_it_should_behave_like_to, :alias_it_behaves_like_to
1123
+
1124
+ # Adds key/value pairs to the `inclusion_filter`. If `args`
1125
+ # includes any symbols that are not part of the hash, each symbol
1126
+ # is treated as a key in the hash with the value `true`.
1127
+ #
1128
+ # ### Note
1129
+ #
1130
+ # Filters set using this method can be overridden from the command line
1131
+ # or config files (e.g. `.rspec`).
1132
+ #
1133
+ # @example
1134
+ # # Given this declaration.
1135
+ # describe "something", :foo => 'bar' do
1136
+ # # ...
1137
+ # end
1138
+ #
1139
+ # # Any of the following will include that group.
1140
+ # config.filter_run_including :foo => 'bar'
1141
+ # config.filter_run_including :foo => /^ba/
1142
+ # config.filter_run_including :foo => lambda {|v| v == 'bar'}
1143
+ # config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
1144
+ #
1145
+ # # Given a proc with an arity of 1, the lambda is passed the value
1146
+ # # related to the key, e.g.
1147
+ # config.filter_run_including :foo => lambda {|v| v == 'bar'}
1148
+ #
1149
+ # # Given a proc with an arity of 2, the lambda is passed the value
1150
+ # # related to the key, and the metadata itself e.g.
1151
+ # config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
1152
+ #
1153
+ # filter_run_including :foo # same as filter_run_including :foo => true
1154
+ def filter_run_including(*args)
1155
+ meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
1156
+ filter_manager.include_with_low_priority meta
1157
+ static_config_filter_manager.include_with_low_priority Metadata.deep_hash_dup(meta)
1158
+ end
1159
+ alias_method :filter_run, :filter_run_including
1160
+
1161
+ # Applies the provided filter only if any of examples match, in constrast
1162
+ # to {#filter_run}, which always applies even if no examples match, in
1163
+ # which case no examples will be run. This allows you to leave configured
1164
+ # filters in place that are intended only for temporary use. The most common
1165
+ # example is focus filtering: `config.filter_run_when_matching :focus`.
1166
+ # With that configured, you can temporarily focus an example or group
1167
+ # by tagging it with `:focus` metadata, or prefixing it with an `f`
1168
+ # (as in `fdescribe`, `fcontext` and `fit`) since those are aliases for
1169
+ # `describe`/`context`/`it` with `:focus` metadata.
1170
+ def filter_run_when_matching(*args)
1171
+ when_first_matching_example_defined(*args) do
1172
+ filter_run(*args)
1173
+ end
1174
+ end
1175
+
1176
+ # Clears and reassigns the `inclusion_filter`. Set to `nil` if you don't
1177
+ # want any inclusion filter at all.
1178
+ #
1179
+ # ### Warning
1180
+ #
1181
+ # This overrides any inclusion filters/tags set on the command line or in
1182
+ # configuration files.
1183
+ def inclusion_filter=(filter)
1184
+ meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
1185
+ filter_manager.include_only meta
1186
+ end
1187
+
1188
+ alias_method :filter=, :inclusion_filter=
1189
+
1190
+ # Returns the `inclusion_filter`. If none has been set, returns an empty
1191
+ # hash.
1192
+ def inclusion_filter
1193
+ filter_manager.inclusions
1194
+ end
1195
+
1196
+ alias_method :filter, :inclusion_filter
1197
+
1198
+ # Adds key/value pairs to the `exclusion_filter`. If `args`
1199
+ # includes any symbols that are not part of the hash, each symbol
1200
+ # is treated as a key in the hash with the value `true`.
1201
+ #
1202
+ # ### Note
1203
+ #
1204
+ # Filters set using this method can be overridden from the command line
1205
+ # or config files (e.g. `.rspec`).
1206
+ #
1207
+ # @example
1208
+ # # Given this declaration.
1209
+ # describe "something", :foo => 'bar' do
1210
+ # # ...
1211
+ # end
1212
+ #
1213
+ # # Any of the following will exclude that group.
1214
+ # config.filter_run_excluding :foo => 'bar'
1215
+ # config.filter_run_excluding :foo => /^ba/
1216
+ # config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
1217
+ # config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
1218
+ #
1219
+ # # Given a proc with an arity of 1, the lambda is passed the value
1220
+ # # related to the key, e.g.
1221
+ # config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
1222
+ #
1223
+ # # Given a proc with an arity of 2, the lambda is passed the value
1224
+ # # related to the key, and the metadata itself e.g.
1225
+ # config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
1226
+ #
1227
+ # filter_run_excluding :foo # same as filter_run_excluding :foo => true
1228
+ def filter_run_excluding(*args)
1229
+ meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
1230
+ filter_manager.exclude_with_low_priority meta
1231
+ static_config_filter_manager.exclude_with_low_priority Metadata.deep_hash_dup(meta)
1232
+ end
1233
+
1234
+ # Clears and reassigns the `exclusion_filter`. Set to `nil` if you don't
1235
+ # want any exclusion filter at all.
1236
+ #
1237
+ # ### Warning
1238
+ #
1239
+ # This overrides any exclusion filters/tags set on the command line or in
1240
+ # configuration files.
1241
+ def exclusion_filter=(filter)
1242
+ meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
1243
+ filter_manager.exclude_only meta
1244
+ end
1245
+
1246
+ # Returns the `exclusion_filter`. If none has been set, returns an empty
1247
+ # hash.
1248
+ def exclusion_filter
1249
+ filter_manager.exclusions
1250
+ end
1251
+
1252
+ # Tells RSpec to include `mod` in example groups. Methods defined in
1253
+ # `mod` are exposed to examples (not example groups). Use `filters` to
1254
+ # constrain the groups or examples in which to include the module.
1255
+ #
1256
+ # @example
1257
+ #
1258
+ # module AuthenticationHelpers
1259
+ # def login_as(user)
1260
+ # # ...
1261
+ # end
1262
+ # end
1263
+ #
1264
+ # module UserHelpers
1265
+ # def users(username)
1266
+ # # ...
1267
+ # end
1268
+ # end
1269
+ #
1270
+ # RSpec.configure do |config|
1271
+ # config.include(UserHelpers) # included in all groups
1272
+ # config.include(AuthenticationHelpers, :type => :request)
1273
+ # end
1274
+ #
1275
+ # describe "edit profile", :type => :request do
1276
+ # it "can be viewed by owning user" do
1277
+ # login_as users(:jdoe)
1278
+ # get "/profiles/jdoe"
1279
+ # assert_select ".username", :text => 'jdoe'
1280
+ # end
1281
+ # end
1282
+ #
1283
+ # @note Filtered module inclusions can also be applied to
1284
+ # individual examples that have matching metadata. Just like
1285
+ # Ruby's object model is that every object has a singleton class
1286
+ # which has only a single instance, RSpec's model is that every
1287
+ # example has a singleton example group containing just the one
1288
+ # example.
1289
+ #
1290
+ # @see #include_context
1291
+ # @see #extend
1292
+ # @see #prepend
1293
+ def include(mod, *filters)
1294
+ define_mixed_in_module(mod, filters, @include_modules, :include) do |group|
1295
+ safe_include(mod, group)
1296
+ end
1297
+ end
1298
+
1299
+ # Tells RSpec to include the named shared example group in example groups.
1300
+ # Use `filters` to constrain the groups or examples in which to include
1301
+ # the example group.
1302
+ #
1303
+ # @example
1304
+ #
1305
+ # RSpec.shared_context "example users" do
1306
+ # let(:admin_user) { create_user(:admin) }
1307
+ # let(:guest_user) { create_user(:guest) }
1308
+ # end
1309
+ #
1310
+ # RSpec.configure do |config|
1311
+ # config.include_context "example users", :type => :request
1312
+ # end
1313
+ #
1314
+ # RSpec.describe "The admin page", :type => :request do
1315
+ # it "can be viewed by admins" do
1316
+ # login_with admin_user
1317
+ # get "/admin"
1318
+ # expect(response).to be_ok
1319
+ # end
1320
+ #
1321
+ # it "cannot be viewed by guests" do
1322
+ # login_with guest_user
1323
+ # get "/admin"
1324
+ # expect(response).to be_forbidden
1325
+ # end
1326
+ # end
1327
+ #
1328
+ # @note Filtered context inclusions can also be applied to
1329
+ # individual examples that have matching metadata. Just like
1330
+ # Ruby's object model is that every object has a singleton class
1331
+ # which has only a single instance, RSpec's model is that every
1332
+ # example has a singleton example group containing just the one
1333
+ # example.
1334
+ #
1335
+ # @see #include
1336
+ def include_context(shared_group_name, *filters)
1337
+ shared_module = world.shared_example_group_registry.find([:main], shared_group_name)
1338
+ include shared_module, *filters
1339
+ end
1340
+
1341
+ # Tells RSpec to extend example groups with `mod`. Methods defined in
1342
+ # `mod` are exposed to example groups (not examples). Use `filters` to
1343
+ # constrain the groups to extend.
1344
+ #
1345
+ # Similar to `include`, but behavior is added to example groups, which
1346
+ # are classes, rather than the examples, which are instances of those
1347
+ # classes.
1348
+ #
1349
+ # @example
1350
+ #
1351
+ # module UiHelpers
1352
+ # def run_in_browser
1353
+ # # ...
1354
+ # end
1355
+ # end
1356
+ #
1357
+ # RSpec.configure do |config|
1358
+ # config.extend(UiHelpers, :type => :request)
1359
+ # end
1360
+ #
1361
+ # describe "edit profile", :type => :request do
1362
+ # run_in_browser
1363
+ #
1364
+ # it "does stuff in the client" do
1365
+ # # ...
1366
+ # end
1367
+ # end
1368
+ #
1369
+ # @see #include
1370
+ # @see #prepend
1371
+ def extend(mod, *filters)
1372
+ define_mixed_in_module(mod, filters, @extend_modules, :extend) do |group|
1373
+ safe_extend(mod, group)
1374
+ end
1375
+ end
1376
+
1377
+ if RSpec::Support::RubyFeatures.module_prepends_supported?
1378
+ # Tells RSpec to prepend example groups with `mod`. Methods defined in
1379
+ # `mod` are exposed to examples (not example groups). Use `filters` to
1380
+ # constrain the groups in which to prepend the module.
1381
+ #
1382
+ # Similar to `include`, but module is included before the example group's class
1383
+ # in the ancestor chain.
1384
+ #
1385
+ # @example
1386
+ #
1387
+ # module OverrideMod
1388
+ # def override_me
1389
+ # "overridden"
1390
+ # end
1391
+ # end
1392
+ #
1393
+ # RSpec.configure do |config|
1394
+ # config.prepend(OverrideMod, :method => :prepend)
1395
+ # end
1396
+ #
1397
+ # describe "overriding example's class", :method => :prepend do
1398
+ # it "finds the user" do
1399
+ # self.class.class_eval do
1400
+ # def override_me
1401
+ # end
1402
+ # end
1403
+ # override_me # => "overridden"
1404
+ # # ...
1405
+ # end
1406
+ # end
1407
+ #
1408
+ # @see #include
1409
+ # @see #extend
1410
+ def prepend(mod, *filters)
1411
+ define_mixed_in_module(mod, filters, @prepend_modules, :prepend) do |group|
1412
+ safe_prepend(mod, group)
1413
+ end
1414
+ end
1415
+ end
1416
+
1417
+ # @private
1418
+ #
1419
+ # Used internally to extend a group with modules using `include`, `prepend` and/or
1420
+ # `extend`.
1421
+ def configure_group(group)
1422
+ group.hooks.register_globals(group, hooks)
1423
+
1424
+ configure_group_with group, @include_modules, :safe_include
1425
+ configure_group_with group, @extend_modules, :safe_extend
1426
+ configure_group_with group, @prepend_modules, :safe_prepend
1427
+ end
1428
+
1429
+ # @private
1430
+ #
1431
+ # Used internally to extend the singleton class of a single example's
1432
+ # example group instance with modules using `include` and/or `extend`.
1433
+ def configure_example(example, example_hooks)
1434
+ example_hooks.register_global_singleton_context_hooks(example, hooks)
1435
+ singleton_group = example.example_group_instance.singleton_class
1436
+
1437
+ # We replace the metadata so that SharedExampleGroupModule#included
1438
+ # has access to the example's metadata[:location].
1439
+ singleton_group.with_replaced_metadata(example.metadata) do
1440
+ modules = @include_modules.items_for(example.metadata)
1441
+ modules.each do |mod|
1442
+ safe_include(mod, example.example_group_instance.singleton_class)
1443
+ end
1444
+
1445
+ MemoizedHelpers.define_helpers_on(singleton_group) unless modules.empty?
1446
+ end
1447
+ end
1448
+
1449
+ # @private
1450
+ def requires=(paths)
1451
+ directories = ['lib', default_path].select { |p| File.directory? p }
1452
+ RSpec::Core::RubyProject.add_to_load_path(*directories)
1453
+ paths.each { |path| require path }
1454
+ @requires += paths
1455
+ end
1456
+
1457
+ # @private
1458
+ def in_project_source_dir_regex
1459
+ regexes = project_source_dirs.map do |dir|
1460
+ /\A#{Regexp.escape(File.expand_path(dir))}\//
1461
+ end
1462
+
1463
+ Regexp.union(regexes)
1464
+ end
1465
+
1466
+ # @private
1467
+ def configure_mock_framework
1468
+ RSpec::Core::ExampleGroup.__send__(:include, mock_framework)
1469
+ conditionally_disable_mocks_monkey_patching
1470
+ end
1471
+
1472
+ # @private
1473
+ def configure_expectation_framework
1474
+ expectation_frameworks.each do |framework|
1475
+ RSpec::Core::ExampleGroup.__send__(:include, framework)
1476
+ end
1477
+ conditionally_disable_expectations_monkey_patching
1478
+ end
1479
+
1480
+ # @private
1481
+ def load_spec_files
1482
+ # Note which spec files world is already aware of.
1483
+ # This is generally only needed for when the user runs
1484
+ # `ruby path/to/spec.rb` (and loads `rspec/autorun`) --
1485
+ # in that case, the spec file was loaded by `ruby` and
1486
+ # isn't loaded by us here so we only know about it because
1487
+ # of an example group being registered in it.
1488
+ world.registered_example_group_files.each do |f|
1489
+ loaded_spec_files << f # the registered files are already expended absolute paths
1490
+ end
1491
+
1492
+ files_to_run.uniq.each do |f|
1493
+ file = File.expand_path(f)
1494
+ load_spec_file_handling_errors(file)
1495
+ loaded_spec_files << file
1496
+ end
1497
+
1498
+ @spec_files_loaded = true
1499
+ end
1500
+
1501
+ # @private
1502
+ DEFAULT_FORMATTER = lambda { |string| string }
1503
+
1504
+ # Formats the docstring output using the block provided.
1505
+ #
1506
+ # @example
1507
+ # # This will strip the descriptions of both examples and example
1508
+ # # groups.
1509
+ # RSpec.configure do |config|
1510
+ # config.format_docstrings { |s| s.strip }
1511
+ # end
1512
+ def format_docstrings(&block)
1513
+ @format_docstrings_block = block_given? ? block : DEFAULT_FORMATTER
1514
+ end
1515
+
1516
+ # @private
1517
+ def format_docstrings_block
1518
+ @format_docstrings_block ||= DEFAULT_FORMATTER
1519
+ end
1520
+
1521
+ # @private
1522
+ # @macro [attach] delegate_to_ordering_manager
1523
+ # @!method $1
1524
+ def self.delegate_to_ordering_manager(*methods)
1525
+ methods.each do |method|
1526
+ define_method method do |*args, &block|
1527
+ ordering_manager.__send__(method, *args, &block)
1528
+ end
1529
+ end
1530
+ end
1531
+
1532
+ # @macro delegate_to_ordering_manager
1533
+ #
1534
+ # Sets the seed value and sets the default global ordering to random.
1535
+ delegate_to_ordering_manager :seed=
1536
+
1537
+ # @macro delegate_to_ordering_manager
1538
+ # Seed for random ordering (default: generated randomly each run).
1539
+ #
1540
+ # When you run specs with `--order random`, RSpec generates a random seed
1541
+ # for the randomization and prints it to the `output_stream` (assuming
1542
+ # you're using RSpec's built-in formatters). If you discover an ordering
1543
+ # dependency (i.e. examples fail intermittently depending on order), set
1544
+ # this (on Configuration or on the command line with `--seed`) to run
1545
+ # using the same seed while you debug the issue.
1546
+ #
1547
+ # We recommend, actually, that you use the command line approach so you
1548
+ # don't accidentally leave the seed encoded.
1549
+ delegate_to_ordering_manager :seed
1550
+
1551
+ # @macro delegate_to_ordering_manager
1552
+ #
1553
+ # Sets the default global ordering strategy. By default this can be one
1554
+ # of `:defined`, `:random`, but is customizable through the
1555
+ # `register_ordering` API. If order is set to `'rand:<seed>'`,
1556
+ # the seed will also be set.
1557
+ #
1558
+ # @see #register_ordering
1559
+ delegate_to_ordering_manager :order=
1560
+
1561
+ # @macro delegate_to_ordering_manager
1562
+ # Registers a named ordering strategy that can later be
1563
+ # used to order an example group's subgroups by adding
1564
+ # `:order => <name>` metadata to the example group.
1565
+ #
1566
+ # @param name [Symbol] The name of the ordering.
1567
+ # @yield Block that will order the given examples or example groups
1568
+ # @yieldparam list [Array<RSpec::Core::Example>,
1569
+ # Array<RSpec::Core::ExampleGroup>] The examples or groups to order
1570
+ # @yieldreturn [Array<RSpec::Core::Example>,
1571
+ # Array<RSpec::Core::ExampleGroup>] The re-ordered examples or groups
1572
+ #
1573
+ # @example
1574
+ # RSpec.configure do |rspec|
1575
+ # rspec.register_ordering :reverse do |list|
1576
+ # list.reverse
1577
+ # end
1578
+ # end
1579
+ #
1580
+ # RSpec.describe 'MyClass', :order => :reverse do
1581
+ # # ...
1582
+ # end
1583
+ #
1584
+ # @note Pass the symbol `:global` to set the ordering strategy that
1585
+ # will be used to order the top-level example groups and any example
1586
+ # groups that do not have declared `:order` metadata.
1587
+ #
1588
+ # @example
1589
+ # RSpec.configure do |rspec|
1590
+ # rspec.register_ordering :global do |examples|
1591
+ # acceptance, other = examples.partition do |example|
1592
+ # example.metadata[:type] == :acceptance
1593
+ # end
1594
+ # other + acceptance
1595
+ # end
1596
+ # end
1597
+ #
1598
+ # RSpec.describe 'MyClass', :type => :acceptance do
1599
+ # # will run last
1600
+ # end
1601
+ #
1602
+ # RSpec.describe 'MyClass' do
1603
+ # # will run first
1604
+ # end
1605
+ #
1606
+ delegate_to_ordering_manager :register_ordering
1607
+
1608
+ # @private
1609
+ delegate_to_ordering_manager :seed_used?, :ordering_registry
1610
+
1611
+ # Set Ruby warnings on or off.
1612
+ def warnings=(value)
1613
+ $VERBOSE = !!value
1614
+ end
1615
+
1616
+ # @return [Boolean] Whether or not ruby warnings are enabled.
1617
+ def warnings?
1618
+ $VERBOSE
1619
+ end
1620
+
1621
+ # @private
1622
+ RAISE_ERROR_WARNING_NOTIFIER = lambda { |message| raise message }
1623
+
1624
+ # Turns warnings into errors. This can be useful when
1625
+ # you want RSpec to run in a 'strict' no warning situation.
1626
+ #
1627
+ # @example
1628
+ #
1629
+ # RSpec.configure do |rspec|
1630
+ # rspec.raise_on_warning = true
1631
+ # end
1632
+ def raise_on_warning=(value)
1633
+ if value
1634
+ RSpec::Support.warning_notifier = RAISE_ERROR_WARNING_NOTIFIER
1635
+ else
1636
+ RSpec::Support.warning_notifier = RSpec::Support::DEFAULT_WARNING_NOTIFIER
1637
+ end
1638
+ end
1639
+
1640
+ # Exposes the current running example via the named
1641
+ # helper method. RSpec 2.x exposed this via `example`,
1642
+ # but in RSpec 3.0, the example is instead exposed via
1643
+ # an arg yielded to `it`, `before`, `let`, etc. However,
1644
+ # some extension gems (such as Capybara) depend on the
1645
+ # RSpec 2.x's `example` method, so this config option
1646
+ # can be used to maintain compatibility.
1647
+ #
1648
+ # @param method_name [Symbol] the name of the helper method
1649
+ #
1650
+ # @example
1651
+ #
1652
+ # RSpec.configure do |rspec|
1653
+ # rspec.expose_current_running_example_as :example
1654
+ # end
1655
+ #
1656
+ # describe MyClass do
1657
+ # before do
1658
+ # # `example` can be used here because of the above config.
1659
+ # do_something if example.metadata[:type] == "foo"
1660
+ # end
1661
+ # end
1662
+ def expose_current_running_example_as(method_name)
1663
+ ExposeCurrentExample.module_exec do
1664
+ extend RSpec::SharedContext
1665
+ let(method_name) { |ex| ex }
1666
+ end
1667
+
1668
+ include ExposeCurrentExample
1669
+ end
1670
+
1671
+ # @private
1672
+ module ExposeCurrentExample; end
1673
+
1674
+ # Turns deprecation warnings into errors, in order to surface
1675
+ # the full backtrace of the call site. This can be useful when
1676
+ # you need more context to address a deprecation than the
1677
+ # single-line call site normally provided.
1678
+ #
1679
+ # @example
1680
+ #
1681
+ # RSpec.configure do |rspec|
1682
+ # rspec.raise_errors_for_deprecations!
1683
+ # end
1684
+ def raise_errors_for_deprecations!
1685
+ self.deprecation_stream = Formatters::DeprecationFormatter::RaiseErrorStream.new
1686
+ end
1687
+
1688
+ # Enables zero monkey patching mode for RSpec. It removes monkey
1689
+ # patching of the top-level DSL methods (`describe`,
1690
+ # `shared_examples_for`, etc) onto `main` and `Module`, instead
1691
+ # requiring you to prefix these methods with `RSpec.`. It enables
1692
+ # expect-only syntax for rspec-mocks and rspec-expectations. It
1693
+ # simply disables monkey patching on whatever pieces of RSpec
1694
+ # the user is using.
1695
+ #
1696
+ # @note It configures rspec-mocks and rspec-expectations only
1697
+ # if the user is using those (either explicitly or implicitly
1698
+ # by not setting `mock_with` or `expect_with` to anything else).
1699
+ #
1700
+ # @note If the user uses this options with `mock_with :mocha`
1701
+ # (or similiar) they will still have monkey patching active
1702
+ # in their test environment from mocha.
1703
+ #
1704
+ # @example
1705
+ #
1706
+ # # It disables all monkey patching.
1707
+ # RSpec.configure do |config|
1708
+ # config.disable_monkey_patching!
1709
+ # end
1710
+ #
1711
+ # # Is an equivalent to
1712
+ # RSpec.configure do |config|
1713
+ # config.expose_dsl_globally = false
1714
+ #
1715
+ # config.mock_with :rspec do |mocks|
1716
+ # mocks.syntax = :expect
1717
+ # mocks.patch_marshal_to_support_partial_doubles = false
1718
+ # end
1719
+ #
1720
+ # config.expect_with :rspec do |expectations|
1721
+ # expectations.syntax = :expect
1722
+ # end
1723
+ # end
1724
+ def disable_monkey_patching!
1725
+ self.expose_dsl_globally = false
1726
+ self.disable_monkey_patching = true
1727
+ conditionally_disable_mocks_monkey_patching
1728
+ conditionally_disable_expectations_monkey_patching
1729
+ end
1730
+
1731
+ # @private
1732
+ attr_accessor :disable_monkey_patching
1733
+
1734
+ # Defines a callback that can assign derived metadata values.
1735
+ #
1736
+ # @param filters [Array<Symbol>, Hash] metadata filters that determine
1737
+ # which example or group metadata hashes the callback will be triggered
1738
+ # for. If none are given, the callback will be run against the metadata
1739
+ # hashes of all groups and examples.
1740
+ # @yieldparam metadata [Hash] original metadata hash from an example or
1741
+ # group. Mutate this in your block as needed.
1742
+ #
1743
+ # @example
1744
+ # RSpec.configure do |config|
1745
+ # # Tag all groups and examples in the spec/unit directory with
1746
+ # # :type => :unit
1747
+ # config.define_derived_metadata(:file_path => %r{/spec/unit/}) do |metadata|
1748
+ # metadata[:type] = :unit
1749
+ # end
1750
+ # end
1751
+ def define_derived_metadata(*filters, &block)
1752
+ meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
1753
+ @derived_metadata_blocks.append(block, meta)
1754
+ end
1755
+
1756
+ # Defines a callback that runs after the first example with matching
1757
+ # metadata is defined. If no examples are defined with matching metadata,
1758
+ # it will not get called at all.
1759
+ #
1760
+ # This can be used to ensure some setup is performed (such as bootstrapping
1761
+ # a DB or loading a specific file that adds significantly to the boot time)
1762
+ # if needed (as indicated by the presence of an example with matching metadata)
1763
+ # but avoided otherwise.
1764
+ #
1765
+ # @example
1766
+ # RSpec.configure do |config|
1767
+ # config.when_first_matching_example_defined(:db) do
1768
+ # # Load a support file that does some heavyweight setup,
1769
+ # # including bootstrapping the DB, but only if we have loaded
1770
+ # # any examples tagged with `:db`.
1771
+ # require 'support/db'
1772
+ # end
1773
+ # end
1774
+ def when_first_matching_example_defined(*filters, &block)
1775
+ specified_meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
1776
+
1777
+ callback = lambda do |example_or_group_meta|
1778
+ # Example groups do not have `:example_group` metadata
1779
+ # (instead they have `:parent_example_group` metadata).
1780
+ return unless example_or_group_meta.key?(:example_group)
1781
+
1782
+ # Ensure the callback only fires once.
1783
+ @derived_metadata_blocks.delete(callback, specified_meta)
1784
+
1785
+ block.call
1786
+ end
1787
+
1788
+ @derived_metadata_blocks.append(callback, specified_meta)
1789
+ end
1790
+
1791
+ # @private
1792
+ def apply_derived_metadata_to(metadata)
1793
+ @derived_metadata_blocks.items_for(metadata).each do |block|
1794
+ block.call(metadata)
1795
+ end
1796
+ end
1797
+
1798
+ # Defines a `before` hook. See {Hooks#before} for full docs.
1799
+ #
1800
+ # This method differs from {Hooks#before} in only one way: it supports
1801
+ # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1802
+ # the first example of the entire suite is executed.
1803
+ #
1804
+ # @see #prepend_before
1805
+ # @see #after
1806
+ # @see #append_after
1807
+ def before(scope=nil, *meta, &block)
1808
+ handle_suite_hook(scope, meta) do
1809
+ @before_suite_hooks << Hooks::BeforeHook.new(block, {})
1810
+ end || begin
1811
+ add_hook_to_existing_matching_groups(meta, scope) { |g| g.before(scope, *meta, &block) }
1812
+ super(scope, *meta, &block)
1813
+ end
1814
+ end
1815
+ alias_method :append_before, :before
1816
+
1817
+ # Adds `block` to the start of the list of `before` blocks in the same
1818
+ # scope (`:example`, `:context`, or `:suite`), in contrast to {#before},
1819
+ # which adds the hook to the end of the list.
1820
+ #
1821
+ # See {Hooks#before} for full `before` hook docs.
1822
+ #
1823
+ # This method differs from {Hooks#prepend_before} in only one way: it supports
1824
+ # the `:suite` scope. Hooks with the `:suite` scope will be run once before
1825
+ # the first example of the entire suite is executed.
1826
+ #
1827
+ # @see #before
1828
+ # @see #after
1829
+ # @see #append_after
1830
+ def prepend_before(scope=nil, *meta, &block)
1831
+ handle_suite_hook(scope, meta) do
1832
+ @before_suite_hooks.unshift Hooks::BeforeHook.new(block, {})
1833
+ end || begin
1834
+ add_hook_to_existing_matching_groups(meta, scope) { |g| g.prepend_before(scope, *meta, &block) }
1835
+ super(scope, *meta, &block)
1836
+ end
1837
+ end
1838
+
1839
+ # Defines a `after` hook. See {Hooks#after} for full docs.
1840
+ #
1841
+ # This method differs from {Hooks#after} in only one way: it supports
1842
+ # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1843
+ # the last example of the entire suite is executed.
1844
+ #
1845
+ # @see #append_after
1846
+ # @see #before
1847
+ # @see #prepend_before
1848
+ def after(scope=nil, *meta, &block)
1849
+ handle_suite_hook(scope, meta) do
1850
+ @after_suite_hooks.unshift Hooks::AfterHook.new(block, {})
1851
+ end || begin
1852
+ add_hook_to_existing_matching_groups(meta, scope) { |g| g.after(scope, *meta, &block) }
1853
+ super(scope, *meta, &block)
1854
+ end
1855
+ end
1856
+ alias_method :prepend_after, :after
1857
+
1858
+ # Adds `block` to the end of the list of `after` blocks in the same
1859
+ # scope (`:example`, `:context`, or `:suite`), in contrast to {#after},
1860
+ # which adds the hook to the start of the list.
1861
+ #
1862
+ # See {Hooks#after} for full `after` hook docs.
1863
+ #
1864
+ # This method differs from {Hooks#append_after} in only one way: it supports
1865
+ # the `:suite` scope. Hooks with the `:suite` scope will be run once after
1866
+ # the last example of the entire suite is executed.
1867
+ #
1868
+ # @see #append_after
1869
+ # @see #before
1870
+ # @see #prepend_before
1871
+ def append_after(scope=nil, *meta, &block)
1872
+ handle_suite_hook(scope, meta) do
1873
+ @after_suite_hooks << Hooks::AfterHook.new(block, {})
1874
+ end || begin
1875
+ add_hook_to_existing_matching_groups(meta, scope) { |g| g.append_after(scope, *meta, &block) }
1876
+ super(scope, *meta, &block)
1877
+ end
1878
+ end
1879
+
1880
+ # Registers `block` as an `around` hook.
1881
+ #
1882
+ # See {Hooks#around} for full `around` hook docs.
1883
+ def around(scope=nil, *meta, &block)
1884
+ add_hook_to_existing_matching_groups(meta, scope) { |g| g.around(scope, *meta, &block) }
1885
+ super(scope, *meta, &block)
1886
+ end
1887
+
1888
+ # @private
1889
+ def with_suite_hooks
1890
+ return yield if dry_run?
1891
+
1892
+ begin
1893
+ run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
1894
+ yield
1895
+ ensure
1896
+ run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
1897
+ end
1898
+ end
1899
+
1900
+ # @private
1901
+ # Holds the various registered hooks. Here we use a FilterableItemRepository
1902
+ # implementation that is specifically optimized for the read/write patterns
1903
+ # of the config object.
1904
+ def hooks
1905
+ @hooks ||= HookCollections.new(self, FilterableItemRepository::QueryOptimized)
1906
+ end
1907
+
1908
+ # Invokes block before defining an example group
1909
+ def on_example_group_definition(&block)
1910
+ on_example_group_definition_callbacks << block
1911
+ end
1912
+
1913
+ # @api private
1914
+ # Returns an array of blocks to call before defining an example group
1915
+ def on_example_group_definition_callbacks
1916
+ @on_example_group_definition_callbacks ||= []
1917
+ end
1918
+
1919
+ private
1920
+
1921
+ def load_spec_file_handling_errors(file)
1922
+ load file
1923
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
1924
+ relative_file = Metadata.relative_path(file)
1925
+ reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
1926
+ RSpec.world.wants_to_quit = true
1927
+ end
1928
+
1929
+ def handle_suite_hook(scope, meta)
1930
+ return nil unless scope == :suite
1931
+
1932
+ unless meta.empty?
1933
+ # TODO: in RSpec 4, consider raising an error here.
1934
+ # We warn only for backwards compatibility.
1935
+ RSpec.warn_with "WARNING: `:suite` hooks do not support metadata since " \
1936
+ "they apply to the suite as a whole rather than " \
1937
+ "any individual example or example group that has metadata. " \
1938
+ "The metadata you have provided (#{meta.inspect}) will be ignored."
1939
+ end
1940
+
1941
+ yield
1942
+ end
1943
+
1944
+ def run_suite_hooks(hook_description, hooks)
1945
+ context = SuiteHookContext.new(hook_description, reporter)
1946
+
1947
+ hooks.each do |hook|
1948
+ begin
1949
+ hook.run(context)
1950
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
1951
+ context.set_exception(ex)
1952
+
1953
+ # Do not run subsequent `before` hooks if one fails.
1954
+ # But for `after` hooks, we run them all so that all
1955
+ # cleanup bits get a chance to complete, minimizing the
1956
+ # chance that resources get left behind.
1957
+ break if hooks.equal?(@before_suite_hooks)
1958
+ end
1959
+ end
1960
+ end
1961
+
1962
+ def get_files_to_run(paths)
1963
+ files = FlatMap.flat_map(paths_to_check(paths)) do |path|
1964
+ path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
1965
+ File.directory?(path) ? gather_directories(path) : extract_location(path)
1966
+ end.uniq
1967
+
1968
+ return files unless only_failures?
1969
+ relative_files = files.map { |f| Metadata.relative_path(File.expand_path f) }
1970
+ intersection = (relative_files & spec_files_with_failures.to_a)
1971
+ intersection.empty? ? files : intersection
1972
+ end
1973
+
1974
+ def paths_to_check(paths)
1975
+ return paths if pattern_might_load_specs_from_vendored_dirs?
1976
+ paths + [Dir.getwd]
1977
+ end
1978
+
1979
+ def pattern_might_load_specs_from_vendored_dirs?
1980
+ pattern.split(File::SEPARATOR).first.include?('**')
1981
+ end
1982
+
1983
+ def gather_directories(path)
1984
+ include_files = get_matching_files(path, pattern)
1985
+ exclude_files = get_matching_files(path, exclude_pattern)
1986
+ (include_files - exclude_files).uniq
1987
+ end
1988
+
1989
+ def get_matching_files(path, pattern)
1990
+ raw_files = Dir[file_glob_from(path, pattern)]
1991
+ raw_files.map { |file| File.expand_path(file) }.sort
1992
+ end
1993
+
1994
+ def file_glob_from(path, pattern)
1995
+ stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
1996
+ return stripped if pattern =~ /^(\.\/)?#{Regexp.escape path}/ || absolute_pattern?(pattern)
1997
+ File.join(path, stripped)
1998
+ end
1999
+
2000
+ if RSpec::Support::OS.windows?
2001
+ # :nocov:
2002
+ def absolute_pattern?(pattern)
2003
+ pattern =~ /\A[A-Z]:\\/ || windows_absolute_network_path?(pattern)
2004
+ end
2005
+
2006
+ def windows_absolute_network_path?(pattern)
2007
+ return false unless ::File::ALT_SEPARATOR
2008
+ pattern.start_with?(::File::ALT_SEPARATOR + ::File::ALT_SEPARATOR)
2009
+ end
2010
+ # :nocov:
2011
+ else
2012
+ def absolute_pattern?(pattern)
2013
+ pattern.start_with?(File::Separator)
2014
+ end
2015
+ end
2016
+
2017
+ def extract_location(path)
2018
+ match = /^(.*?)((?:\:\d+)+)$/.match(path)
2019
+
2020
+ if match
2021
+ captures = match.captures
2022
+ path = captures[0]
2023
+ lines = captures[1][1..-1].split(":").map(&:to_i)
2024
+ filter_manager.add_location path, lines
2025
+ else
2026
+ path, scoped_ids = Example.parse_id(path)
2027
+ filter_manager.add_ids(path, scoped_ids.split(/\s*,\s*/)) if scoped_ids
2028
+ end
2029
+
2030
+ return [] if path == default_path
2031
+ File.expand_path(path)
2032
+ end
2033
+
2034
+ def command
2035
+ $0.split(File::SEPARATOR).last
2036
+ end
2037
+
2038
+ def value_for(key)
2039
+ @preferred_options.fetch(key) { yield }
2040
+ end
2041
+
2042
+ def define_built_in_hooks
2043
+ around(:example, :aggregate_failures => true) do |procsy|
2044
+ begin
2045
+ aggregate_failures(nil, :hide_backtrace => true, &procsy)
2046
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue => exception
2047
+ procsy.example.set_aggregate_failures_exception(exception)
2048
+ end
2049
+ end
2050
+ end
2051
+
2052
+ def assert_no_example_groups_defined(config_option)
2053
+ return unless world.example_groups.any?
2054
+
2055
+ raise MustBeConfiguredBeforeExampleGroupsError.new(
2056
+ "RSpec's #{config_option} configuration option must be configured before " \
2057
+ "any example groups are defined, but you have already defined a group."
2058
+ )
2059
+ end
2060
+
2061
+ def output_wrapper
2062
+ @output_wrapper ||= OutputWrapper.new(output_stream)
2063
+ end
2064
+
2065
+ def output_to_tty?(output=output_stream)
2066
+ output.respond_to?(:tty?) && output.tty?
2067
+ end
2068
+
2069
+ def conditionally_disable_mocks_monkey_patching
2070
+ return unless disable_monkey_patching && rspec_mocks_loaded?
2071
+
2072
+ RSpec::Mocks.configuration.tap do |config|
2073
+ config.syntax = :expect
2074
+ config.patch_marshal_to_support_partial_doubles = false
2075
+ end
2076
+ end
2077
+
2078
+ def conditionally_disable_expectations_monkey_patching
2079
+ return unless disable_monkey_patching && rspec_expectations_loaded?
2080
+
2081
+ RSpec::Expectations.configuration.syntax = :expect
2082
+ end
2083
+
2084
+ def rspec_mocks_loaded?
2085
+ defined?(RSpec::Mocks.configuration)
2086
+ end
2087
+
2088
+ def rspec_expectations_loaded?
2089
+ defined?(RSpec::Expectations.configuration)
2090
+ end
2091
+
2092
+ def update_pattern_attr(name, value)
2093
+ if @spec_files_loaded
2094
+ RSpec.warning "Configuring `#{name}` to #{value} has no effect since " \
2095
+ "RSpec has already loaded the spec files."
2096
+ end
2097
+
2098
+ instance_variable_set(:"@#{name}", value)
2099
+ @files_to_run = nil
2100
+ end
2101
+
2102
+ def clear_values_derived_from_example_status_persistence_file_path
2103
+ @last_run_statuses = nil
2104
+ @spec_files_with_failures = nil
2105
+ end
2106
+
2107
+ def configure_group_with(group, module_list, application_method)
2108
+ module_list.items_for(group.metadata).each do |mod|
2109
+ __send__(application_method, mod, group)
2110
+ end
2111
+ end
2112
+
2113
+ def add_hook_to_existing_matching_groups(meta, scope, &block)
2114
+ # For example hooks, we have to apply it to each of the top level
2115
+ # groups, even if the groups do not match. When we apply it, we
2116
+ # apply it with the metadata, so it will only apply to examples
2117
+ # in the group that match the metadata.
2118
+ # #2280 for background and discussion.
2119
+ if scope == :example || scope == :each || scope.nil?
2120
+ world.example_groups.each(&block)
2121
+ else
2122
+ meta = Metadata.build_hash_from(meta.dup)
2123
+ on_existing_matching_groups(meta, &block)
2124
+ end
2125
+ end
2126
+
2127
+ def on_existing_matching_groups(meta)
2128
+ world.traverse_example_group_trees_until do |group|
2129
+ metadata_applies_to_group?(meta, group).tap do |applies|
2130
+ yield group if applies
2131
+ end
2132
+ end
2133
+ end
2134
+
2135
+ def metadata_applies_to_group?(meta, group)
2136
+ meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata)
2137
+ end
2138
+
2139
+ if RSpec::Support::RubyFeatures.module_prepends_supported?
2140
+ def safe_prepend(mod, host)
2141
+ host.__send__(:prepend, mod) unless host < mod
2142
+ end
2143
+ end
2144
+
2145
+ if RUBY_VERSION.to_f >= 1.9
2146
+ def safe_include(mod, host)
2147
+ host.__send__(:include, mod) unless host < mod
2148
+ end
2149
+
2150
+ def safe_extend(mod, host)
2151
+ host.extend(mod) unless host.singleton_class < mod
2152
+ end
2153
+ else # for 1.8.7
2154
+ # :nocov:
2155
+ def safe_include(mod, host)
2156
+ host.__send__(:include, mod) unless host.included_modules.include?(mod)
2157
+ end
2158
+
2159
+ def safe_extend(mod, host)
2160
+ host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
2161
+ end
2162
+ # :nocov:
2163
+ end
2164
+
2165
+ def define_mixed_in_module(mod, filters, mod_list, config_method, &block)
2166
+ unless Module === mod
2167
+ raise TypeError, "`RSpec.configuration.#{config_method}` expects a module but got: #{mod.inspect}"
2168
+ end
2169
+
2170
+ meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
2171
+ mod_list.append(mod, meta)
2172
+ on_existing_matching_groups(meta, &block)
2173
+ end
2174
+ end
2175
+ # rubocop:enable Metrics/ClassLength
2176
+ end
2177
+ end