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,2 @@
1
+ require_relative 'stdlib/pp'
2
+ require_relative 'stdlib/set'
@@ -0,0 +1,23 @@
1
+ # https://github.com/opal/opal/pull/1104, fixed in Opal 0.9
2
+ # Opal hasn't been using $stdout as a default value
3
+ unless Opal::RSpec::Compatibility.pp_uses_stdout_default?
4
+ class PP
5
+ class << self
6
+ if `(typeof(console) === "undefined" || typeof(console.log) === "undefined")`
7
+ def pp(obj, out=$stdout, width=79)
8
+ p(*args)
9
+ end
10
+ else
11
+ def pp(obj, out=$stdout, width=79)
12
+ if String === out
13
+ out + obj.inspect + "\n"
14
+ else
15
+ out << obj.inspect + "\n"
16
+ end
17
+ end
18
+ end
19
+
20
+ alias :singleline_pp :pp
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ # https://github.com/opal/opal/pull/1152
2
+ unless Opal::RSpec::Compatibility.set_has_superset?
3
+ class Set
4
+ def superset?(set)
5
+ set.is_a?(Set) or raise ArgumentError, "value must be a set"
6
+ return false if size < set.size
7
+ set.all? { |o| include?(o) }
8
+ end
9
+
10
+ alias >= superset?
11
+
12
+ def proper_superset?(set)
13
+ set.is_a?(Set) or raise ArgumentError, "value must be a set"
14
+ return false if size <= set.size
15
+ set.all? { |o| include?(o) }
16
+ end
17
+
18
+ alias > proper_superset?
19
+
20
+ def subset?(set)
21
+ set.is_a?(Set) or raise ArgumentError, "value must be a set"
22
+ return false if set.size < size
23
+ all? { |o| set.include?(o) }
24
+ end
25
+
26
+ alias <= subset?
27
+
28
+ def proper_subset?(set)
29
+ set.is_a?(Set) or raise ArgumentError, "value must be a set"
30
+ return false if set.size <= size
31
+ all? { |o| set.include?(o) }
32
+ end
33
+
34
+ alias < proper_subset?
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'rspec/core'
2
+ require_relative 'rspec/support'
3
+ require_relative 'rspec/expectations'
4
+ require_relative 'rspec/matchers'
5
+ require_relative 'rspec/mocks'
6
+ require_relative 'rspec/caller_filter'
7
+ require_relative 'rspec/example_groups'
@@ -0,0 +1,9 @@
1
+ require_relative 'core/example_group'
2
+ require_relative 'core/example'
3
+ require_relative 'core/reporter'
4
+ require_relative 'core/formatters'
5
+ require_relative 'core/notifications'
6
+ require_relative 'core/ordering'
7
+ require_relative 'core/metadata'
8
+ require_relative 'core/configuration'
9
+ require_relative 'core/warnings'
@@ -0,0 +1,11 @@
1
+ class ::RSpec::Core::Configuration
2
+ # This needs to be implemented if/when we allow the Opal side to decide what files to run
3
+ def files_or_directories_to_run=(*files)
4
+ @files_or_directories_to_run = []
5
+ @files_to_run = nil
6
+ end
7
+
8
+ def requires=(paths)
9
+ # can't change requires @ this stage, this method calls RubyProject which will crash on Opal
10
+ end
11
+ end
@@ -11,7 +11,7 @@ class RSpec::Core::Example
11
11
  RSpec::Matchers.clear_generated_description
12
12
  end
13
13
 
14
- # Fix unnecessary deprecation warnings
14
+ # https://github.com/opal/opal/issues/1126
15
15
  # Hash.public_instance_methods - Object.public_instance_methods, which is a part of metadata.rb/HashImitatable (included by ExecutionResult), returns the initialize method, which gets marked as deprecated. The intent of the issue_deprecation method though is to shift people away from using this as a hash. Initialize obviously is not indicative of hash usage (any new object will trip this up, and that should not happen).
16
16
  class ExecutionResult
17
17
  # There is no real constructor to preserve in example.rb's ExecutionResult class, so can eliminate the issue_deprecation call this way
@@ -0,0 +1,9 @@
1
+ unless Opal::RSpec::Compatibility.class_descendant_of_self_fixed?
2
+ class ::RSpec::Core::ExampleGroup
3
+ def self.parent_groups
4
+ # https://github.com/opal/opal/issues/1077, fixed in Opal 0.9
5
+ # @parent_groups ||= ancestors.select { |a| a < RSpec::Core::ExampleGroup }
6
+ @parent_groups ||= ancestors.select { |a| a < RSpec::Core::ExampleGroup and a != RSpec::Core::ExampleGroup }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'formatters/backtrace_formatter'
2
+ require_relative 'formatters/deprecation_formatter'
3
+ require_relative 'formatters/generated_deprecation_message'
4
+ require_relative 'formatters/console_codes'
5
+ require_relative 'formatters/loader'
6
+ require_relative 'formatters/json_formatter'
@@ -0,0 +1,20 @@
1
+ class ::RSpec::Core::BacktraceFormatter
2
+ def backtrace_line(line)
3
+ # don't have the Metadata class in Opal
4
+ #Metadata.relative_path(line) unless exclude?(line)
5
+ nil
6
+ end
7
+
8
+ alias_method :original_format_backtrace, :format_backtrace
9
+
10
+ def format_backtrace(backtrace, options={})
11
+ # Javascript stack traces include the message on the first few lines, but we already have that in the message
12
+ # have several blank lines as well
13
+ original_format_backtrace clean_js_backtrace(backtrace), options
14
+ end
15
+
16
+ def clean_js_backtrace(backtrace)
17
+ valid_line = /\s*at.*/
18
+ backtrace.select { |line| valid_line.match line }
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module ::RSpec::Core::Formatters::ConsoleCodes
2
+ def wrap(text, code_or_symbol)
3
+ if RSpec.configuration.color_enabled?
4
+ # Need to escape the \e differently in JS and can't use string interpolation
5
+ #"\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
6
+ "\033" + "[#{console_code_for(code_or_symbol)}m#{text}" +"\033" + '[0m'
7
+ else
8
+ text
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ class RSpec::Core::Formatters::DeprecationFormatter
2
+
3
+ # SpecifiedDeprecationMessage is a Struct
4
+ SpecifiedDeprecationMessage.class_eval do
5
+ def too_many_warnings_message
6
+ # mutable strings not supported
7
+ "Too many similar deprecation messages reported, disregarding further reports. " + DEPRECATION_STREAM_NOTICE
8
+ end
9
+ end
10
+
11
+ # GeneratedDeprecationMessage is a Struct
12
+ GeneratedDeprecationMessage.class_eval do
13
+ def to_s
14
+ msg = "#{@data.deprecated} is deprecated."
15
+ msg = msg + " Use #{@data.replacement} instead." if @data.replacement
16
+ msg = msg + " Called from #{@data.call_site}." if @data.call_site
17
+ msg
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ RSpec::Core::Formatters::DeprecationFormatter::GeneratedDeprecationMessage.class_eval do
2
+ # string mutations
3
+ def to_s
4
+ msg = "#{@data.deprecated} is deprecated."
5
+ msg += " Use #{@data.replacement} instead." if @data.replacement
6
+ msg += " Called from #{@data.call_site}." if @data.call_site
7
+ msg
8
+ end
9
+
10
+ def too_many_warnings_message
11
+ msg = "Too many uses of deprecated '#{type}'. "
12
+ msg += RSpec::Core::Formatters::DeprecationFormatter::DEPRECATION_STREAM_NOTICE
13
+ msg
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ class ::RSpec::Core::Formatters::JsonFormatter
2
+ def close(_notification)
3
+ output.write @output_hash.to_json
4
+ # JSON formatter does not look @ closed? and we need it to, otherwise Phantom freezes
5
+ return unless IO === output
6
+ return if output.closed? || output == $stdout
7
+
8
+ output.close
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ class ::RSpec::Core::Formatters::Loader
2
+ def string_const?(str)
3
+ # Incompatible regex (\A flag and \z flag)
4
+ # str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str
5
+ str.is_a?(String) && /^[A-Z][a-zA-Z0-9_:]*$/ =~ str
6
+ end
7
+
8
+ def underscore(camel_cased_word)
9
+ # string mutation
10
+ word = camel_cased_word.to_s.dup
11
+ word = word.gsub(/::/, '/')
12
+ word = word.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
13
+ word = word.gsub(/([a-z\d])([A-Z])/, '\1_\2')
14
+ word = word.tr("-", "_")
15
+ word.downcase
16
+ end
17
+
18
+ def custom_formatter(formatter_ref)
19
+ if Class === formatter_ref
20
+ formatter_ref
21
+ elsif string_const?(formatter_ref)
22
+ # retry not supported on opal
23
+ # begin
24
+ # formatter_ref.gsub(/^::/, '').split('::').inject(Object) { |a, e| a.const_get e }
25
+ # rescue NameError
26
+ # require(path_for(formatter_ref)) ? retry : raise
27
+ # end
28
+ while true
29
+ begin
30
+ return formatter_ref.gsub(/^::/, '').split('::').inject(Object) { |a, e| a.const_get e }
31
+ rescue NameError
32
+ raise unless require(path_for(formatter_ref))
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,39 @@
1
+ module ::RSpec::Core::Metadata
2
+ # https://github.com/opal/opal/issues/1090, fixed in Opal 0.9
3
+ unless ::Opal::RSpec::Compatibility.and_works_with_lhs_nil?
4
+ class ExampleGroupHash
5
+ def described_class
6
+ candidate = metadata[:description_args].first
7
+ return candidate unless NilClass === candidate || String === candidate
8
+ parent_group = metadata[:parent_example_group]
9
+ # https://github.com/opal/opal/issues/1090, fixed in Opal 0.9
10
+ # parent_group && parent_group[:described_class]
11
+ if parent_group
12
+ parent_group[:described_class]
13
+ else
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ class HashPopulator
21
+ def populate_location_attributes
22
+ backtrace = user_metadata.delete(:caller)
23
+
24
+ file_path, line_number = if backtrace
25
+ file_path_and_line_number_from(backtrace)
26
+ # Opal 0.9 has a stub for this but it does not return anything
27
+ # elsif block.respond_to?(:source_location)
28
+ # block.source_location
29
+ else
30
+ file_path_and_line_number_from(caller)
31
+ end
32
+
33
+ file_path = Metadata.relative_path(file_path)
34
+ metadata[:file_path] = file_path
35
+ metadata[:line_number] = line_number.to_i
36
+ metadata[:location] = "#{file_path}:#{line_number}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'notifications/examples_notification'
2
+ require_relative 'notifications/failed_example_notification'
3
+ require_relative 'notifications/summary_notification'
@@ -0,0 +1,30 @@
1
+ module ::RSpec::Core::Notifications
2
+ class ExamplesNotification
3
+ def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
4
+ formatted = "\nFailures:\n"
5
+
6
+ failure_notifications.each_with_index do |failure, index|
7
+ # string mutation
8
+ formatted = formatted + failure.fully_formatted(index.next, colorizer)
9
+ end
10
+
11
+ formatted
12
+ end
13
+
14
+ def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
15
+ formatted = "\nPending:\n"
16
+
17
+ pending_examples.each do |example|
18
+ formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
19
+
20
+ # string mutation
21
+ formatted = formatted +
22
+ " #{colorizer.wrap(example.full_description, :pending)}\n" \
23
+ " # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" \
24
+ " # #{colorizer.wrap(formatted_caller, :detail)}\n"
25
+ end
26
+
27
+ formatted
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module ::RSpec::Core::Notifications
2
+ class FailedExampleNotification
3
+ def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
4
+ formatted = "\n #{failure_number}) #{description}\n"
5
+
6
+ colorized_message_lines(colorizer).each do |line|
7
+ # formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
8
+ # string mutation
9
+ formatted = formatted + RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
10
+ end
11
+
12
+ colorized_formatted_backtrace(colorizer).each do |line|
13
+ # formatted << RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
14
+ # string mutation
15
+ formatted = formatted + RSpec::Support::EncodedString.new(" #{line}\n", encoding_of(formatted))
16
+ end
17
+ formatted
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module ::RSpec::Core::Notifications
2
+ # SummaryNotification is a Struct
3
+ SummaryNotification.class_eval do
4
+ def totals_line
5
+ summary = Formatters::Helpers.pluralize(example_count, "example")
6
+ # 2 string mutations
7
+ summary = summary + ", " + Formatters::Helpers.pluralize(failure_count, "failure")
8
+ # string mutation
9
+ summary = summary + ", #{pending_count} pending" if pending_count > 0
10
+ summary
11
+ end
12
+
13
+ def fully_formatted(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
14
+ formatted = "\nFinished in #{formatted_duration} " \
15
+ "(files took #{formatted_load_time} to load)\n" \
16
+ "#{colorized_totals_line(colorizer)}\n"
17
+
18
+ unless failed_examples.empty?
19
+ # 2 string mutations
20
+ formatted = formatted + colorized_rerun_commands(colorizer) + "\n"
21
+ end
22
+
23
+ formatted
24
+ end
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require_relative 'ordering/random'
@@ -0,0 +1,13 @@
1
+ # Random causes problems that can lock up a browser (see README)
2
+ class ::RSpec::Core::Ordering::Random
3
+ HIDE_RANDOM_WARNINGS = false
4
+
5
+ def initialize(configuration)
6
+ `console.warn("Random order is not currently supported by opal-rspec, using default order.")` unless HIDE_RANDOM_WARNINGS
7
+ end
8
+
9
+ # Identity is usually the default, so borrowing its implementation, this forces 'accidental' random usage down that path
10
+ def order(items)
11
+ items
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ unless Opal::RSpec::Compatibility.is_set_coerced_to_array?
2
+ class RSpec::Core::Reporter
3
+ # https://github.com/opal/opal/issues/858, fixed in Opal 0.9
4
+ # The problem is not directly related to the Reporter class (it has more to do with Formatter's call in add using a splat in the args list and right now, Opal does not run a to_a on a set that can be an array in the splat before the callee method takes over)
5
+ def register_listener(listener, *notifications)
6
+ # Without this, we won't flatten out each notification properly (e.g. example_started, finished, etc.)
7
+ notifications = notifications[0].to_a if notifications[0].is_a? Set
8
+ notifications.each do |notification|
9
+ @listeners[notification.to_sym] << listener
10
+ end
11
+ true
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # not 100% sure this compat check fixes this, but it's pretty close
2
+ unless Opal::RSpec::Compatibility.multiple_module_include_super_works_right?
3
+ module ::RSpec::Core::Warnings
4
+ def warn_with(message, options={})
5
+ if options[:use_spec_location_as_call_site]
6
+ message += "." unless message.end_with?(".")
7
+
8
+ if RSpec.current_example
9
+ message += " Warning generated from spec at `#{RSpec.current_example.location}`."
10
+ end
11
+ end
12
+
13
+ # super won't find this
14
+ # super(message, options)
15
+ support_warn_with message, options
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ module RSpec::ExampleGroups
2
+ # opal cannot use mutable strings AND opal doesnt support `\A` or `\z` anchors
3
+ def self.base_name_for(group)
4
+ return "Anonymous" if group.description.empty?
5
+
6
+ # convert to CamelCase
7
+ name = ' ' + group.description
8
+
9
+ # replaced gsub! with name = name.gsub (mutable strings)
10
+ name = name.gsub(/[^0-9a-zA-Z]+([0-9a-zA-Z])/) { Regexp.last_match[1].upcase }
11
+
12
+ # mutable strings on these 2
13
+ name = name.lstrip # Remove leading whitespace
14
+ name = name.gsub(/\W/, '') # JRuby, RBX and others don't like non-ascii in const names
15
+
16
+ # Ruby requires first const letter to be A-Z. Use `Nested`
17
+ # as necessary to enforce that.
18
+ # name.gsub!(/\A([^A-Z]|\z)/, 'Nested\1')
19
+ # opal-rspec, mutable strings, also substituted in ^ for \A since \A and $ for \z is not supported in JS regex
20
+ name = name.gsub(/^([^A-Z]|$)/, 'Nested\1')
21
+
22
+ name
23
+ end
24
+
25
+ # opal cannot use mutable strings
26
+ def self.disambiguate(name, const_scope)
27
+ return name unless const_defined_on?(const_scope, name)
28
+
29
+ # Add a trailing number if needed to disambiguate from an existing constant.
30
+ name = name + "_2"
31
+
32
+ while const_defined_on?(const_scope, name)
33
+ name = name.next
34
+ end
35
+
36
+ name
37
+ end
38
+ end
39
+
40
+ # https://github.com/opal/opal/issues/1080, fixed in Opal 0.9
41
+ unless Opal::RSpec::Compatibility.is_constants_a_clone?
42
+ module RSpec::ExampleGroups
43
+ original_constants = method(:constants)
44
+
45
+ self.class.send(:define_method, :constants) do
46
+ original_constants.call().dup
47
+ end
48
+ end
49
+ end