opal-rspec 0.5.0.beta2 → 0.5.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +23 -4
  4. data/CHANGELOG.md +22 -1
  5. data/Gemfile +10 -3
  6. data/README.md +142 -36
  7. data/Rakefile +101 -75
  8. data/config.ru +8 -6
  9. data/gemfiles/opal_master.gemfile +18 -0
  10. data/lib/opal/rspec.rb +6 -10
  11. data/lib/opal/rspec/cached_environment.rb +23 -0
  12. data/lib/opal/rspec/post_rack_locator.rb +20 -0
  13. data/lib/opal/rspec/pre_rack_locator.rb +68 -0
  14. data/lib/opal/rspec/rake_task.rb +97 -20
  15. data/lib/opal/rspec/sprockets_environment.rb +35 -0
  16. data/lib/opal/rspec/version.rb +1 -1
  17. data/opal-rspec.gemspec +9 -12
  18. data/opal/opal/rspec.rb +11 -8
  19. data/opal/opal/rspec/async.rb +1 -0
  20. data/opal/opal/rspec/async/async_example.rb +27 -18
  21. data/opal/opal/rspec/async/example_group.rb +23 -21
  22. data/opal/opal/rspec/async/hooks.rb +0 -36
  23. data/opal/opal/rspec/async/reporter.rb +9 -0
  24. data/opal/opal/rspec/fixes.rb +3 -10
  25. data/opal/opal/rspec/fixes/opal.rb +5 -0
  26. data/opal/opal/rspec/fixes/opal/class.rb +8 -0
  27. data/opal/opal/rspec/fixes/opal/compatibility.rb +228 -0
  28. data/opal/opal/rspec/fixes/opal/corelib.rb +3 -0
  29. data/opal/opal/rspec/fixes/opal/corelib/error.rb +61 -0
  30. data/opal/opal/rspec/fixes/opal/corelib/regexp.rb +92 -0
  31. data/opal/opal/rspec/fixes/opal/corelib/struct.rb +260 -0
  32. data/opal/opal/rspec/fixes/opal/kernel.rb +80 -0
  33. data/opal/opal/rspec/fixes/opal/stdlib.rb +2 -0
  34. data/opal/opal/rspec/fixes/opal/stdlib/pp.rb +23 -0
  35. data/opal/opal/rspec/fixes/opal/stdlib/set.rb +36 -0
  36. data/opal/opal/rspec/fixes/rspec.rb +7 -0
  37. data/opal/opal/rspec/fixes/{caller_filter.rb → rspec/caller_filter.rb} +0 -0
  38. data/opal/opal/rspec/fixes/rspec/core.rb +9 -0
  39. data/opal/opal/rspec/fixes/rspec/core/configuration.rb +11 -0
  40. data/opal/opal/rspec/fixes/{example.rb → rspec/core/example.rb} +1 -1
  41. data/opal/opal/rspec/fixes/rspec/core/example_group.rb +9 -0
  42. data/opal/opal/rspec/fixes/rspec/core/formatters.rb +6 -0
  43. data/opal/opal/rspec/fixes/rspec/core/formatters/backtrace_formatter.rb +20 -0
  44. data/opal/opal/rspec/fixes/rspec/core/formatters/console_codes.rb +11 -0
  45. data/opal/opal/rspec/fixes/rspec/core/formatters/deprecation_formatter.rb +20 -0
  46. data/opal/opal/rspec/fixes/rspec/core/formatters/generated_deprecation_message.rb +15 -0
  47. data/opal/opal/rspec/fixes/rspec/core/formatters/json_formatter.rb +10 -0
  48. data/opal/opal/rspec/fixes/rspec/core/formatters/loader.rb +38 -0
  49. data/opal/opal/rspec/fixes/rspec/core/metadata.rb +39 -0
  50. data/opal/opal/rspec/fixes/rspec/core/notifications.rb +3 -0
  51. data/opal/opal/rspec/fixes/rspec/core/notifications/examples_notification.rb +30 -0
  52. data/opal/opal/rspec/fixes/rspec/core/notifications/failed_example_notification.rb +20 -0
  53. data/opal/opal/rspec/fixes/rspec/core/notifications/summary_notification.rb +26 -0
  54. data/opal/opal/rspec/fixes/rspec/core/ordering.rb +1 -0
  55. data/opal/opal/rspec/fixes/rspec/core/ordering/random.rb +13 -0
  56. data/opal/opal/rspec/fixes/rspec/core/reporter.rb +14 -0
  57. data/opal/opal/rspec/fixes/rspec/core/warnings.rb +18 -0
  58. data/opal/opal/rspec/fixes/rspec/example_groups.rb +49 -0
  59. data/opal/opal/rspec/fixes/rspec/expectations.rb +2 -0
  60. data/opal/opal/rspec/fixes/{expectations.rb → rspec/expectations/fail_with.rb} +0 -0
  61. data/opal/opal/rspec/fixes/rspec/expectations/syntax.rb +25 -0
  62. data/opal/opal/rspec/fixes/rspec/matchers.rb +2 -0
  63. data/opal/opal/rspec/fixes/rspec/matchers/built_in.rb +4 -0
  64. data/opal/opal/rspec/fixes/rspec/matchers/built_in/all.rb +10 -0
  65. data/opal/opal/rspec/fixes/rspec/matchers/built_in/compound.rb +15 -0
  66. data/opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb +42 -0
  67. data/opal/opal/rspec/fixes/rspec/matchers/built_in/yield.rb +21 -0
  68. data/opal/opal/rspec/fixes/{matchers.rb → rspec/matchers/pretty.rb} +0 -0
  69. data/opal/opal/rspec/fixes/rspec/mocks.rb +4 -0
  70. data/opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +40 -0
  71. data/opal/opal/rspec/fixes/rspec/mocks/space.rb +37 -0
  72. data/opal/opal/rspec/fixes/rspec/mocks/test_double.rb +39 -0
  73. data/opal/opal/rspec/fixes/rspec/mocks/verifying_double.rb +29 -0
  74. data/opal/opal/rspec/fixes/rspec/support.rb +4 -0
  75. data/opal/opal/rspec/fixes/rspec/support/encoded_string.rb +10 -0
  76. data/opal/opal/rspec/fixes/rspec/support/fuzzy_matcher.rb +23 -0
  77. data/opal/opal/rspec/fixes/rspec/support/recursive_const_methods.rb +7 -0
  78. data/opal/opal/rspec/fixes/rspec/support/ruby_features.rb +8 -0
  79. data/opal/opal/rspec/fixes/rspec/support/warnings.rb +18 -0
  80. data/opal/opal/rspec/formatter/browser_formatter.rb +38 -0
  81. data/opal/opal/rspec/formatter/document_io.rb +27 -0
  82. data/opal/opal/rspec/formatter/element.rb +88 -0
  83. data/opal/opal/rspec/formatter/html_printer.rb +109 -0
  84. data/opal/opal/rspec/formatter/noop_flush_string_io.rb +9 -0
  85. data/opal/opal/rspec/formatter/opal_closed_tty_io.rb +27 -0
  86. data/opal/opal/rspec/pre_require_fixes.rb +7 -0
  87. data/opal/opal/rspec/requires.rb +32 -0
  88. data/opal/opal/rspec/runner.rb +71 -53
  89. data/opal/opal/rspec/spec_opts.rb.erb +28 -0
  90. data/opal/opal/rspec/sprockets_runner.rb.erb +5 -3
  91. data/spec/mri/integration/browser_spec.rb +31 -0
  92. data/spec/mri/integration/rack/sprockets_runner_js_errors.rb.erb +20 -0
  93. data/spec/mri/integration/spec_opts_spec.rb +81 -0
  94. data/spec/mri/unit/opal/rspec/browser_formatter_spec.rb +35 -0
  95. data/spec/mri/unit/opal/rspec/cached_environment_spec.rb +103 -0
  96. data/spec/mri/unit/opal/rspec/opal/browser_formatter_spec.rb +14 -0
  97. data/spec/mri/unit/opal/rspec/rack/config.ru +12 -0
  98. data/spec/mri/unit/opal/rspec/rake_task_spec.rb +245 -0
  99. data/spec/mri/unit/opal/rspec/sprockets_environment_spec.rb +94 -0
  100. data/spec/mri/unit/opal/rspec/temp_dir_helper.rb +19 -0
  101. data/spec/{after_hooks_spec.rb → opal/after_hooks_spec.rb} +0 -0
  102. data/spec/{around_hooks_spec.rb → opal/around_hooks_spec.rb} +46 -105
  103. data/spec/{async_spec.rb → opal/async_spec.rb} +0 -0
  104. data/spec/{before_hooks_spec.rb → opal/before_hooks_spec.rb} +0 -0
  105. data/spec/{example_spec.rb → opal/example_spec.rb} +0 -0
  106. data/spec/opal/expected_failures.txt +40 -0
  107. data/spec/{matchers_spec.rb → opal/matchers_spec.rb} +0 -0
  108. data/spec/{mock_spec.rb → opal/mock_spec.rb} +0 -0
  109. data/spec/{should_syntax_spec.rb → opal/should_syntax_spec.rb} +0 -0
  110. data/spec/{skip_pending_spec.rb → opal/skip_pending_spec.rb} +0 -0
  111. data/spec/{subject_spec.rb → opal/subject_spec.rb} +16 -16
  112. data/spec/other/color_on_by_default_spec.rb +9 -0
  113. data/spec/other/dummy_spec.rb +5 -0
  114. data/spec/other/formatter_dependency.rb +3 -0
  115. data/spec/other/ignored_spec.opal +5 -0
  116. data/spec/other/test_formatter.rb +9 -0
  117. data/spec/rspec/core/config.rb +5 -0
  118. data/spec/rspec/core/config.ru +4 -0
  119. data/spec/rspec/core/core_spec_loader.rb +42 -0
  120. data/spec/rspec/core/filter/core/async/example_group.txt +13 -0
  121. data/spec/rspec/core/filter/core/async/hooks.rb +12 -0
  122. data/spec/rspec/core/filter/core/async/memoized_helpers.txt +3 -0
  123. data/spec/rspec/core/filter/core/async/metadata.txt +2 -0
  124. data/spec/rspec/core/filter/core/bugs/filter_manager.txt +4 -0
  125. data/spec/rspec/core/filter/core/bugs/formatters.txt +4 -0
  126. data/spec/rspec/core/filter/core/bugs/memoized_helpers.rb +11 -0
  127. data/spec/rspec/core/filter/core/bugs/metadata.txt +5 -0
  128. data/spec/rspec/core/filter/core/bugs/sandbox/subject_issue_test.rb +328 -0
  129. data/spec/rspec/core/filter/core/bugs/warnings_deprecations.txt +3 -0
  130. data/spec/rspec/core/filter/core/unsupported/core.txt +5 -0
  131. data/spec/rspec/core/filter/core/unsupported/example.txt +7 -0
  132. data/spec/rspec/core/filter/core/unsupported/example_group.txt +13 -0
  133. data/spec/rspec/core/filter/core/unsupported/filter_manager.txt +7 -0
  134. data/spec/rspec/core/filter/core/unsupported/formatters.txt +27 -0
  135. data/spec/rspec/core/filter/core/unsupported/hooks.txt +2 -0
  136. data/spec/rspec/core/filter/core/unsupported/memoized_helpers.txt +6 -0
  137. data/spec/rspec/core/filter/core/unsupported/metadata.txt +14 -0
  138. data/spec/rspec/core/filter/core/unsupported/metadata_filter.txt +2 -0
  139. data/spec/rspec/core/filter/core/unsupported/notifications.txt +8 -0
  140. data/spec/rspec/core/filter/core/unsupported/world.txt +3 -0
  141. data/spec/rspec/core/fixes/missing_constants.rb +20 -0
  142. data/spec/rspec/core/fixes/opal_itself.rb +38 -0
  143. data/spec/rspec/core/fixes/shared_examples.rb +3 -0
  144. data/spec/rspec/core/opal_alternates/rspec/core/example_group_spec.rb +145 -0
  145. data/spec/rspec/core/opal_alternates/rspec/core/failed_example_notification_spec.rb +31 -0
  146. data/spec/rspec/core/opal_alternates/rspec/core/hooks_spec.rb +113 -0
  147. data/spec/rspec/core/opal_alternates/rspec/core/memoized_helpers_spec.rb +36 -0
  148. data/spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb +48 -0
  149. data/spec/rspec/core/require_specs.rb +25 -0
  150. data/spec/rspec/core/sandboxing.rb +72 -0
  151. data/spec/rspec/core/spec_files_exclude.txt +41 -0
  152. data/spec/rspec/expectations/config.rb +16 -0
  153. data/spec/rspec/expectations/config.ru +4 -0
  154. data/spec/rspec/expectations/expectation_spec_loader.rb +106 -0
  155. data/spec/rspec/expectations/filter/bugs/aliased_matcher.txt +2 -0
  156. data/spec/rspec/expectations/filter/bugs/aliases.rb +13 -0
  157. data/spec/rspec/expectations/filter/bugs/base_matcher.txt +2 -0
  158. data/spec/rspec/expectations/filter/bugs/be.rb +4 -0
  159. data/spec/rspec/expectations/filter/bugs/be_instance_of.rb +7 -0
  160. data/spec/rspec/expectations/filter/bugs/be_spec.txt +2 -0
  161. data/spec/rspec/expectations/filter/bugs/configuration.txt +8 -0
  162. data/spec/rspec/expectations/filter/bugs/contain_exactly.rb +13 -0
  163. data/spec/rspec/expectations/filter/bugs/define_negated_matcher.rb +9 -0
  164. data/spec/rspec/expectations/filter/bugs/description_generation.rb +4 -0
  165. data/spec/rspec/expectations/filter/bugs/dsl.txt +14 -0
  166. data/spec/rspec/expectations/filter/bugs/equal.txt +3 -0
  167. data/spec/rspec/expectations/filter/bugs/expectation_target.txt +2 -0
  168. data/spec/rspec/expectations/filter/bugs/expectations.txt +2 -0
  169. data/spec/rspec/expectations/filter/bugs/have_attributes.rb +8 -0
  170. data/spec/rspec/expectations/filter/bugs/include.rb +4 -0
  171. data/spec/rspec/expectations/filter/bugs/operators.txt +2 -0
  172. data/spec/rspec/expectations/filter/bugs/raise_error.txt +2 -0
  173. data/spec/rspec/expectations/filter/bugs/respond_to.rb +13 -0
  174. data/spec/rspec/expectations/filter/bugs/sandbox/undef.rb +20 -0
  175. data/spec/rspec/expectations/filter/unsupported/aliases.txt +5 -0
  176. data/spec/rspec/expectations/filter/unsupported/be.txt +2 -0
  177. data/spec/rspec/expectations/filter/unsupported/be_instance_of.txt +3 -0
  178. data/spec/rspec/expectations/filter/unsupported/change.txt +2 -0
  179. data/spec/rspec/expectations/filter/unsupported/configuration.txt +2 -0
  180. data/spec/rspec/expectations/filter/unsupported/contain_exactly.txt +2 -0
  181. data/spec/rspec/expectations/filter/unsupported/description_generation.txt +6 -0
  182. data/spec/rspec/expectations/filter/unsupported/dsl.txt +8 -0
  183. data/spec/rspec/expectations/filter/unsupported/eq.txt +10 -0
  184. data/spec/rspec/expectations/filter/unsupported/equal.txt +3 -0
  185. data/spec/rspec/expectations/filter/unsupported/expectation_target.txt +2 -0
  186. data/spec/rspec/expectations/filter/unsupported/expectations.txt +8 -0
  187. data/spec/rspec/expectations/filter/unsupported/has.txt +2 -0
  188. data/spec/rspec/expectations/filter/unsupported/include.txt +3 -0
  189. data/spec/rspec/expectations/filter/unsupported/match.txt +2 -0
  190. data/spec/rspec/expectations/filter/unsupported/matchers.txt +11 -0
  191. data/spec/rspec/expectations/filter/unsupported/output.txt +14 -0
  192. data/spec/rspec/expectations/filter/unsupported/raise_error.txt +3 -0
  193. data/spec/rspec/expectations/filter/unsupported/respond_to.rb +5 -0
  194. data/spec/rspec/expectations/filter/unsupported/syntax.txt +3 -0
  195. data/spec/rspec/expectations/filter/unsupported/yield.txt +2 -0
  196. data/spec/rspec/expectations/fixes/example_patches.rb +32 -0
  197. data/spec/rspec/expectations/fixes/missing_constants.rb +12 -0
  198. data/spec/rspec/expectations/fixes/not_compatible.rb +6 -0
  199. data/spec/rspec/expectations/fixes/opal_itself.rb +140 -0
  200. data/spec/rspec/expectations/opal_alternates/be_instance_of_spec.rb +11 -0
  201. data/spec/rspec/expectations/opal_alternates/dsl_spec.rb +66 -0
  202. data/spec/rspec/expectations/opal_alternates/expectation_target_spec.rb +21 -0
  203. data/spec/rspec/expectations/opal_alternates/yield_spec.rb +11 -0
  204. data/spec/rspec/expectations/require_specs.rb +16 -0
  205. data/spec/rspec/expectations/shared_examples.rb +47 -0
  206. data/spec/rspec/expectations/spec_files_exclude.txt +2 -0
  207. data/spec/rspec/expectations/spec_helper_opal.rb +13 -0
  208. data/spec/rspec/filter_processor.rb +77 -0
  209. data/spec/rspec/mocks/config.ru +4 -0
  210. data/spec/rspec/mocks/filter/bugs/and_call_original.txt +9 -0
  211. data/spec/rspec/mocks/filter/bugs/and_wrap_original.txt +2 -0
  212. data/spec/rspec/mocks/filter/bugs/any_instance.rb +24 -0
  213. data/spec/rspec/mocks/filter/bugs/argument_matchers.rb +3 -0
  214. data/spec/rspec/mocks/filter/bugs/configuration.txt +2 -0
  215. data/spec/rspec/mocks/filter/bugs/double.txt +3 -0
  216. data/spec/rspec/mocks/filter/bugs/expiration.txt +2 -0
  217. data/spec/rspec/mocks/filter/bugs/instance_method_stasher.txt +2 -0
  218. data/spec/rspec/mocks/filter/bugs/methods.rb +5 -0
  219. data/spec/rspec/mocks/filter/bugs/mocks.txt +6 -0
  220. data/spec/rspec/mocks/filter/bugs/mutate_const.txt +2 -0
  221. data/spec/rspec/mocks/filter/bugs/partial_double.rb +8 -0
  222. data/spec/rspec/mocks/filter/bugs/receive.txt +5 -0
  223. data/spec/rspec/mocks/filter/bugs/should_syntax.txt +5 -0
  224. data/spec/rspec/mocks/filter/bugs/space.txt +2 -0
  225. data/spec/rspec/mocks/filter/bugs/spy.txt +5 -0
  226. data/spec/rspec/mocks/filter/bugs/stub_implementation.rb +9 -0
  227. data/spec/rspec/mocks/filter/unsupported/and_call_original.txt +5 -0
  228. data/spec/rspec/mocks/filter/unsupported/and_return.txt +2 -0
  229. data/spec/rspec/mocks/filter/unsupported/any_instance.rb +6 -0
  230. data/spec/rspec/mocks/filter/unsupported/argument_matchers.rb +10 -0
  231. data/spec/rspec/mocks/filter/unsupported/combining_implementation_instructions.rb +9 -0
  232. data/spec/rspec/mocks/filter/unsupported/double.rb +16 -0
  233. data/spec/rspec/mocks/filter/unsupported/expected_arg_verification.txt +2 -0
  234. data/spec/rspec/mocks/filter/unsupported/have_received.txt +2 -0
  235. data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.txt +8 -0
  236. data/spec/rspec/mocks/filter/unsupported/mocks.rb +8 -0
  237. data/spec/rspec/mocks/filter/unsupported/nil_expectation_warning.rb +8 -0
  238. data/spec/rspec/mocks/filter/unsupported/partial_double.rb +6 -0
  239. data/spec/rspec/mocks/filter/unsupported/receive.txt +13 -0
  240. data/spec/rspec/mocks/filter/unsupported/receive_message_chain.rb +4 -0
  241. data/spec/rspec/mocks/filter/unsupported/receive_messages.txt +2 -0
  242. data/spec/rspec/mocks/filter/unsupported/should_syntax.txt +1 -0
  243. data/spec/rspec/mocks/filter/unsupported/space.rb +7 -0
  244. data/spec/rspec/mocks/filter/unsupported/stub.rb +7 -0
  245. data/spec/rspec/mocks/fixes/doubled_classes.rb +76 -0
  246. data/spec/rspec/mocks/fixes/missing_constants.rb +3 -0
  247. data/spec/rspec/mocks/fixes/opal_itself.rb +59 -0
  248. data/spec/rspec/mocks/mocks_spec_loader.rb +87 -0
  249. data/spec/rspec/mocks/require_specs.rb +15 -0
  250. data/spec/rspec/mocks/spec_files_exclude.txt +11 -0
  251. data/spec/rspec/mocks/spec_helper_opal.rb +129 -0
  252. data/spec/rspec/opal_rspec_spec_loader.rb +349 -0
  253. data/spec/rspec/shared/opal/fixes/deprecation_helpers.rb +31 -0
  254. data/spec/rspec/shared/opal/fixes/rspec_helpers.rb +6 -0
  255. data/spec/rspec/shared/opal/progress_json_formatter.rb +29 -0
  256. data/spec/rspec/support/config.rb +5 -0
  257. data/spec/rspec/support/config.ru +4 -0
  258. data/spec/rspec/support/filter/bugs/recursive_const_methods.txt +3 -0
  259. data/spec/rspec/support/filter/bugs/sandbox/basic_object.rb +30 -0
  260. data/spec/rspec/support/filter/bugs/stderr_splitter_spec.txt +2 -0
  261. data/spec/rspec/support/filter/bugs/support.txt +2 -0
  262. data/spec/rspec/support/filter/unsupported/fuzzy_matcher.txt +2 -0
  263. data/spec/rspec/support/filter/unsupported/support.rb +7 -0
  264. data/spec/rspec/support/filter/unsupported/warnings.txt +6 -0
  265. data/spec/rspec/support/fixes/missing_constants.rb +3 -0
  266. data/spec/rspec/support/fixes/opal_itself.rb +13 -0
  267. data/spec/rspec/support/require_specs.rb +15 -0
  268. data/spec/rspec/support/spec_files_exclude.txt +26 -0
  269. data/spec/rspec/support/spec_helper.rb +27 -0
  270. data/spec/rspec/support/support_spec_loader.rb +34 -0
  271. data/util/create_requires.rb +6 -2
  272. data/vendor/spec_runner.js +14 -0
  273. metadata +255 -43
  274. data/opal/opal/rspec/browser_formatter.rb +0 -225
  275. data/opal/opal/rspec/fixes/example_groups.rb +0 -32
  276. data/opal/opal/rspec/fixes/formatter.rb +0 -62
  277. data/opal/opal/rspec/fixes/kernel.rb +0 -48
  278. data/opal/opal/rspec/fixes/mocks.rb +0 -13
  279. data/opal/opal/rspec/fixes/reporter.rb +0 -12
  280. data/opal/opal/rspec/text_formatter.rb +0 -88
  281. data/spec_mri/integration/browser_spec.rb +0 -37
@@ -0,0 +1,3 @@
1
+ # https://github.com/opal/opal/issues/568 - long standing issue that hasn't been fixed
2
+ rspec warnings and deprecations #warn_with when :use_spec_location_as_call_site => true is passed adds the source location of spec
3
+ rspec warnings and deprecations #warn_with when :use_spec_location_as_call_site => true is passed appends a period to the supplied message if one is not present
@@ -0,0 +1,5 @@
1
+ # Launches a new Ruby process
2
+ RSpec loads mocks and expectations when the constants are referenced
3
+
4
+ # Can't do file paths in Opal
5
+ RSpec::Core.path_to_executable.*
@@ -0,0 +1,7 @@
1
+ # location/line number
2
+ RSpec::Core::Example when there is no explicit description.*using the block
3
+ RSpec::Core::Example when there is no explicit description.*uses the file and line number.*
4
+ RSpec::Core::Example#pending in the example sets the backtrace to the example definition so it can be located by the user
5
+
6
+ # set_backtrace not supported on Opal
7
+ RSpec::Core::Example#run when the example raises an error leaves a raised exception unmodified.*
@@ -0,0 +1,13 @@
1
+ # There is a carve out for Rubinius, but not for Opal, see opal alternates
2
+ RSpec::Core::ExampleGroup constant naming disambiguates name collisions by appending a number
3
+
4
+ # location, file path, line number
5
+ RSpec::Core::ExampleGroup ordering when tagged with an unrecognized ordering prints a warning so users are notified of their mistake
6
+
7
+ # File path, line number
8
+ RSpec::Core::ExampleGroup#metadata adds the the file_path to metadata
9
+ RSpec::Core::ExampleGroup#metadata has a reader for file_path
10
+ RSpec::Core::ExampleGroup#metadata adds the line_number to metadata
11
+
12
+ # Back trace, line number
13
+ RSpec::Core::ExampleGroup.pending sets the backtrace to the example definition so it can be located by the user
@@ -0,0 +1,7 @@
1
+ # location, file path, line number
2
+
3
+ RSpec::Core::FilterManager#prune prefers location to exclusion filter.*
4
+
5
+ # File I/O
6
+ RSpec::Core::FilterManager#exclusions#description cleans up the description
7
+ RSpec::Core::FilterManager#inclusions#description cleans up the description
@@ -0,0 +1,27 @@
1
+ # Spec uses File I/O and opal-rspec customizes the IO class anyways (see NoCarriageReturnIO)
2
+ RSpec::Core::Formatters::BaseTextFormatter when closing the formatter does not close an already closed output stream
3
+
4
+ # Will trigger File I/O
5
+ RSpec::Core::Formatters::DeprecationFormatter.* with a File deprecation_stream.*
6
+ RSpec::Core::Formatters::Loader#add\(formatter\) when a duplicate formatter exists adds the formatter for different output targets
7
+ RSpec::Core::Formatters::Loader#add\(formatter\) with a 2nd arg defining the output accepts Pathname objects for file paths
8
+ RSpec::Core::Formatters::Loader#add\(formatter\) with a 2nd arg defining the output creates a file at that path and sets it as the output
9
+
10
+ # Profiling within JSON formatter not supported either (profiling and Opal do not work yet)
11
+ RSpec::Core::Formatters::JsonFormatter#dump_profile.*
12
+
13
+ # location, file path, line number
14
+ RSpec::Core::Formatters::BaseTextFormatter#dump_failures for #shared_examples outputs the name and location
15
+ RSpec::Core::Formatters::BaseTextFormatter#dump_failures for #shared_examples that contains nested example groups outputs the name and location
16
+
17
+ # backtrace, line_number related
18
+ RSpec::Core::Formatters::BaseTextFormatter#dump_failures.*does not show the error class
19
+ RSpec::Core::Formatters::BaseTextFormatter#dump_summary includes command to re-run each failed example
20
+ RSpec::Core::Formatters::JsonFormatter outputs json \(brittle high level functional test\)
21
+
22
+ # Encoding related
23
+ RSpec::Core::Formatters::BaseTextFormatter#dump_failures with an exception that has a differently encoded message.*
24
+
25
+ # option parser
26
+ RSpec::Core::Formatters::DocumentationFormatter produces the expected full output
27
+ RSpec::Core::Formatters::ProgressFormatter produces the expected full output
@@ -0,0 +1,2 @@
1
+ # line number / back trace
2
+ RSpec::Core::Hooks#around when it does not run the example indicates which around hook did not run the example in the pending message
@@ -0,0 +1,6 @@
1
+ # Expected errors have line numbers in them, which is not supported on Opal right now
2
+ .let raises an error when referenced from.*
3
+ RSpec::Core::MemoizedHelpers.*raises an error when referenced from.*
4
+
5
+ # No private methods in Opal
6
+ Module#define_method is still a private method
@@ -0,0 +1,14 @@
1
+ # Uses I/O
2
+ RSpec::Core::Metadata :file_path.*
3
+
4
+ # location, file path, line number
5
+ RSpec::Core::Metadata for an example extracts .* caller
6
+ RSpec::Core::Metadata backwards compatibility :example_group can access the parent example group attributes via.*
7
+ RSpec::Core::Metadata backwards compatibility :example_group can still access the example group attributes via.*
8
+ RSpec::Core::Metadata backwards compatibility :example_group can still be filtered via a nested key under.*
9
+
10
+ # We can't figure this out in JS yet
11
+ RSpec::Core::Metadata :line_number.*
12
+
13
+ # symbols are strings in opal, so they won't be picked up as described classes
14
+ RSpec::Core::Metadata :described_class in an outer group with a Symbol returns the symbol
@@ -0,0 +1,2 @@
1
+ # Opal doesn't do checking to see if args match arity
2
+ RSpec::Core::MetadataFilter.filter_applies\? raises an error when the proc has an incorrect arity
@@ -0,0 +1,8 @@
1
+ # Uses #{__FILE__}:#{__LINE__} and backtrace
2
+ FailedExampleNotification #message_lines.*
3
+
4
+ # Uses File IO to find the failed line
5
+ FailedExampleNotification #read_failed_line.*
6
+
7
+ # Need special Javascript console code work, so have an alternate spec for this
8
+ RSpec::Core::Notifications::FailedExampleNotification uses the default color for the shared example backtrace line
@@ -0,0 +1,3 @@
1
+ # line numbers
2
+ RSpec::Core::World#preceding_declaration_line \(again\) with one example returns line number of an example that immediately precedes the argument line
3
+ RSpec::Core::World#preceding_declaration_line \(again\) with one example returns the argument line number if an example starts on that line
@@ -0,0 +1,20 @@
1
+ class ::Dir
2
+ def self.[](index)
3
+ []
4
+ end
5
+ end
6
+
7
+ module Aruba
8
+ module Api
9
+ end
10
+ end
11
+
12
+ # None of this is supported in Opal
13
+ module RSpec::Support::ShellOut
14
+ end
15
+
16
+ module MathnIntegrationSupport
17
+ def with_mathn_loaded
18
+ yield
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ # RSpec::Core::ExampleGroup setting pending metadata in parent marks every example as pending
2
+ # This opal-rspec test failure is happening because 'fail' in opal does not behave correctly
3
+ # https://github.com/opal/opal/pull/1117, status pending
4
+ unless Opal::RSpec::Compatibility.fail_raise_matches_mri?
5
+ module Kernel
6
+ def fail(message=nil)
7
+ if message
8
+ raise message
9
+ else
10
+ raise RuntimeError.new
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ # https://github.com/opal/opal/issues/1110, fixed in Opal 0.9
17
+ unless Opal::RSpec::Compatibility.class_within_class_new_works?
18
+ class ::RSpec::Core::HooksHost
19
+ include Hooks
20
+
21
+ def parent_groups
22
+ []
23
+ end
24
+ end
25
+ end
26
+
27
+ # Fixed in Opal 0.9
28
+ # https://github.com/opal/opal/commit/a6ec3164fcbb0f98ef46d385ea06bf0591828f23)
29
+ unless Object.const_defined? :ZeroDivisionError
30
+ class ZeroDivisionError < StandardError
31
+ end
32
+ end
33
+
34
+ # https://github.com/opal/opal/commit/5a17a12de1d3af45e189d34994a047fb7c1b4c72
35
+ unless Object.const_defined? :SecurityError
36
+ class SecurityError < Exception
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ # shell/file dependent
2
+ RSpec.shared_examples_for "a library that issues no warnings when loaded" do |lib, *preamble_stmnts|
3
+ end
@@ -0,0 +1,145 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ module RSpec::Core
5
+ RSpec.describe 'Opal ExampleGroup' do
6
+ describe "constant naming" do
7
+ around do |ex|
8
+ before_constants = RSpec::ExampleGroups.constants
9
+ ex.run
10
+ after_constants = RSpec::ExampleGroups.constants
11
+
12
+ (after_constants - before_constants).each do |name|
13
+ RSpec::ExampleGroups.send(:remove_const, name)
14
+ end
15
+ end
16
+
17
+ it 'disambiguates name collisions by appending a number', :unless => RUBY_VERSION == '1.9.2' do
18
+ groups = 10.times.map { ExampleGroup.describe("Collision") }
19
+ expect(groups[0]).to have_class_const("Collision")
20
+ expect(groups[1]).to have_class_const("Collision_2")
21
+ expect(groups[8]).to have_class_const("Collision_9")
22
+
23
+ if RUBY_VERSION.to_f > 1.8 && !(defined?(RUBY_ENGINE) && ['rbx', 'opal'].include?(RUBY_ENGINE))
24
+ # on 1.8.7, rbx "Collision_9".next => "Collisioo_0"
25
+ expect(groups[9]).to have_class_const("Collision_10")
26
+ end
27
+ end
28
+ end
29
+
30
+ describe "#before, after, and around hooks" do
31
+ it "treats an error in before(:each) as a failure" do
32
+ group = ExampleGroup.describe
33
+ group.before(:each) { raise "error in before each" }
34
+ example = group.example("equality") { expect(1).to eq(2) }
35
+ #expect(group.run).to be(false)
36
+ expect(group.run).to be_a Promise
37
+ expect(group.run.value).to be_falsey
38
+
39
+ expect(example.execution_result.exception.message).to eq("error in before each")
40
+ end
41
+
42
+ it "treats an error in before(:all) as a failure" do
43
+ group = ExampleGroup.describe
44
+ group.before(:all) { raise "error in before all" }
45
+ example = group.example("equality") { expect(1).to eq(2) }
46
+ #expect(group.run).to be_falsey
47
+ expect(group.run).to be_a Promise
48
+ expect(group.run.value).to be_falsey
49
+
50
+ expect(example.metadata).not_to be_nil
51
+ expect(example.execution_result.exception).not_to be_nil
52
+ expect(example.execution_result.exception.message).to eq("error in before all")
53
+ end
54
+ end
55
+
56
+ describe "#run_examples" do
57
+ let(:reporter) { double("reporter").as_null_object }
58
+
59
+ it "returns false if any of the examples fail" do
60
+ group = ExampleGroup.describe('group') do
61
+ example('ex 1') { expect(1).to eq(1) }
62
+ example('ex 2') { expect(1).to eq(2) }
63
+ end
64
+ allow(group).to receive(:filtered_examples) { group.examples }
65
+ # expect(group.run(reporter)).to be_falsey
66
+ # Promise
67
+ result = group.run(reporter)
68
+ expect(group.run(reporter).value).to be_falsey
69
+ end
70
+
71
+ it "runs all examples, regardless of any of them failing" do
72
+ group = ExampleGroup.describe('group') do
73
+ example('ex 1') { expect(1).to eq(2) }
74
+ example('ex 2') { expect(1).to eq(1) }
75
+ end
76
+ allow(group).to receive(:filtered_examples) { group.examples }
77
+ group.filtered_examples.each do |example|
78
+ expect(example).to receive(:run)
79
+ end
80
+ # expect(group.run(reporter)).to be_falsey
81
+ # Promise
82
+ expect(group.run(reporter).value).to be_falsey
83
+ end
84
+ end
85
+
86
+ describe "#run" do
87
+ let(:reporter) { double("reporter").as_null_object }
88
+
89
+ context "with fail_fast? => true" do
90
+ let(:group) do
91
+ group = RSpec::Core::ExampleGroup.describe
92
+ allow(group).to receive(:fail_fast?) { true }
93
+ group
94
+ end
95
+
96
+ it "sets RSpec.world.wants_to_quit flag if encountering an exception in before(:all)" do
97
+ group.before(:all) { raise "error in before all" }
98
+ group.example("equality") { expect(1).to eq(2) }
99
+ # This method returns a promise in Opal
100
+ #expect(group.run).to be_falsey
101
+ expect(group.run.value).to be_falsey
102
+ expect(RSpec.world.wants_to_quit).to be_truthy
103
+ end
104
+ end
105
+
106
+ context "with top level example failing" do
107
+ it "returns false" do
108
+ group = RSpec::Core::ExampleGroup.describe("something") do
109
+ it "does something (wrong - fail)" do
110
+ raise "fail"
111
+ end
112
+ describe "nested" do
113
+ it "does something else" do
114
+ # pass
115
+ end
116
+ end
117
+ end
118
+
119
+ #expect(group.run(reporter)).to be_falsey
120
+ # Promise
121
+ expect(group.run(reporter).value).to be_falsey
122
+ end
123
+ end
124
+
125
+ context "with nested example failing" do
126
+ it "returns true" do
127
+ group = RSpec::Core::ExampleGroup.describe("something") do
128
+ it "does something" do
129
+ # pass
130
+ end
131
+ describe "nested" do
132
+ it "does something else (wrong -fail)" do
133
+ raise "fail"
134
+ end
135
+ end
136
+ end
137
+
138
+ #expect(group.run(reporter)).to be_falsey
139
+ # Promise
140
+ expect(group.run(reporter).value).to be_falsey
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ module RSpec::Core::Notifications
4
+ describe 'Opal FailedExampleNotification' do
5
+ before do
6
+ allow(RSpec.configuration).to receive(:color_enabled?).and_return(true)
7
+ end
8
+
9
+ it "uses the default color for the shared example backtrace line" do
10
+ example = nil
11
+ group = RSpec::Core::ExampleGroup.describe "testing" do
12
+ shared_examples_for "a" do
13
+ example = it "fails" do
14
+ expect(1).to eq(2)
15
+ end
16
+ end
17
+ it_behaves_like "a"
18
+ end
19
+ group.run
20
+ fne = FailedExampleNotification.new(example)
21
+ lines = fne.colorized_message_lines
22
+ #expect(lines).to include(match("\\e\\[37mShared Example Group:"))
23
+ # Javascript console code
24
+ matcher = /.*Shared Example Group.*/
25
+ line = lines.find { |l| matcher.match l }
26
+ escape = "\033"
27
+ # Have to string concat this for it to work properly
28
+ expect(line).to eq(escape +"[31m" + escape+"[37mShared Example Group: \"a\" called from "+escape+"[0m"+escape+"[0m")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,113 @@
1
+ require "spec_helper"
2
+
3
+ module RSpec::Core
4
+ RSpec.describe 'Opal RSpec::Core::Hooks' do
5
+ context "when an error happens in `after(:suite)`" do
6
+ it 'allows the error to propagate to the user' do
7
+ RSpec.configuration.after(:suite) { 1 / 0 }
8
+
9
+ # expect {
10
+ # RSpec.configuration.hooks.run(:after, :suite, SuiteHookContext.new)
11
+ # }.to raise_error(ZeroDivisionError)
12
+ # hooks returns a promise, have to wait for that
13
+ RSpec.configuration.hooks.run(:after, :suite, SuiteHookContext.new).then do
14
+ raise 'Expected ZeroDivisionError but got none'
15
+ end.rescue do |ex|
16
+ expect(ex).to be_a? ZeroDivisionError
17
+ end
18
+ end
19
+ end
20
+
21
+ context "when an error happens in `before(:suite)`" do
22
+ it 'allows the error to propagate to the user' do
23
+ RSpec.configuration.before(:suite) { 1 / 0 }
24
+
25
+ # expect {
26
+ # RSpec.configuration.hooks.run(:before, :suite, SuiteHookContext.new)
27
+ # }.to raise_error(ZeroDivisionError)
28
+ # hooks return a promise
29
+ RSpec.configuration.hooks.run(:before, :suite, SuiteHookContext.new).then do
30
+ raise 'Expected ZeroDivisionError but got none'
31
+ end.rescue do |ex|
32
+ expect(ex).to be_a? ZeroDivisionError
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '#around' do
38
+ context 'when it does not run the example' do
39
+ context 'for a hook declared in the group' do
40
+ it 'converts the example to a skipped example so the user is made aware of it' do
41
+ ex = nil
42
+ group = RSpec.describe do
43
+ around {}
44
+ ex = example("not run") {}
45
+ end
46
+
47
+ # promise
48
+ # group.run
49
+ # expect(ex.execution_result.status).to eq(:pending)
50
+ group.run.then do
51
+ expect(ex.execution_result.status).to eq(:pending)
52
+ end
53
+ end
54
+ end
55
+
56
+ context 'for a hook declared in config' do
57
+ it 'converts the example to a skipped example so the user is made aware of it' do
58
+ RSpec.configuration.around {}
59
+
60
+ ex = nil
61
+ group = RSpec.describe do
62
+ ex = example("not run") {}
63
+ end
64
+
65
+ # promise
66
+ # group.run
67
+ # expect(ex.execution_result.status).to eq(:pending)
68
+ group.run.then do
69
+ expect(ex.execution_result.status).to eq(:pending)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ it 'considers the hook to have run when passed as a block to a method that yields' do
76
+ ex = nil
77
+ group = RSpec.describe do
78
+ def transactionally
79
+ yield
80
+ end
81
+
82
+ around { |e| transactionally(&e) }
83
+ ex = example("run") {}
84
+ end
85
+
86
+ # promise
87
+ # group.run
88
+ # expect(ex.execution_result.status).to eq(:passed)
89
+ group.run.then do
90
+ expect(ex.execution_result.status).to eq(:passed)
91
+ end
92
+ end
93
+
94
+ it 'does not consider the hook to have run when passed as a block to a method that does not yield' do
95
+ ex = nil
96
+ group = RSpec.describe do
97
+ def transactionally;
98
+ end
99
+
100
+ around { |e| transactionally(&e) }
101
+ ex = example("not run") {}
102
+ end
103
+
104
+ # promise
105
+ # group.run
106
+ # expect(ex.execution_result.status).to eq(:pending)
107
+ group.run.then do
108
+ expect(ex.execution_result.status).to eq(:pending)
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end