opal-rspec 0.4.3 → 0.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (525) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +9 -3
  4. data/Gemfile +6 -5
  5. data/README.md +73 -13
  6. data/Rakefile +108 -12
  7. data/lib/opal/rspec/version.rb +1 -1
  8. data/lib/opal/rspec.rb +35 -12
  9. data/opal/opal/rspec/async/async_example.rb +87 -0
  10. data/opal/opal/rspec/async/example_group.rb +94 -0
  11. data/opal/opal/rspec/async/hooks.rb +46 -0
  12. data/opal/opal/rspec/async/legacy.rb +50 -0
  13. data/opal/opal/rspec/async.rb +4 -289
  14. data/opal/opal/rspec/browser_formatter.rb +55 -18
  15. data/opal/opal/rspec/fixes/caller_filter.rb +6 -0
  16. data/opal/opal/rspec/fixes/example.rb +20 -0
  17. data/opal/opal/rspec/fixes/example_groups.rb +32 -0
  18. data/opal/opal/rspec/fixes/expectations.rb +21 -0
  19. data/opal/opal/rspec/fixes/formatter.rb +62 -0
  20. data/opal/opal/rspec/fixes/kernel.rb +35 -0
  21. data/opal/opal/rspec/fixes/matchers.rb +15 -0
  22. data/opal/opal/rspec/fixes/mocks.rb +13 -0
  23. data/opal/opal/rspec/fixes/reporter.rb +12 -0
  24. data/opal/opal/rspec/fixes.rb +11 -115
  25. data/opal/opal/rspec/pre_require_fixes.rb +4 -0
  26. data/opal/opal/rspec/requires.rb +103 -35
  27. data/opal/opal/rspec/runner.rb +19 -15
  28. data/opal/opal/rspec/text_formatter.rb +24 -10
  29. data/opal/opal/rspec.rb +4 -9
  30. data/opal-rspec.gemspec +5 -2
  31. data/{vendor_lib → rspec/lib}/rspec/version.rb +1 -1
  32. data/{vendor_lib → rspec/lib}/rspec.rb +0 -0
  33. data/rspec-core/benchmarks/call_v_yield.rb +81 -0
  34. data/rspec-core/benchmarks/check_inclusion.rb +125 -0
  35. data/rspec-core/benchmarks/define_method_v_attr_reader_v_def.rb +81 -0
  36. data/rspec-core/benchmarks/eager_vs_lazy_metadata/define_examples.rb +22 -0
  37. data/rspec-core/benchmarks/eager_vs_lazy_metadata.rb +126 -0
  38. data/rspec-core/benchmarks/filter_object.rb +35 -0
  39. data/rspec-core/benchmarks/index_v_take_while.rb +47 -0
  40. data/rspec-core/benchmarks/map_then_flatten_vs_flat_map_benchmarks.rb +94 -0
  41. data/rspec-core/benchmarks/require_relative_v_require.rb +75 -0
  42. data/rspec-core/benchmarks/respond_to_v_defined.rb +72 -0
  43. data/rspec-core/benchmarks/several_regexps_v_one_big_one.rb +86 -0
  44. data/rspec-core/benchmarks/sort_by_v_shuffle.rb +83 -0
  45. data/rspec-core/benchmarks/to_proc_v_not_to_proc.rb +539 -0
  46. data/rspec-core/features/step_definitions/additional_cli_steps.rb +126 -0
  47. data/rspec-core/features/step_definitions/core_standalone_steps.rb +12 -0
  48. data/rspec-core/features/support/env.rb +21 -0
  49. data/rspec-core/features/support/require_expect_syntax_in_aruba_specs.rb +29 -0
  50. data/rspec-core/features/support/rubinius.rb +6 -0
  51. data/{vendor_lib → rspec-core/lib}/rspec/autorun.rb +0 -0
  52. data/{vendor_lib → rspec-core/lib}/rspec/core/backport_random.rb +40 -6
  53. data/rspec-core/lib/rspec/core/backtrace_formatter.rb +66 -0
  54. data/{vendor_lib → rspec-core/lib}/rspec/core/configuration.rb +561 -250
  55. data/rspec-core/lib/rspec/core/configuration_options.rb +173 -0
  56. data/rspec-core/lib/rspec/core/drb.rb +111 -0
  57. data/rspec-core/lib/rspec/core/dsl.rb +93 -0
  58. data/rspec-core/lib/rspec/core/example.rb +502 -0
  59. data/rspec-core/lib/rspec/core/example_group.rb +606 -0
  60. data/rspec-core/lib/rspec/core/filter_manager.rb +259 -0
  61. data/{vendor_lib → rspec-core/lib}/rspec/core/flat_map.rb +1 -0
  62. data/rspec-core/lib/rspec/core/formatters/base_formatter.rb +67 -0
  63. data/rspec-core/lib/rspec/core/formatters/base_text_formatter.rb +76 -0
  64. data/rspec-core/lib/rspec/core/formatters/console_codes.rb +64 -0
  65. data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/deprecation_formatter.rb +65 -36
  66. data/rspec-core/lib/rspec/core/formatters/documentation_formatter.rb +68 -0
  67. data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/helpers.rb +18 -13
  68. data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/html_formatter.rb +69 -75
  69. data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/html_printer.rb +17 -22
  70. data/rspec-core/lib/rspec/core/formatters/json_formatter.rb +94 -0
  71. data/rspec-core/lib/rspec/core/formatters/profile_formatter.rb +65 -0
  72. data/rspec-core/lib/rspec/core/formatters/progress_formatter.rb +28 -0
  73. data/rspec-core/lib/rspec/core/formatters/protocol.rb +163 -0
  74. data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/snippet_extractor.rb +15 -12
  75. data/rspec-core/lib/rspec/core/formatters.rb +240 -0
  76. data/rspec-core/lib/rspec/core/hooks.rb +591 -0
  77. data/{vendor_lib → rspec-core/lib}/rspec/core/memoized_helpers.rb +82 -41
  78. data/rspec-core/lib/rspec/core/metadata.rb +437 -0
  79. data/rspec-core/lib/rspec/core/metadata_filter.rb +95 -0
  80. data/rspec-core/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
  81. data/rspec-core/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
  82. data/{vendor_lib/rspec/core/mocking/with_mocha.rb → rspec-core/lib/rspec/core/mocking_adapters/mocha.rb} +21 -16
  83. data/rspec-core/lib/rspec/core/mocking_adapters/null.rb +14 -0
  84. data/rspec-core/lib/rspec/core/mocking_adapters/rr.rb +31 -0
  85. data/rspec-core/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
  86. data/rspec-core/lib/rspec/core/notifications.rb +542 -0
  87. data/{vendor_lib → rspec-core/lib}/rspec/core/option_parser.rb +53 -65
  88. data/{vendor_lib → rspec-core/lib}/rspec/core/ordering.rb +11 -10
  89. data/rspec-core/lib/rspec/core/pending.rb +163 -0
  90. data/rspec-core/lib/rspec/core/project_initializer/spec/spec_helper.rb +89 -0
  91. data/rspec-core/lib/rspec/core/project_initializer.rb +48 -0
  92. data/rspec-core/lib/rspec/core/rake_task.rb +187 -0
  93. data/rspec-core/lib/rspec/core/reporter.rb +149 -0
  94. data/{vendor_lib → rspec-core/lib}/rspec/core/ruby_project.rb +3 -2
  95. data/rspec-core/lib/rspec/core/runner.rb +158 -0
  96. data/{vendor_lib → rspec-core/lib}/rspec/core/shared_context.rb +7 -5
  97. data/rspec-core/lib/rspec/core/shared_example_group.rb +182 -0
  98. data/rspec-core/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  99. data/rspec-core/lib/rspec/core/version.rb +9 -0
  100. data/rspec-core/lib/rspec/core/warnings.rb +40 -0
  101. data/{vendor_lib → rspec-core/lib}/rspec/core/world.rb +78 -26
  102. data/{vendor_lib → rspec-core/lib}/rspec/core.rb +64 -98
  103. data/rspec-core/spec/command_line/order_spec.rb +213 -0
  104. data/rspec-core/spec/rspec/core/backtrace_formatter_spec.rb +306 -0
  105. data/rspec-core/spec/rspec/core/configuration_options_spec.rb +425 -0
  106. data/rspec-core/spec/rspec/core/configuration_spec.rb +1963 -0
  107. data/rspec-core/spec/rspec/core/drb_spec.rb +278 -0
  108. data/rspec-core/spec/rspec/core/dsl_spec.rb +85 -0
  109. data/rspec-core/spec/rspec/core/example_execution_result_spec.rb +142 -0
  110. data/rspec-core/spec/rspec/core/example_group_constants_spec.rb +16 -0
  111. data/rspec-core/spec/rspec/core/example_group_spec.rb +1621 -0
  112. data/rspec-core/spec/rspec/core/example_spec.rb +662 -0
  113. data/rspec-core/spec/rspec/core/failed_example_notification_spec.rb +25 -0
  114. data/rspec-core/spec/rspec/core/filter_manager_spec.rb +299 -0
  115. data/rspec-core/spec/rspec/core/formatters/base_text_formatter_spec.rb +182 -0
  116. data/rspec-core/spec/rspec/core/formatters/console_codes_spec.rb +65 -0
  117. data/rspec-core/spec/rspec/core/formatters/deprecation_formatter_spec.rb +225 -0
  118. data/rspec-core/spec/rspec/core/formatters/documentation_formatter_spec.rb +111 -0
  119. data/rspec-core/spec/rspec/core/formatters/helpers_spec.rb +104 -0
  120. data/rspec-core/spec/rspec/core/formatters/html_formatter_spec.rb +111 -0
  121. data/rspec-core/spec/rspec/core/formatters/json_formatter_spec.rb +183 -0
  122. data/rspec-core/spec/rspec/core/formatters/profile_formatter_spec.rb +99 -0
  123. data/rspec-core/spec/rspec/core/formatters/progress_formatter_spec.rb +55 -0
  124. data/rspec-core/spec/rspec/core/formatters/snippet_extractor_spec.rb +26 -0
  125. data/rspec-core/spec/rspec/core/formatters_spec.rb +160 -0
  126. data/rspec-core/spec/rspec/core/hooks_filtering_spec.rb +227 -0
  127. data/rspec-core/spec/rspec/core/hooks_spec.rb +447 -0
  128. data/rspec-core/spec/rspec/core/memoized_helpers_spec.rb +537 -0
  129. data/rspec-core/spec/rspec/core/metadata_filter_spec.rb +181 -0
  130. data/rspec-core/spec/rspec/core/metadata_spec.rb +642 -0
  131. data/rspec-core/spec/rspec/core/notifications_spec.rb +92 -0
  132. data/rspec-core/spec/rspec/core/option_parser_spec.rb +270 -0
  133. data/rspec-core/spec/rspec/core/ordering_spec.rb +102 -0
  134. data/rspec-core/spec/rspec/core/pending_example_spec.rb +221 -0
  135. data/rspec-core/spec/rspec/core/pending_spec.rb +8 -0
  136. data/rspec-core/spec/rspec/core/project_initializer_spec.rb +123 -0
  137. data/rspec-core/spec/rspec/core/rake_task_spec.rb +351 -0
  138. data/rspec-core/spec/rspec/core/random_spec.rb +47 -0
  139. data/rspec-core/spec/rspec/core/reporter_spec.rb +198 -0
  140. data/rspec-core/spec/rspec/core/resources/a_bar.rb +0 -0
  141. data/rspec-core/spec/rspec/core/resources/a_foo.rb +0 -0
  142. data/rspec-core/spec/rspec/core/resources/a_spec.rb +1 -0
  143. data/rspec-core/spec/rspec/core/resources/acceptance/bar.rb +0 -0
  144. data/rspec-core/spec/rspec/core/resources/acceptance/foo_spec.rb +0 -0
  145. data/rspec-core/spec/rspec/core/resources/custom_example_group_runner.rb +14 -0
  146. data/rspec-core/spec/rspec/core/resources/formatter_specs.rb +58 -0
  147. data/rspec-core/spec/rspec/core/resources/utf8_encoded.rb +9 -0
  148. data/rspec-core/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  149. data/rspec-core/spec/rspec/core/ruby_project_spec.rb +26 -0
  150. data/rspec-core/spec/rspec/core/runner_spec.rb +309 -0
  151. data/rspec-core/spec/rspec/core/shared_context_spec.rb +102 -0
  152. data/rspec-core/spec/rspec/core/shared_example_group_spec.rb +268 -0
  153. data/rspec-core/spec/rspec/core/warnings_spec.rb +72 -0
  154. data/rspec-core/spec/rspec/core/world_spec.rb +142 -0
  155. data/rspec-core/spec/rspec/core_spec.rb +103 -0
  156. data/rspec-core/spec/spec_helper.rb +89 -0
  157. data/rspec-core/spec/support/config_options_helper.rb +13 -0
  158. data/rspec-core/spec/support/fake_minitest/minitest/minitest_assertions.rb +4 -0
  159. data/rspec-core/spec/support/fake_minitest/minitest.rb +0 -0
  160. data/rspec-core/spec/support/fake_minitest/test/unit/assertions.rb +6 -0
  161. data/rspec-core/spec/support/formatter_support.rb +263 -0
  162. data/rspec-core/spec/support/helper_methods.rb +26 -0
  163. data/rspec-core/spec/support/isolated_home_directory.rb +16 -0
  164. data/rspec-core/spec/support/matchers.rb +103 -0
  165. data/rspec-core/spec/support/mathn_integration_support.rb +12 -0
  166. data/rspec-core/spec/support/sandboxing.rb +50 -0
  167. data/rspec-core/spec/support/shared_example_groups.rb +43 -0
  168. data/rspec-core/spec/support/spec_files.rb +44 -0
  169. data/rspec-expectations/benchmarks/2.x_vs_3.x_matcher_dsl_implementation.rb +253 -0
  170. data/rspec-expectations/benchmarks/autoload_v_require.rb +25 -0
  171. data/rspec-expectations/benchmarks/cloning_matchers.rb +19 -0
  172. data/rspec-expectations/benchmarks/default_messages_as_methods_v_blocks.rb +27 -0
  173. data/rspec-expectations/benchmarks/example_spec.rb +9 -0
  174. data/rspec-expectations/benchmarks/include_v_superclass.rb +39 -0
  175. data/rspec-expectations/benchmarks/match_array/failing_with_distinct_items.rb +147 -0
  176. data/rspec-expectations/benchmarks/match_array/failing_with_duplicate_items.rb +122 -0
  177. data/rspec-expectations/benchmarks/match_array/passing_with_distinct_items.rb +154 -0
  178. data/rspec-expectations/benchmarks/match_array/passing_with_duplicate_items.rb +132 -0
  179. data/rspec-expectations/benchmarks/match_array/rubyprof/passing_with_distinct_items.rb +9 -0
  180. data/rspec-expectations/benchmarks/matcher_dsl_vs_classes.rb +180 -0
  181. data/rspec-expectations/benchmarks/method_to_proc.rb +72 -0
  182. data/rspec-expectations/benchmarks/set_vs_array_include.rb +68 -0
  183. data/rspec-expectations/features/step_definitions/additional_cli_steps.rb +22 -0
  184. data/rspec-expectations/features/support/disallow_certain_apis.rb +34 -0
  185. data/rspec-expectations/features/support/env.rb +21 -0
  186. data/rspec-expectations/features/support/rubinius.rb +6 -0
  187. data/{vendor_lib/rspec/matchers → rspec-expectations/lib/rspec/expectations}/configuration.rb +50 -16
  188. data/rspec-expectations/lib/rspec/expectations/expectation_target.rb +119 -0
  189. data/rspec-expectations/lib/rspec/expectations/fail_with.rb +34 -0
  190. data/rspec-expectations/lib/rspec/expectations/handler.rb +167 -0
  191. data/rspec-expectations/lib/rspec/expectations/minitest_integration.rb +17 -0
  192. data/rspec-expectations/lib/rspec/expectations/syntax.rb +132 -0
  193. data/{vendor_lib → rspec-expectations/lib}/rspec/expectations/version.rb +1 -1
  194. data/rspec-expectations/lib/rspec/expectations.rb +68 -0
  195. data/rspec-expectations/lib/rspec/matchers/aliased_matcher.rb +116 -0
  196. data/rspec-expectations/lib/rspec/matchers/built_in/all.rb +85 -0
  197. data/rspec-expectations/lib/rspec/matchers/built_in/base_matcher.rb +132 -0
  198. data/rspec-expectations/lib/rspec/matchers/built_in/be.rb +277 -0
  199. data/rspec-expectations/lib/rspec/matchers/built_in/be_between.rb +77 -0
  200. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/be_instance_of.rb +11 -4
  201. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/be_kind_of.rb +5 -0
  202. data/rspec-expectations/lib/rspec/matchers/built_in/be_within.rb +72 -0
  203. data/rspec-expectations/lib/rspec/matchers/built_in/change.rb +337 -0
  204. data/rspec-expectations/lib/rspec/matchers/built_in/compound.rb +258 -0
  205. data/rspec-expectations/lib/rspec/matchers/built_in/contain_exactly.rb +249 -0
  206. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/cover.rb +3 -0
  207. data/rspec-expectations/lib/rspec/matchers/built_in/eq.rb +75 -0
  208. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/eql.rb +17 -6
  209. data/rspec-expectations/lib/rspec/matchers/built_in/equal.rb +81 -0
  210. data/rspec-expectations/lib/rspec/matchers/built_in/exist.rb +86 -0
  211. data/rspec-expectations/lib/rspec/matchers/built_in/has.rb +101 -0
  212. data/rspec-expectations/lib/rspec/matchers/built_in/have_attributes.rb +84 -0
  213. data/rspec-expectations/lib/rspec/matchers/built_in/include.rb +105 -0
  214. data/rspec-expectations/lib/rspec/matchers/built_in/match.rb +29 -0
  215. data/rspec-expectations/lib/rspec/matchers/built_in/operators.rb +119 -0
  216. data/rspec-expectations/lib/rspec/matchers/built_in/output.rb +152 -0
  217. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/raise_error.rb +66 -46
  218. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/respond_to.rb +43 -26
  219. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/satisfy.rb +13 -4
  220. data/rspec-expectations/lib/rspec/matchers/built_in/start_and_end_with.rb +82 -0
  221. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/throw_symbol.rb +51 -13
  222. data/rspec-expectations/lib/rspec/matchers/built_in/yield.rb +420 -0
  223. data/rspec-expectations/lib/rspec/matchers/built_in.rb +52 -0
  224. data/rspec-expectations/lib/rspec/matchers/composable.rb +183 -0
  225. data/{vendor_lib/rspec/matchers/matcher.rb → rspec-expectations/lib/rspec/matchers/dsl.rb} +120 -30
  226. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/generated_descriptions.rb +13 -6
  227. data/rspec-expectations/lib/rspec/matchers/matcher_delegator.rb +33 -0
  228. data/rspec-expectations/lib/rspec/matchers/matcher_protocol.rb +99 -0
  229. data/rspec-expectations/lib/rspec/matchers/pretty.rb +77 -0
  230. data/{vendor_lib → rspec-expectations/lib}/rspec/matchers.rb +408 -74
  231. data/rspec-expectations/spec/rspec/expectations/configuration_spec.rb +226 -0
  232. data/rspec-expectations/spec/rspec/expectations/expectation_target_spec.rb +147 -0
  233. data/rspec-expectations/spec/rspec/expectations/extensions/kernel_spec.rb +69 -0
  234. data/rspec-expectations/spec/rspec/expectations/fail_with_spec.rb +73 -0
  235. data/rspec-expectations/spec/rspec/expectations/handler_spec.rb +200 -0
  236. data/rspec-expectations/spec/rspec/expectations/minitest_integration_spec.rb +25 -0
  237. data/rspec-expectations/spec/rspec/expectations/syntax_spec.rb +93 -0
  238. data/rspec-expectations/spec/rspec/expectations_spec.rb +15 -0
  239. data/rspec-expectations/spec/rspec/matchers/aliased_matcher_spec.rb +113 -0
  240. data/rspec-expectations/spec/rspec/matchers/aliases_spec.rb +455 -0
  241. data/rspec-expectations/spec/rspec/matchers/built_in/all_spec.rb +212 -0
  242. data/rspec-expectations/spec/rspec/matchers/built_in/base_matcher_spec.rb +140 -0
  243. data/rspec-expectations/spec/rspec/matchers/built_in/be_between_spec.rb +157 -0
  244. data/rspec-expectations/spec/rspec/matchers/built_in/be_instance_of_spec.rb +61 -0
  245. data/rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb +39 -0
  246. data/rspec-expectations/spec/rspec/matchers/built_in/be_spec.rb +685 -0
  247. data/rspec-expectations/spec/rspec/matchers/built_in/be_within_spec.rb +139 -0
  248. data/rspec-expectations/spec/rspec/matchers/built_in/change_spec.rb +829 -0
  249. data/rspec-expectations/spec/rspec/matchers/built_in/compound_spec.rb +537 -0
  250. data/rspec-expectations/spec/rspec/matchers/built_in/contain_exactly_spec.rb +556 -0
  251. data/rspec-expectations/spec/rspec/matchers/built_in/cover_spec.rb +67 -0
  252. data/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb +176 -0
  253. data/rspec-expectations/spec/rspec/matchers/built_in/eql_spec.rb +39 -0
  254. data/rspec-expectations/spec/rspec/matchers/built_in/equal_spec.rb +130 -0
  255. data/rspec-expectations/spec/rspec/matchers/built_in/exist_spec.rb +139 -0
  256. data/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb +179 -0
  257. data/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb +177 -0
  258. data/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb +587 -0
  259. data/rspec-expectations/spec/rspec/matchers/built_in/match_spec.rb +100 -0
  260. data/rspec-expectations/spec/rspec/matchers/built_in/operators_spec.rb +250 -0
  261. data/rspec-expectations/spec/rspec/matchers/built_in/output_spec.rb +168 -0
  262. data/rspec-expectations/spec/rspec/matchers/built_in/raise_error_spec.rb +446 -0
  263. data/rspec-expectations/spec/rspec/matchers/built_in/respond_to_spec.rb +290 -0
  264. data/rspec-expectations/spec/rspec/matchers/built_in/satisfy_spec.rb +42 -0
  265. data/rspec-expectations/spec/rspec/matchers/built_in/start_and_end_with_spec.rb +347 -0
  266. data/rspec-expectations/spec/rspec/matchers/built_in/throw_symbol_spec.rb +133 -0
  267. data/rspec-expectations/spec/rspec/matchers/built_in/yield_spec.rb +643 -0
  268. data/rspec-expectations/spec/rspec/matchers/composable_spec.rb +77 -0
  269. data/rspec-expectations/spec/rspec/matchers/define_negated_matcher_spec.rb +199 -0
  270. data/rspec-expectations/spec/rspec/matchers/description_generation_spec.rb +189 -0
  271. data/rspec-expectations/spec/rspec/matchers/dsl_spec.rb +1036 -0
  272. data/rspec-expectations/spec/rspec/matchers/legacy_spec.rb +104 -0
  273. data/rspec-expectations/spec/rspec/matchers_spec.rb +108 -0
  274. data/rspec-expectations/spec/spec_helper.rb +94 -0
  275. data/rspec-expectations/spec/support/matchers.rb +54 -0
  276. data/rspec-expectations/spec/support/shared_examples.rb +101 -0
  277. data/rspec-mocks/benchmarks/double_creation.rb +66 -0
  278. data/rspec-mocks/benchmarks/each_value_v_values_each.rb +58 -0
  279. data/rspec-mocks/benchmarks/find_original_method_early.rb +64 -0
  280. data/rspec-mocks/benchmarks/method_defined_at_any_visibility.rb +101 -0
  281. data/rspec-mocks/benchmarks/thread_safety.rb +24 -0
  282. data/rspec-mocks/benchmarks/transfer_nested_constants.rb +77 -0
  283. data/rspec-mocks/features/step_definitions/additional_cli_steps.rb +21 -0
  284. data/rspec-mocks/features/support/disallow_certain_apis.rb +24 -0
  285. data/rspec-mocks/features/support/env.rb +22 -0
  286. data/rspec-mocks/features/support/rubinius.rb +6 -0
  287. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/chain.rb +19 -2
  288. data/rspec-mocks/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
  289. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/expectation_chain.rb +12 -11
  290. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/message_chains.rb +15 -5
  291. data/rspec-mocks/lib/rspec/mocks/any_instance/proxy.rb +116 -0
  292. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/recorder.rb +105 -38
  293. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/stub_chain.rb +9 -9
  294. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/stub_chain_chain.rb +5 -1
  295. data/rspec-mocks/lib/rspec/mocks/any_instance.rb +10 -0
  296. data/rspec-mocks/lib/rspec/mocks/argument_list_matcher.rb +72 -0
  297. data/rspec-mocks/lib/rspec/mocks/argument_matchers.rb +282 -0
  298. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/configuration.rb +60 -14
  299. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/error_generator.rb +93 -43
  300. data/rspec-mocks/lib/rspec/mocks/example_methods.rb +379 -0
  301. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/instance_method_stasher.rb +30 -7
  302. data/rspec-mocks/lib/rspec/mocks/marshal_extension.rb +41 -0
  303. data/rspec-mocks/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
  304. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/have_received.rb +36 -14
  305. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/receive.rb +24 -30
  306. data/rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb +66 -0
  307. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/receive_messages.rb +9 -10
  308. data/rspec-mocks/lib/rspec/mocks/message_chain.rb +91 -0
  309. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/message_expectation.rb +156 -105
  310. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/method_double.rb +81 -30
  311. data/rspec-mocks/lib/rspec/mocks/method_reference.rb +155 -0
  312. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/mutate_const.rb +84 -166
  313. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/object_reference.rb +19 -18
  314. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/order_group.rb +4 -5
  315. data/rspec-mocks/lib/rspec/mocks/proxy.rb +431 -0
  316. data/rspec-mocks/lib/rspec/mocks/space.rb +221 -0
  317. data/rspec-mocks/lib/rspec/mocks/standalone.rb +3 -0
  318. data/rspec-mocks/lib/rspec/mocks/syntax.rb +329 -0
  319. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/targets.rb +20 -13
  320. data/rspec-mocks/lib/rspec/mocks/test_double.rb +135 -0
  321. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_double.rb +69 -19
  322. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_message_expecation.rb +23 -21
  323. data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_proxy.rb +58 -38
  324. data/rspec-mocks/lib/rspec/mocks/version.rb +9 -0
  325. data/rspec-mocks/lib/rspec/mocks.rb +126 -0
  326. data/rspec-mocks/spec/rspec/mocks/and_call_original_spec.rb +267 -0
  327. data/rspec-mocks/spec/rspec/mocks/and_return_spec.rb +21 -0
  328. data/rspec-mocks/spec/rspec/mocks/and_wrap_original_spec.rb +63 -0
  329. data/rspec-mocks/spec/rspec/mocks/and_yield_spec.rb +161 -0
  330. data/rspec-mocks/spec/rspec/mocks/any_instance/message_chains_spec.rb +39 -0
  331. data/rspec-mocks/spec/rspec/mocks/any_instance_spec.rb +1242 -0
  332. data/rspec-mocks/spec/rspec/mocks/argument_matchers_spec.rb +336 -0
  333. data/rspec-mocks/spec/rspec/mocks/array_including_matcher_spec.rb +39 -0
  334. data/rspec-mocks/spec/rspec/mocks/at_least_spec.rb +147 -0
  335. data/rspec-mocks/spec/rspec/mocks/at_most_spec.rb +113 -0
  336. data/rspec-mocks/spec/rspec/mocks/before_all_spec.rb +75 -0
  337. data/rspec-mocks/spec/rspec/mocks/block_return_value_spec.rb +68 -0
  338. data/rspec-mocks/spec/rspec/mocks/combining_implementation_instructions_spec.rb +196 -0
  339. data/rspec-mocks/spec/rspec/mocks/configuration_spec.rb +175 -0
  340. data/rspec-mocks/spec/rspec/mocks/double_spec.rb +830 -0
  341. data/rspec-mocks/spec/rspec/mocks/example_methods_spec.rb +11 -0
  342. data/rspec-mocks/spec/rspec/mocks/expiration_spec.rb +90 -0
  343. data/rspec-mocks/spec/rspec/mocks/hash_excluding_matcher_spec.rb +65 -0
  344. data/rspec-mocks/spec/rspec/mocks/hash_including_matcher_spec.rb +92 -0
  345. data/rspec-mocks/spec/rspec/mocks/instance_method_stasher_spec.rb +72 -0
  346. data/rspec-mocks/spec/rspec/mocks/marshal_extension_spec.rb +67 -0
  347. data/rspec-mocks/spec/rspec/mocks/matchers/have_received_spec.rb +513 -0
  348. data/rspec-mocks/spec/rspec/mocks/matchers/receive_message_chain_spec.rb +227 -0
  349. data/rspec-mocks/spec/rspec/mocks/matchers/receive_messages_spec.rb +148 -0
  350. data/rspec-mocks/spec/rspec/mocks/matchers/receive_spec.rb +525 -0
  351. data/rspec-mocks/spec/rspec/mocks/methods_spec.rb +24 -0
  352. data/rspec-mocks/spec/rspec/mocks/mock_expectation_error_spec.rb +20 -0
  353. data/rspec-mocks/spec/rspec/mocks/mock_ordering_spec.rb +112 -0
  354. data/rspec-mocks/spec/rspec/mocks/multiple_return_value_spec.rb +130 -0
  355. data/rspec-mocks/spec/rspec/mocks/mutate_const_spec.rb +561 -0
  356. data/rspec-mocks/spec/rspec/mocks/nil_expectation_warning_spec.rb +52 -0
  357. data/rspec-mocks/spec/rspec/mocks/null_object_double_spec.rb +135 -0
  358. data/rspec-mocks/spec/rspec/mocks/once_counts_spec.rb +50 -0
  359. data/rspec-mocks/spec/rspec/mocks/order_group_spec.rb +26 -0
  360. data/rspec-mocks/spec/rspec/mocks/partial_double_spec.rb +379 -0
  361. data/rspec-mocks/spec/rspec/mocks/partial_double_using_mocks_directly_spec.rb +83 -0
  362. data/rspec-mocks/spec/rspec/mocks/precise_counts_spec.rb +66 -0
  363. data/rspec-mocks/spec/rspec/mocks/serialization_spec.rb +89 -0
  364. data/rspec-mocks/spec/rspec/mocks/should_syntax_spec.rb +539 -0
  365. data/rspec-mocks/spec/rspec/mocks/space_spec.rb +242 -0
  366. data/rspec-mocks/spec/rspec/mocks/spy_spec.rb +127 -0
  367. data/rspec-mocks/spec/rspec/mocks/stash_spec.rb +43 -0
  368. data/rspec-mocks/spec/rspec/mocks/stub_chain_spec.rb +166 -0
  369. data/rspec-mocks/spec/rspec/mocks/stub_implementation_spec.rb +98 -0
  370. data/rspec-mocks/spec/rspec/mocks/stub_spec.rb +520 -0
  371. data/rspec-mocks/spec/rspec/mocks/stubbed_message_expectations_spec.rb +56 -0
  372. data/rspec-mocks/spec/rspec/mocks/syntax_agnostic_message_matchers_spec.rb +99 -0
  373. data/rspec-mocks/spec/rspec/mocks/syntax_spec.rb +7 -0
  374. data/rspec-mocks/spec/rspec/mocks/test_double_spec.rb +53 -0
  375. data/rspec-mocks/spec/rspec/mocks/thrice_counts_spec.rb +72 -0
  376. data/rspec-mocks/spec/rspec/mocks/to_ary_spec.rb +52 -0
  377. data/rspec-mocks/spec/rspec/mocks/twice_counts_spec.rb +64 -0
  378. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/class_double_with_class_loaded_spec.rb +118 -0
  379. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb +58 -0
  380. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/construction_spec.rb +54 -0
  381. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/expected_arg_verification_spec.rb +81 -0
  382. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/instance_double_with_class_loaded_spec.rb +195 -0
  383. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/instance_double_with_class_not_loaded_spec.rb +57 -0
  384. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/method_visibility_spec.rb +129 -0
  385. data/rspec-mocks/spec/rspec/mocks/verifying_doubles/object_double_spec.rb +68 -0
  386. data/rspec-mocks/spec/rspec/mocks_spec.rb +199 -0
  387. data/rspec-mocks/spec/spec_helper.rb +131 -0
  388. data/rspec-mocks/spec/support/before_all_shared_example_group.rb +16 -0
  389. data/rspec-mocks/spec/support/doubled_classes.rb +74 -0
  390. data/rspec-mocks/spec/support/matchers.rb +15 -0
  391. data/rspec-support/benchmarks/caller.rb +81 -0
  392. data/{vendor_lib → rspec-support/lib}/rspec/support/caller_filter.rb +11 -4
  393. data/rspec-support/lib/rspec/support/differ.rb +214 -0
  394. data/rspec-support/lib/rspec/support/directory_maker.rb +61 -0
  395. data/rspec-support/lib/rspec/support/encoded_string.rb +69 -0
  396. data/rspec-support/lib/rspec/support/fuzzy_matcher.rb +48 -0
  397. data/rspec-support/lib/rspec/support/hunk_generator.rb +47 -0
  398. data/rspec-support/lib/rspec/support/matcher_definition.rb +31 -0
  399. data/rspec-support/lib/rspec/support/method_signature_verifier.rb +272 -0
  400. data/rspec-support/lib/rspec/support/os.rb +18 -0
  401. data/rspec-support/lib/rspec/support/recursive_const_methods.rb +76 -0
  402. data/rspec-support/lib/rspec/support/ruby_features.rb +45 -0
  403. data/rspec-support/lib/rspec/support/spec/deprecation_helpers.rb +60 -0
  404. data/rspec-support/lib/rspec/support/spec/formatting_support.rb +9 -0
  405. data/{vendor_lib → rspec-support/lib}/rspec/support/spec/in_sub_process.rb +5 -2
  406. data/rspec-support/lib/rspec/support/spec/prevent_load_time_warnings.rb +44 -0
  407. data/rspec-support/lib/rspec/support/spec/shell_out.rb +69 -0
  408. data/{vendor_lib → rspec-support/lib}/rspec/support/spec/stderr_splitter.rb +7 -5
  409. data/rspec-support/lib/rspec/support/spec/with_isolated_directory.rb +9 -0
  410. data/rspec-support/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  411. data/rspec-support/lib/rspec/support/spec.rb +72 -0
  412. data/{vendor_lib → rspec-support/lib}/rspec/support/version.rb +1 -1
  413. data/rspec-support/lib/rspec/support/version_checker.rb +53 -0
  414. data/rspec-support/lib/rspec/support/warnings.rb +39 -0
  415. data/rspec-support/lib/rspec/support.rb +76 -0
  416. data/rspec-support/spec/rspec/support/caller_filter_spec.rb +66 -0
  417. data/rspec-support/spec/rspec/support/differ_spec.rb +322 -0
  418. data/rspec-support/spec/rspec/support/directory_maker_spec.rb +58 -0
  419. data/rspec-support/spec/rspec/support/encoded_string_spec.rb +86 -0
  420. data/rspec-support/spec/rspec/support/fuzzy_matcher_spec.rb +179 -0
  421. data/rspec-support/spec/rspec/support/method_signature_verifier_spec.rb +357 -0
  422. data/rspec-support/spec/rspec/support/os_spec.rb +36 -0
  423. data/rspec-support/spec/rspec/support/recursive_const_methods_spec.rb +49 -0
  424. data/rspec-support/spec/rspec/support/spec/in_sub_process_spec.rb +36 -0
  425. data/rspec-support/spec/rspec/support/spec/prevent_load_time_warnings_spec.rb +10 -0
  426. data/rspec-support/spec/rspec/support/spec/shell_out_spec.rb +44 -0
  427. data/rspec-support/spec/rspec/support/spec/stderr_splitter_spec.rb +60 -0
  428. data/rspec-support/spec/rspec/support/spec/with_isolated_std_err_spec.rb +21 -0
  429. data/rspec-support/spec/rspec/support/version_checker_spec.rb +29 -0
  430. data/rspec-support/spec/rspec/support/warnings_spec.rb +66 -0
  431. data/rspec-support/spec/rspec/support_spec.rb +119 -0
  432. data/rspec-support/spec/spec_helper.rb +2 -0
  433. data/spec/after_hooks_spec.rb +140 -0
  434. data/spec/around_hooks_spec.rb +223 -0
  435. data/spec/async_spec.rb +147 -1
  436. data/spec/before_hooks_spec.rb +183 -0
  437. data/spec/example_spec.rb +11 -0
  438. data/spec/matchers_spec.rb +4 -0
  439. data/spec/skip_pending_spec.rb +43 -0
  440. data/spec/subject_spec.rb +87 -0
  441. data/util/create_requires.rb +45 -0
  442. metadata +443 -147
  443. data/spec/named_subject_spec.rb +0 -11
  444. data/vendor_lib/rspec/core/backtrace_formatter.rb +0 -65
  445. data/vendor_lib/rspec/core/command_line.rb +0 -36
  446. data/vendor_lib/rspec/core/configuration_options.rb +0 -143
  447. data/vendor_lib/rspec/core/drb_command_line.rb +0 -26
  448. data/vendor_lib/rspec/core/drb_options.rb +0 -87
  449. data/vendor_lib/rspec/core/dsl.rb +0 -26
  450. data/vendor_lib/rspec/core/example.rb +0 -312
  451. data/vendor_lib/rspec/core/example_group.rb +0 -540
  452. data/vendor_lib/rspec/core/filter_manager.rb +0 -224
  453. data/vendor_lib/rspec/core/formatters/base_formatter.rb +0 -291
  454. data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +0 -307
  455. data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +0 -67
  456. data/vendor_lib/rspec/core/formatters/json_formatter.rb +0 -99
  457. data/vendor_lib/rspec/core/formatters/progress_formatter.rb +0 -32
  458. data/vendor_lib/rspec/core/formatters.rb +0 -54
  459. data/vendor_lib/rspec/core/hooks.rb +0 -535
  460. data/vendor_lib/rspec/core/metadata.rb +0 -313
  461. data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  462. data/vendor_lib/rspec/core/mocking/with_flexmock.rb +0 -27
  463. data/vendor_lib/rspec/core/mocking/with_rr.rb +0 -27
  464. data/vendor_lib/rspec/core/mocking/with_rspec.rb +0 -27
  465. data/vendor_lib/rspec/core/pending.rb +0 -110
  466. data/vendor_lib/rspec/core/project_initializer.rb +0 -88
  467. data/vendor_lib/rspec/core/rake_task.rb +0 -128
  468. data/vendor_lib/rspec/core/reporter.rb +0 -132
  469. data/vendor_lib/rspec/core/runner.rb +0 -97
  470. data/vendor_lib/rspec/core/shared_example_group/collection.rb +0 -27
  471. data/vendor_lib/rspec/core/shared_example_group.rb +0 -146
  472. data/vendor_lib/rspec/core/version.rb +0 -7
  473. data/vendor_lib/rspec/core/warnings.rb +0 -22
  474. data/vendor_lib/rspec/expectations/differ.rb +0 -154
  475. data/vendor_lib/rspec/expectations/errors.rb +0 -9
  476. data/vendor_lib/rspec/expectations/expectation_target.rb +0 -87
  477. data/vendor_lib/rspec/expectations/extensions/object.rb +0 -29
  478. data/vendor_lib/rspec/expectations/extensions.rb +0 -1
  479. data/vendor_lib/rspec/expectations/fail_with.rb +0 -79
  480. data/vendor_lib/rspec/expectations/handler.rb +0 -68
  481. data/vendor_lib/rspec/expectations/syntax.rb +0 -182
  482. data/vendor_lib/rspec/expectations.rb +0 -75
  483. data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +0 -68
  484. data/vendor_lib/rspec/matchers/built_in/be.rb +0 -213
  485. data/vendor_lib/rspec/matchers/built_in/be_within.rb +0 -55
  486. data/vendor_lib/rspec/matchers/built_in/change.rb +0 -141
  487. data/vendor_lib/rspec/matchers/built_in/eq.rb +0 -22
  488. data/vendor_lib/rspec/matchers/built_in/equal.rb +0 -48
  489. data/vendor_lib/rspec/matchers/built_in/exist.rb +0 -26
  490. data/vendor_lib/rspec/matchers/built_in/has.rb +0 -48
  491. data/vendor_lib/rspec/matchers/built_in/include.rb +0 -61
  492. data/vendor_lib/rspec/matchers/built_in/match.rb +0 -17
  493. data/vendor_lib/rspec/matchers/built_in/match_array.rb +0 -51
  494. data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +0 -48
  495. data/vendor_lib/rspec/matchers/built_in/yield.rb +0 -297
  496. data/vendor_lib/rspec/matchers/built_in.rb +0 -39
  497. data/vendor_lib/rspec/matchers/compatibility.rb +0 -14
  498. data/vendor_lib/rspec/matchers/dsl.rb +0 -23
  499. data/vendor_lib/rspec/matchers/method_missing.rb +0 -12
  500. data/vendor_lib/rspec/matchers/operator_matcher.rb +0 -99
  501. data/vendor_lib/rspec/matchers/pretty.rb +0 -70
  502. data/vendor_lib/rspec/matchers/test_unit_integration.rb +0 -11
  503. data/vendor_lib/rspec/mocks/argument_list_matcher.rb +0 -104
  504. data/vendor_lib/rspec/mocks/argument_matchers.rb +0 -264
  505. data/vendor_lib/rspec/mocks/arity_calculator.rb +0 -66
  506. data/vendor_lib/rspec/mocks/errors.rb +0 -12
  507. data/vendor_lib/rspec/mocks/example_methods.rb +0 -201
  508. data/vendor_lib/rspec/mocks/extensions/marshal.rb +0 -17
  509. data/vendor_lib/rspec/mocks/framework.rb +0 -36
  510. data/vendor_lib/rspec/mocks/method_reference.rb +0 -95
  511. data/vendor_lib/rspec/mocks/mock.rb +0 -7
  512. data/vendor_lib/rspec/mocks/proxy.rb +0 -269
  513. data/vendor_lib/rspec/mocks/proxy_for_nil.rb +0 -37
  514. data/vendor_lib/rspec/mocks/space.rb +0 -95
  515. data/vendor_lib/rspec/mocks/standalone.rb +0 -3
  516. data/vendor_lib/rspec/mocks/stub_chain.rb +0 -51
  517. data/vendor_lib/rspec/mocks/syntax.rb +0 -374
  518. data/vendor_lib/rspec/mocks/test_double.rb +0 -109
  519. data/vendor_lib/rspec/mocks/version.rb +0 -7
  520. data/vendor_lib/rspec/mocks.rb +0 -100
  521. data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +0 -29
  522. data/vendor_lib/rspec/support/spec.rb +0 -14
  523. data/vendor_lib/rspec/support/warnings.rb +0 -41
  524. data/vendor_lib/rspec/support.rb +0 -6
  525. data/vendor_lib/rspec-expectations.rb +0 -1
@@ -1,65 +0,0 @@
1
- module RSpec
2
- module Core
3
- class BacktraceFormatter
4
- # This is only used externally by rspec-expectations. Can be removed once
5
- # rspec-expectations uses
6
- # RSpec.configuration.backtrace_formatter.format_backtrace instead.
7
- def self.format_backtrace(backtrace, options = {})
8
- RSpec.configuration.backtrace_formatter.format_backtrace(backtrace, options)
9
- end
10
-
11
- attr_accessor :exclusion_patterns, :inclusion_patterns
12
-
13
- def initialize
14
- @full_backtrace = false
15
- @exclusion_patterns = [] << Regexp.union(
16
- *["/lib\d*/ruby/",
17
- "org/jruby/",
18
- "bin/",
19
- "/gems/",
20
- "lib/rspec/(core|expectations|matchers|mocks)"].
21
- map {|s| Regexp.new(s.gsub("/", File::SEPARATOR))}
22
- )
23
- @inclusion_patterns = [Regexp.new(Dir.getwd)]
24
- end
25
-
26
- def full_backtrace=(full_backtrace)
27
- @full_backtrace = full_backtrace
28
- end
29
-
30
- def full_backtrace?
31
- @full_backtrace || @exclusion_patterns.empty?
32
- end
33
-
34
- def format_backtrace(backtrace, options = {})
35
- return backtrace if options[:full_backtrace]
36
- backtrace.
37
- take_while {|l| l != RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE}.
38
- map {|l| backtrace_line(l)}.
39
- compact.
40
- tap do |filtered|
41
- if filtered.empty?
42
- filtered.concat backtrace
43
- filtered << ""
44
- filtered << " Showing full backtrace because every line was filtered out."
45
- filtered << " See docs for RSpec::Configuration#backtrace_exclusion_patterns and"
46
- filtered << " RSpec::Configuration#backtrace_inclusion_patterns for more information."
47
- end
48
- end
49
- end
50
-
51
- # @api private
52
- def backtrace_line(line)
53
- RSpec::Core::Metadata::relative_path(line) unless exclude?(line)
54
- rescue SecurityError
55
- nil
56
- end
57
-
58
- # @api private
59
- def exclude?(line)
60
- return false if @full_backtrace
61
- @exclusion_patterns.any? {|p| p =~ line} && @inclusion_patterns.none? {|p| p =~ line}
62
- end
63
- end
64
- end
65
- end
@@ -1,36 +0,0 @@
1
- module RSpec
2
- module Core
3
- class CommandLine
4
- def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
5
- if Array === options
6
- options = ConfigurationOptions.new(options)
7
- options.parse_options
8
- end
9
- @options = options
10
- @configuration = configuration
11
- @world = world
12
- end
13
-
14
- # Configures and runs a suite
15
- #
16
- # @param [IO] err
17
- # @param [IO] out
18
- def run(err, out)
19
- @configuration.error_stream = err
20
- @configuration.output_stream = out if @configuration.output_stream == $stdout
21
- @options.configure(@configuration)
22
- @configuration.load_spec_files
23
- @world.announce_filters
24
-
25
- @configuration.reporter.report(@world.example_count) do |reporter|
26
- begin
27
- @configuration.run_hook(:before, :suite)
28
- @world.ordered_example_groups.map {|g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
29
- ensure
30
- @configuration.run_hook(:after, :suite)
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,143 +0,0 @@
1
- require 'erb'
2
- require 'shellwords'
3
-
4
- module RSpec
5
- module Core
6
- # @private
7
- class ConfigurationOptions
8
- attr_reader :options
9
-
10
- def initialize(args)
11
- @args = args.map {|a|
12
- a.sub("default_path", "default-path").sub("line_number", "line-number")
13
- }
14
- end
15
-
16
- def configure(config)
17
- config.filter_manager = filter_manager
18
-
19
- config.libs = options[:libs] || []
20
- config.setup_load_path_and_require(options[:requires] || [])
21
-
22
- process_options_into config
23
- load_formatters_into config
24
- end
25
-
26
- def parse_options
27
- @options = (file_options << command_line_options << env_options).
28
- each {|opts|
29
- filter_manager.include opts.delete(:inclusion_filter) if opts.has_key?(:inclusion_filter)
30
- filter_manager.exclude opts.delete(:exclusion_filter) if opts.has_key?(:exclusion_filter)
31
- }.
32
- inject {|h, opts|
33
- h.merge(opts) {|k, oldval, newval|
34
- [:libs, :requires].include?(k) ? oldval + newval : newval
35
- }
36
- }
37
- end
38
-
39
- def drb_argv
40
- DrbOptions.new(options, filter_manager).options
41
- end
42
-
43
- def filter_manager
44
- @filter_manager ||= RSpec::configuration.filter_manager
45
- end
46
-
47
- private
48
-
49
- UNFORCED_OPTIONS = [
50
- :requires, :profile, :drb, :libs, :files_or_directories_to_run,
51
- :line_numbers, :full_description, :full_backtrace, :tty
52
- ].to_set
53
-
54
- UNPROCESSABLE_OPTIONS = [:libs, :formatters, :requires].to_set
55
-
56
- def force?(key)
57
- !UNFORCED_OPTIONS.include?(key)
58
- end
59
-
60
- def order(keys, *ordered)
61
- ordered.reverse.each do |key|
62
- keys.unshift(key) if keys.delete(key)
63
- end
64
- keys
65
- end
66
-
67
- def process_options_into(config)
68
- opts = options.reject { |k, _| UNPROCESSABLE_OPTIONS.include? k }
69
-
70
- order(opts.keys, :default_path, :pattern).each do |key|
71
- force?(key) ? config.force(key => opts[key]) : config.send("#{key}=", opts[key])
72
- end
73
- end
74
-
75
- def load_formatters_into(config)
76
- options[:formatters].each { |pair| config.add_formatter(*pair) } if options[:formatters]
77
- end
78
-
79
- def file_options
80
- custom_options_file ? [custom_options] : [global_options, project_options, local_options]
81
- end
82
-
83
- def env_options
84
- ENV["SPEC_OPTS"] ? Parser.parse!(Shellwords.split(ENV["SPEC_OPTS"])) : {}
85
- end
86
-
87
- def command_line_options
88
- @command_line_options ||= Parser.parse!(@args).merge :files_or_directories_to_run => @args
89
- end
90
-
91
- def custom_options
92
- options_from(custom_options_file)
93
- end
94
-
95
- def local_options
96
- @local_options ||= options_from(local_options_file)
97
- end
98
-
99
- def project_options
100
- @project_options ||= options_from(project_options_file)
101
- end
102
-
103
- def global_options
104
- @global_options ||= options_from(global_options_file)
105
- end
106
-
107
- def options_from(path)
108
- Parser.parse(args_from_options_file(path))
109
- end
110
-
111
- def args_from_options_file(path)
112
- return [] unless path && File.exist?(path)
113
- config_string = options_file_as_erb_string(path)
114
- FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit)
115
- end
116
-
117
- def options_file_as_erb_string(path)
118
- ERB.new(File.read(path), nil, '-').result(binding)
119
- end
120
-
121
- def custom_options_file
122
- command_line_options[:custom_options_file]
123
- end
124
-
125
- def project_options_file
126
- ".rspec"
127
- end
128
-
129
- def local_options_file
130
- ".rspec-local"
131
- end
132
-
133
- def global_options_file
134
- begin
135
- File.join(File.expand_path("~"), ".rspec")
136
- rescue ArgumentError
137
- RSpec.warning "Unable to find ~/.rspec because the HOME environment variable is not set"
138
- nil
139
- end
140
- end
141
- end
142
- end
143
- end
@@ -1,26 +0,0 @@
1
- require 'drb/drb'
2
- require 'rspec/core/drb_options'
3
-
4
- module RSpec
5
- module Core
6
- class DRbCommandLine
7
- def initialize(options)
8
- @options = options
9
- end
10
-
11
- def drb_port
12
- @options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989
13
- end
14
-
15
- def run(err, out)
16
- begin
17
- DRb.start_service("druby://localhost:0")
18
- rescue SocketError, Errno::EADDRNOTAVAIL
19
- DRb.start_service("druby://:0")
20
- end
21
- spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}")
22
- spec_server.run(@options.drb_argv, err, out)
23
- end
24
- end
25
- end
26
- end
@@ -1,87 +0,0 @@
1
- # Builds command line arguments to pass to the rspec command over DRb
2
-
3
- module RSpec::Core
4
- # @private
5
- class DrbOptions
6
- def initialize(submitted_options, filter_manager)
7
- @submitted_options = submitted_options
8
- @filter_manager = filter_manager
9
- end
10
-
11
- def options
12
- argv = []
13
- argv << "--color" if @submitted_options[:color]
14
- argv << "--profile" if @submitted_options[:profile_examples]
15
- argv << "--backtrace" if @submitted_options[:full_backtrace]
16
- argv << "--tty" if @submitted_options[:tty]
17
- argv << "--fail-fast" if @submitted_options[:fail_fast]
18
- argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file]
19
- argv << "--order" << @submitted_options[:order] if @submitted_options[:order]
20
-
21
- add_failure_exit_code(argv)
22
- add_full_description(argv)
23
- add_line_numbers(argv)
24
- add_filter(argv, :inclusion, @filter_manager.inclusions)
25
- add_filter(argv, :exclusion, @filter_manager.exclusions)
26
- add_formatters(argv)
27
- add_libs(argv)
28
- add_requires(argv)
29
-
30
- argv + @submitted_options[:files_or_directories_to_run]
31
- end
32
-
33
- def add_failure_exit_code(argv)
34
- if @submitted_options[:failure_exit_code]
35
- argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s
36
- end
37
- end
38
-
39
- def add_full_description(argv)
40
- if @submitted_options[:full_description]
41
- # The argument to --example is regexp-escaped before being stuffed
42
- # into a regexp when received for the first time (see OptionParser).
43
- # Hence, merely grabbing the source of this regexp will retain the
44
- # backslashes, so we must remove them.
45
- @submitted_options[:full_description].each do |description|
46
- argv << "--example" << description.source.delete('\\')
47
- end
48
- end
49
- end
50
-
51
- def add_line_numbers(argv)
52
- if @submitted_options[:line_numbers]
53
- argv.push(*@submitted_options[:line_numbers].inject([]){|a,l| a << "--line_number" << l})
54
- end
55
- end
56
-
57
- CONDITIONAL_FILTERS = [:if, :unless]
58
-
59
- def add_filter(argv, name, hash)
60
- hash.each_pair do |k, v|
61
- next if CONDITIONAL_FILTERS.include?(k)
62
- tag = name == :inclusion ? k.to_s : "~#{k}"
63
- tag << ":#{v}" if v.is_a?(String)
64
- argv << "--tag" << tag
65
- end unless hash.empty?
66
- end
67
-
68
- def add_formatters(argv)
69
- @submitted_options[:formatters].each do |pair|
70
- argv << "--format" << pair[0]
71
- argv << "--out" << pair[1] if pair[1]
72
- end if @submitted_options[:formatters]
73
- end
74
-
75
- def add_libs(argv)
76
- @submitted_options[:libs].each do |path|
77
- argv << "-I" << path
78
- end if @submitted_options[:libs]
79
- end
80
-
81
- def add_requires(argv)
82
- @submitted_options[:requires].each do |path|
83
- argv << "--require" << path
84
- end if @submitted_options[:requires]
85
- end
86
- end
87
- end
@@ -1,26 +0,0 @@
1
- module RSpec
2
- module Core
3
- # Adds the `describe` method to the top-level namespace.
4
- module DSL
5
- # Generates a subclass of {ExampleGroup}
6
- #
7
- # ## Examples:
8
- #
9
- # describe "something" do
10
- # it "does something" do
11
- # # example code goes here
12
- # end
13
- # end
14
- #
15
- # @see ExampleGroup
16
- # @see ExampleGroup.describe
17
- def describe(*args, &example_group_block)
18
- RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register
19
- end
20
- end
21
- end
22
- end
23
-
24
- extend RSpec::Core::DSL
25
- Module.send(:include, RSpec::Core::DSL)
26
-
@@ -1,312 +0,0 @@
1
- module RSpec
2
- module Core
3
- # Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
4
- # `Example` is returned by the {ExampleGroup#example example} method
5
- # exposed to examples, {Hooks#before before} and {Hooks#after after} hooks,
6
- # and yielded to {Hooks#around around} hooks.
7
- #
8
- # Useful for configuring logging and/or taking some action based
9
- # on the state of an example's metadata.
10
- #
11
- # @example
12
- #
13
- # RSpec.configure do |config|
14
- # config.before do
15
- # log example.description
16
- # end
17
- #
18
- # config.after do
19
- # log example.description
20
- # end
21
- #
22
- # config.around do |ex|
23
- # log example.description
24
- # ex.run
25
- # end
26
- # end
27
- #
28
- # shared_examples "auditable" do
29
- # it "does something" do
30
- # log "#{example.full_description}: #{auditable.inspect}"
31
- # auditable.should do_something
32
- # end
33
- # end
34
- #
35
- # @see ExampleGroup
36
- class Example
37
- # @private
38
- #
39
- # Used to define methods that delegate to this example's metadata
40
- def self.delegate_to_metadata(*keys)
41
- keys.each { |key| define_method(key) { @metadata[key] } }
42
- end
43
-
44
- delegate_to_metadata :full_description, :execution_result, :file_path, :pending, :location
45
-
46
- # Returns the string submitted to `example` or its aliases (e.g.
47
- # `specify`, `it`, etc). If no string is submitted (e.g. `it { should
48
- # do_something }`) it returns the message generated by the matcher if
49
- # there is one, otherwise returns a message including the location of the
50
- # example.
51
- def description
52
- description = metadata[:description].to_s.empty? ? "example at #{location}" : metadata[:description]
53
- RSpec.configuration.format_docstrings_block.call(description)
54
- end
55
-
56
- # @attr_reader
57
- #
58
- # Returns the first exception raised in the context of running this
59
- # example (nil if no exception is raised)
60
- attr_reader :exception
61
-
62
- # @attr_reader
63
- #
64
- # Returns the metadata object associated with this example.
65
- attr_reader :metadata
66
-
67
- # @attr_reader
68
- # @private
69
- #
70
- # Returns the example_group_instance that provides the context for
71
- # running this example.
72
- attr_reader :example_group_instance
73
-
74
- # Creates a new instance of Example.
75
- # @param example_group_class the subclass of ExampleGroup in which this Example is declared
76
- # @param description the String passed to the `it` method (or alias)
77
- # @param metadata additional args passed to `it` to be used as metadata
78
- # @param example_block the block of code that represents the example
79
- def initialize(example_group_class, description, metadata, example_block=nil)
80
- @example_group_class, @options, @example_block = example_group_class, metadata, example_block
81
- @metadata = @example_group_class.metadata.for_example(description, metadata)
82
- @example_group_instance = @exception = nil
83
- @pending_declared_in_example = false
84
- end
85
-
86
- # @deprecated access options via metadata instead
87
- def options
88
- @options
89
- end
90
-
91
- # Returns the example group class that provides the context for running
92
- # this example.
93
- def example_group
94
- @example_group_class
95
- end
96
-
97
- alias_method :pending?, :pending
98
-
99
- # @api private
100
- # instance_evals the block passed to the constructor in the context of
101
- # the instance of {ExampleGroup}.
102
- # @param example_group_instance the instance of an ExampleGroup subclass
103
- def run(example_group_instance, reporter)
104
- @example_group_instance = example_group_instance
105
- RSpec.current_example = self
106
-
107
- start(reporter)
108
-
109
- begin
110
- unless pending || RSpec.configuration.dry_run?
111
- with_around_each_hooks do
112
- begin
113
- run_before_each
114
- @example_group_instance.instance_exec(self, &@example_block)
115
- rescue Pending::PendingDeclaredInExample => e
116
- @pending_declared_in_example = e.message
117
- rescue Exception => e
118
- set_exception(e)
119
- ensure
120
- run_after_each
121
- end
122
- end
123
- end
124
- rescue Exception => e
125
- set_exception(e)
126
- ensure
127
- @example_group_instance.instance_variables.each do |ivar|
128
- @example_group_instance.instance_variable_set(ivar, nil)
129
- end
130
- @example_group_instance = nil
131
-
132
- begin
133
- assign_generated_description
134
- rescue Exception => e
135
- set_exception(e, "while assigning the example description")
136
- end
137
- end
138
-
139
- finish(reporter)
140
- ensure
141
- RSpec.current_example = nil
142
- end
143
-
144
- # Wraps a `Proc` and exposes a `run` method for use in {Hooks#around
145
- # around} hooks.
146
- #
147
- # @note Procsy, itself, is not a public API, but we're documenting it
148
- # here to document how to interact with the object yielded to an
149
- # `around` hook.
150
- #
151
- # @example
152
- #
153
- # RSpec.configure do |c|
154
- # c.around do |ex| # Procsy which wraps the example
155
- # if ex.metadata[:key] == :some_value && some_global_condition
156
- # raise "some message"
157
- # end
158
- # ex.run # run delegates to ex.call
159
- # end
160
- # end
161
- class Procsy
162
- # The `metadata` of the {Example} instance.
163
- attr_reader :metadata
164
-
165
- Proc.public_instance_methods(false).each do |name|
166
- define_method(name) { |*a, &b| @proc.__send__(name, *a, &b) }
167
- end
168
- alias run call
169
-
170
- def initialize(metadata, &block)
171
- @metadata = metadata
172
- @proc = block
173
- end
174
-
175
- # @api private
176
- def wrap(&block)
177
- self.class.new(metadata, &block)
178
- end
179
- end
180
-
181
- # @private
182
- def any_apply?(filters)
183
- metadata.any_apply?(filters)
184
- end
185
-
186
- # @private
187
- def all_apply?(filters)
188
- @metadata.all_apply?(filters) || @example_group_class.all_apply?(filters)
189
- end
190
-
191
- # @private
192
- def around_each_hooks
193
- @around_each_hooks ||= example_group.around_each_hooks_for(self)
194
- end
195
-
196
- # @private
197
- #
198
- # Used internally to set an exception in an after hook, which
199
- # captures the exception but doesn't raise it.
200
- def set_exception(exception, context=nil)
201
- if @exception && context != :dont_print
202
- # An error has already been set; we don't want to override it,
203
- # but we also don't want silence the error, so let's print it.
204
- msg = <<-EOS
205
-
206
- An error occurred #{context}
207
- #{exception.class}: #{exception.message}
208
- occurred at #{exception.backtrace.first}
209
-
210
- EOS
211
- RSpec.configuration.reporter.message(msg)
212
- end
213
-
214
- @exception ||= exception
215
- end
216
-
217
- # @private
218
- #
219
- # Used internally to set an exception and fail without actually executing
220
- # the example when an exception is raised in before(:all).
221
- def fail_with_exception(reporter, exception)
222
- start(reporter)
223
- set_exception(exception)
224
- finish(reporter)
225
- end
226
-
227
- # @private
228
- def instance_exec_with_rescue(context = nil, &block)
229
- @example_group_instance.instance_exec_with_rescue(self, context, &block)
230
- end
231
-
232
- # @private
233
- def instance_exec(*args, &block)
234
- @example_group_instance.instance_exec(*args, &block)
235
- end
236
-
237
- private
238
-
239
- def with_around_each_hooks(&block)
240
- if around_each_hooks.empty?
241
- yield
242
- else
243
- @example_group_class.run_around_each_hooks(self, Procsy.new(metadata, &block))
244
- end
245
- rescue Exception => e
246
- set_exception(e, "in an around(:each) hook")
247
- end
248
-
249
- def start(reporter)
250
- reporter.example_started(self)
251
- record :started_at => RSpec::Core::Time.now
252
- end
253
-
254
- def finish(reporter)
255
- if @exception
256
- record_finished 'failed', :exception => @exception
257
- reporter.example_failed self
258
- false
259
- elsif @pending_declared_in_example
260
- record_finished 'pending', :pending_message => @pending_declared_in_example
261
- reporter.example_pending self
262
- true
263
- elsif pending
264
- record_finished 'pending', :pending_message => String === pending ? pending : Pending::NO_REASON_GIVEN
265
- reporter.example_pending self
266
- true
267
- else
268
- record_finished 'passed'
269
- reporter.example_passed self
270
- true
271
- end
272
- end
273
-
274
- def record_finished(status, results={})
275
- finished_at = RSpec::Core::Time.now
276
- record results.merge(:status => status, :finished_at => finished_at, :run_time => (finished_at - execution_result[:started_at]).to_f)
277
- end
278
-
279
- def run_before_each
280
- @example_group_instance.setup_mocks_for_rspec
281
- @example_group_class.run_before_each_hooks(self)
282
- end
283
-
284
- def run_after_each
285
- @example_group_class.run_after_each_hooks(self)
286
- verify_mocks
287
- rescue Exception => e
288
- set_exception(e, "in an after(:each) hook")
289
- ensure
290
- @example_group_instance.teardown_mocks_for_rspec
291
- end
292
-
293
- def verify_mocks
294
- @example_group_instance.verify_mocks_for_rspec
295
- rescue Exception => e
296
- set_exception(e, :dont_print)
297
- end
298
-
299
- def assign_generated_description
300
- return unless RSpec.configuration.expecting_with_rspec?
301
- if metadata[:description_args].empty? and !pending?
302
- metadata[:description_args] << RSpec::Matchers.generated_description
303
- end
304
- RSpec::Matchers.clear_generated_description
305
- end
306
-
307
- def record(results={})
308
- execution_result.update(results)
309
- end
310
- end
311
- end
312
- end