genkaio 0.0.1

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