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,4 @@
1
+ rspec_filter 'receive_message_chain' do
2
+ # throw not supported on Opal 0.8
3
+ filter('receive_message_chain with only the expect syntax enabled works with and_throw').unless { at_least_opal_0_9? }
4
+ end
@@ -0,0 +1,2 @@
1
+ # line/number backtrace
2
+ expect\(...\).to receive_messages\(:a => 1, :b => 2\) fails with the correct location
@@ -0,0 +1 @@
1
+ Using the legacy should syntax #should_receive with an options hash reports the file and line submitted with :expected_from
@@ -0,0 +1,7 @@
1
+ rspec_filter 'space' do
2
+ # no diff on Opal
3
+ filter 'RSpec::Mocks::Space can be diffed in a failure when it has references to an error generator via a proxy'
4
+
5
+ # mocking strings
6
+ filter 'RSpec::Mocks::Space#proxies_of(klass) returns proxies'
7
+ end
@@ -0,0 +1,7 @@
1
+ rspec_filter 'stub' do
2
+ # no throw in Opal 0.8
3
+ unless at_least_opal_0_9?
4
+ filter('A method stub throws with argument when told to')
5
+ filter('A method stub throws when told to')
6
+ end
7
+ end
@@ -0,0 +1,76 @@
1
+ # Copied from rspec-mocks/spec/support
2
+ class LoadedClass
3
+ extend RSpec::Support::RubyFeatures
4
+
5
+ M = :m
6
+ N = :n
7
+ INSTANCE = LoadedClass.new
8
+
9
+ class << self
10
+
11
+ def respond_to?(method_name, include_all = false)
12
+ return true if method_name == :dynamic_class_method
13
+ super
14
+ end
15
+
16
+ def defined_class_method
17
+ end
18
+
19
+ def send
20
+ # fake out!
21
+ end
22
+
23
+ protected
24
+
25
+ def defined_protected_class_method
26
+ end
27
+
28
+ private
29
+
30
+ def defined_private_class_method
31
+ end
32
+
33
+ end
34
+
35
+ def defined_instance_method
36
+ end
37
+
38
+ def instance_method_with_two_args(a, b)
39
+ end
40
+
41
+ def instance_method_with_only_defaults(a=1, b=2)
42
+ end
43
+
44
+ # no eval on opal
45
+ #if required_kw_args_supported?
46
+ # Need to eval this since it is invalid syntax on earlier rubies.
47
+ #eval <<-RUBY
48
+ def kw_args_method(foo, optional_arg:'hello', required_arg:)
49
+ end
50
+
51
+ def mixed_args_method(foo, bar, optional_arg_1:1, optional_arg_2:2)
52
+ end
53
+ #RUBY
54
+ #end
55
+
56
+ def send(*)
57
+ end
58
+
59
+ def respond_to?(method_name, include_all = false)
60
+ return true if method_name == :dynamic_instance_method
61
+ super
62
+ end
63
+
64
+ class Nested; end
65
+
66
+ protected
67
+
68
+ def defined_protected_method
69
+ end
70
+
71
+ private
72
+
73
+ def defined_private_method
74
+ "wink wink ;)"
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ # None of this is supported in Opal
2
+ module RSpec::Support::ShellOut
3
+ end
@@ -0,0 +1,59 @@
1
+ # https://github.com/opal/opal/issues/1110, fixed in Opal 0.9
2
+ unless Opal::RSpec::Compatibility.class_within_class_new_works?
3
+ class ExpiredInstanceInterface
4
+ def foo;
5
+ end
6
+
7
+ def bar;
8
+ end
9
+
10
+ def bazz;
11
+ end
12
+ end
13
+
14
+ class ExpiredClassInterface
15
+ def self.foo;
16
+ end
17
+
18
+ def self.bar;
19
+ end
20
+
21
+ def self.bazz;
22
+ end
23
+ end
24
+
25
+ class ExampleClass
26
+ def hello
27
+ :hello_defined_on_class
28
+ end
29
+ end
30
+
31
+ module MethodMissing
32
+ remove_method :method_missing rescue nil
33
+
34
+ def method_missing(m, *a, &b)
35
+ if m == :captured_by_method_missing
36
+ "response generated by method missing"
37
+ else
38
+ super(m, *a, &b)
39
+ end
40
+ end
41
+ end
42
+
43
+ class Foo
44
+ def self.foo
45
+ bar
46
+ rescue StandardError
47
+ end
48
+ end
49
+
50
+ class OutOfGas < StandardError
51
+ attr_reader :amount, :units
52
+
53
+ def initialize(amount, units)
54
+ @amount = amount
55
+ @units = units
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,87 @@
1
+ require_relative '../opal_rspec_spec_loader'
2
+
3
+ module Opal
4
+ module RSpec
5
+ module MocksSpecLoader
6
+ extend Opal::RSpec::OpalRSpecSpecLoader
7
+
8
+ def self.expected_pending_count
9
+ 10
10
+ end
11
+
12
+ def self.base_dir
13
+ 'spec/rspec/mocks'
14
+ end
15
+
16
+ def self.files_with_line_continue
17
+ []
18
+ end
19
+
20
+ def self.spec_glob
21
+ %w{rspec-mocks/spec/**/*_spec.rb}
22
+ end
23
+
24
+ def self.stubbed_requires
25
+ [
26
+ 'rubygems',
27
+ 'rspec/support/spec/shell_out', # only does stuff Opal can't support anyways,
28
+ 'spec', # we have our own version of this in spec_helper that's compatible
29
+ 'simplecov', # hooks aren't available on Opal
30
+ 'yaml', # not avail om opal yet
31
+ 'psych',
32
+ 'support/doubled_classes', # we have to create our own version of this due to eval in their code
33
+ 'spec_helper' # we include our own spec helper that's opal compatible (spec_helper_opal)
34
+ ]
35
+ end
36
+
37
+ def self.symbol_files
38
+ [
39
+ /have_received_spec.rb/,
40
+ /stubbed_message_expectations_spec.rb/,
41
+ /stub_spec.rb/,
42
+ /receive_spec.rb/,
43
+ /hash_excluding_matcher_spec.rb/,
44
+ /hash_including_matcher_spec.rb/,
45
+ /\/double_spec.rb/,
46
+ /argument_matchers_spec.rb/
47
+ ]
48
+ end
49
+
50
+ def self.symbols_replace_regexes
51
+ [
52
+ /(expect.*description\)\.to eq)\((.*)\)/,
53
+ /(expect.*description\)\.to eq) (.*)/,
54
+ /(raise_error)\((%Q.*)\)/,
55
+ /(raise_error)\((\/received (?!:two).*\/.*)\)/,
56
+ /(raise_error\(RSpec::Mocks::MockExpectationError,) (.*\))/,
57
+ /(fail_\w+)\((\/expected: \\\({\(:.*)\)/,
58
+ # "expected: (hash_not_including(:a=>1))"
59
+ /(fail_\w+) ("expected: \(hash.*)/,
60
+ # fail_matching "expected: (duck_type(:abs, :div))"
61
+ /(fail_\w+) ("expected: \(duck_type.*)/
62
+ ]
63
+ end
64
+
65
+ def self.symbol_do_not_replace_regexes
66
+ # in these cases, the symbols do come in correctly in Opal
67
+ [
68
+ # fails when args are expected but none are received
69
+ 'raise_error(RSpec::Mocks::MockExpectationError, %q|Double "test double" received unexpected message :foobar with (no args)|)',
70
+ # fails if unexpected method called
71
+ 'raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" received unexpected message :something with (\"a\", \"b\", \"c\")")'
72
+ ].map { |r| Regexp.new(Regexp.escape(r)) }
73
+ end
74
+
75
+ def self.sub_in_files
76
+ files = super
77
+ symbols_in_expectations files
78
+ end
79
+
80
+ def self.additional_load_paths
81
+ [
82
+ 'rspec-mocks/spec' # a few spec support files live outside of rspec-mocks/spec/rspec and live in support
83
+ ]
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,15 @@
1
+ class ::RSpec::Core::Ordering::Random
2
+ # there are a lot of these in the RSpec specs that create noise
3
+ HIDE_RANDOM_WARNINGS = true
4
+ end
5
+
6
+ require 'support/before_all_shared_example_group'
7
+ require 'rspec/support/spec/with_isolated_stderr'
8
+ require 'rspec/support/spec/stderr_splitter'
9
+ require 'rspec/support/spec/formatting_support'
10
+ require 'opal/fixes/deprecation_helpers'
11
+ require 'opal/fixes/rspec_helpers'
12
+ require_relative 'spec_helper_opal'
13
+ require_relative 'fixes/doubled_classes'
14
+ require_relative 'fixes/missing_constants'
15
+ require_relative 'fixes/opal_itself'
@@ -0,0 +1,11 @@
1
+ # Do not support marshalling in Opal
2
+ **/marshal_extension_spec.rb
3
+
4
+ # No private, public, etc.
5
+ **/method_visibility_spec.rb
6
+
7
+ # class_double depends on ClassVerifyingDouble inheriting from Module to support transferring nested constants, but that doesn't work on Opal
8
+ **/class_double*_spec.rb
9
+
10
+ # YAML/marshal serialization
11
+ **/serialization_spec.rb
@@ -0,0 +1,129 @@
1
+ require 'rspec/support/spec'
2
+ require 'rspec/support/ruby_features'
3
+
4
+ require 'opal/progress_json_formatter' # verify case uses this
5
+ # Only doing this because any_instance causes the runner itself to break
6
+ CAUSES_SPECS_TO_CRASH = [
7
+ /.*allow_any_instance.*/,
8
+ /.*any_instance_of.*/
9
+ ]
10
+
11
+ RSpec::Matchers.define :include_method do |expected|
12
+ match do |actual|
13
+ actual.map { |m| m.to_s }.include?(expected.to_s)
14
+ end
15
+ end
16
+ require 'support/matchers'
17
+
18
+ module VerifyAndResetHelpers
19
+ def verify(object)
20
+ proxy = RSpec::Mocks.space.proxy_for(object)
21
+ proxy.verify
22
+ ensure
23
+ proxy.reset # so it doesn't fail the verify after the example completes
24
+ end
25
+
26
+ def reset(object)
27
+ RSpec::Mocks.space.proxy_for(object).reset
28
+ end
29
+
30
+ def verify_all
31
+ RSpec::Mocks.space.verify_all
32
+ ensure
33
+ reset_all
34
+ end
35
+
36
+ def reset_all
37
+ RSpec::Mocks.space.reset_all
38
+ end
39
+ end
40
+
41
+ module VerificationHelpers
42
+ def prevents(msg = //, &block)
43
+ expect(&block).to raise_error(RSpec::Mocks::MockExpectationError, msg)
44
+ end
45
+ end
46
+
47
+ require 'rspec/support/spec'
48
+
49
+ RSpec.configure do |config|
50
+ config.expose_dsl_globally = false
51
+ config.mock_with :rspec
52
+ config.color = true
53
+ config.order = :random
54
+
55
+ config.expect_with :rspec do |expectations|
56
+ expectations.syntax = :expect
57
+ end
58
+
59
+ config.mock_with :rspec do |mocks|
60
+ $default_rspec_mocks_syntax = mocks.syntax
61
+ mocks.syntax = :expect
62
+ end
63
+
64
+ old_verbose = nil
65
+ config.before(:each, :silence_warnings) do
66
+ old_verbose = $VERBOSE
67
+ $VERBOSE = nil
68
+ end
69
+
70
+ config.after(:each, :silence_warnings) do
71
+ $VERBOSE = old_verbose
72
+ end
73
+
74
+ config.include VerifyAndResetHelpers
75
+ config.include VerificationHelpers
76
+ config.extend RSpec::Support::RubyFeatures
77
+ config.include RSpec::Support::RubyFeatures
78
+ config.filter_run_excluding full_description: Regexp.union(CAUSES_SPECS_TO_CRASH)
79
+ #config.full_description = 'when verify_partial_doubles configuration option is set.*'
80
+ end
81
+
82
+ RSpec.shared_context "with syntax" do |syntax|
83
+ orig_syntax = nil
84
+
85
+ before(:all) do
86
+ orig_syntax = RSpec::Mocks.configuration.syntax
87
+ RSpec::Mocks.configuration.syntax = syntax
88
+ end
89
+
90
+ after(:all) do
91
+ RSpec::Mocks.configuration.syntax = orig_syntax
92
+ end
93
+ end
94
+
95
+
96
+ RSpec.shared_context "with isolated configuration" do
97
+ orig_configuration = nil
98
+ before do
99
+ orig_configuration = RSpec::Mocks.configuration
100
+ RSpec::Mocks.instance_variable_set(:@configuration, RSpec::Mocks::Configuration.new)
101
+ end
102
+
103
+ after do
104
+ RSpec::Mocks.instance_variable_set(:@configuration, orig_configuration)
105
+ end
106
+ end
107
+
108
+ RSpec.shared_context "with monkey-patched marshal" do
109
+ before do
110
+ RSpec::Mocks.configuration.patch_marshal_to_support_partial_doubles = true
111
+ end
112
+
113
+ after do
114
+ RSpec::Mocks.configuration.patch_marshal_to_support_partial_doubles = false
115
+ end
116
+ end
117
+
118
+ RSpec.shared_context "with the default mocks syntax" do
119
+ orig_syntax = nil
120
+
121
+ before(:all) do
122
+ orig_syntax = RSpec::Mocks.configuration.syntax
123
+ RSpec::Mocks.configuration.reset_syntaxes_to_default
124
+ end
125
+
126
+ after(:all) do
127
+ RSpec::Mocks.configuration.syntax = orig_syntax
128
+ end
129
+ end
@@ -0,0 +1,349 @@
1
+ require 'tmpdir'
2
+ require_relative 'filter_processor'
3
+
4
+ module Opal
5
+ module RSpec
6
+ module OpalRSpecSpecLoader
7
+ include Rake::DSL
8
+
9
+ def files_with_line_continue
10
+ []
11
+ end
12
+
13
+ def files_with_multiline_regex
14
+ []
15
+ end
16
+
17
+ def unstub_requires
18
+ []
19
+ end
20
+
21
+ def additional_load_paths
22
+ []
23
+ end
24
+
25
+ def post_requires
26
+ []
27
+ end
28
+
29
+ def get_ignored_spec_failures
30
+ text_based = FileList[File.join(base_dir, 'filter/**/*.txt')].map do |filename|
31
+ get_compact_text_expressions filename, wrap_in_regex=true
32
+ end.flatten
33
+ processor = FilterProcessor.new
34
+ FileList[File.join(base_dir, 'filter/**/*.rb')].exclude('**/sandbox/**/*').each do |filename|
35
+ processor.filename = filename
36
+ contents = File.read filename
37
+ processor.instance_eval contents
38
+ end
39
+ text_based + processor.all_filters
40
+ end
41
+
42
+ def stub_requires
43
+ stubbed_requires.each { |f| Opal::Processor.stub_file f }
44
+ unstub_requires.each do |f|
45
+ puts "Unstubbing #{f} per test request"
46
+ Opal::Processor.stubbed_files.delete f
47
+ end
48
+ end
49
+
50
+ def symbols_replace_regexes
51
+ [
52
+ /(fail_\w+)\((.*)\)/,
53
+ /(expect.*description\)\.to eq)\((.*)\)/,
54
+ /(expect.*description\)\.to eq) (.*)/
55
+ ]
56
+ end
57
+
58
+ def symbol_do_not_replace_regexes
59
+ []
60
+ end
61
+
62
+ def symbols_in_expectations(files)
63
+ matching = symbols_replace_regexes
64
+ # fail_with(/expected .* to respond to :some_method/)
65
+ replace_with_regex matching, 'fix symbols in message expectations', files, symbol_files do |match, temp_filename|
66
+ next match.to_s if symbol_do_not_replace_regexes.any? { |exp| exp.match match.to_s }
67
+ # Don't want to match #<Object:.*>
68
+ between_parens = match.captures[1]
69
+ symbol_matcher = /:([a-zA-Z]\w*)/
70
+ next match.to_s unless symbol_matcher.match(between_parens)
71
+ # Escape quotes if in a string
72
+ replace_pattern = if between_parens.start_with? '"'
73
+ "\\\"\\1\\\""
74
+ else
75
+ "\"\\1\""
76
+ end
77
+ fail_with_wo_symbols = between_parens.gsub(symbol_matcher, replace_pattern)
78
+ fail_type = match.captures[0]
79
+ new = "#{fail_type}(#{fail_with_wo_symbols})"
80
+ puts "#{temp_filename} - symbol fix -replacing #{match.to_s} with #{new} in new temp file"
81
+ new
82
+ end
83
+ end
84
+
85
+ def get_file_list
86
+ exclude_these_specs = get_compact_text_expressions File.join(base_dir, 'spec_files_exclude.txt'), wrap_in_regex=false
87
+ exclude_globs_only = exclude_these_specs.map { |f| f[:exclusion] }
88
+ files = FileList[
89
+ File.join(base_dir, 'require_specs.rb'), # need our code to go in first
90
+ *spec_glob
91
+ ].exclude(*exclude_globs_only)
92
+ missing_exclusions = exclude_these_specs.reject do |exclude|
93
+ FileList[exclude[:exclusion]].any?
94
+ end
95
+ if missing_exclusions.any?
96
+ raise "Expected to exclude #{missing_exclusions} as noted in spec_files_exclude.txt but we didn't find these files. Has RSpec been upgraded?"
97
+ end
98
+ files += post_requires.map { |r| File.join(base_dir, r) }
99
+ puts 'Running the following RSpec specs:'
100
+ files.each { |f| puts f }
101
+ files
102
+ end
103
+
104
+ def append_additional_load_paths(server)
105
+ baseline = ['spec/rspec/shared']
106
+ (baseline + additional_load_paths).each { |p| server.append_path p }
107
+ end
108
+
109
+ def replace_with_regex(regex, description, starting_file_set, files_to_replace)
110
+ fix_these_files = starting_file_set.select { |f| files_to_replace.any? { |r| r.match(f) } }
111
+ return starting_file_set unless fix_these_files.any?
112
+ dir = Dir.mktmpdir
113
+ missing = []
114
+ expressions = [*regex]
115
+ fixed_temp_files = fix_these_files.map do |path|
116
+ temp_filename = File.join dir, File.basename(path)
117
+ input = File.read path
118
+ matching = false
119
+ expressions.each do |r|
120
+ match = r.match input
121
+ if match
122
+ matching = true
123
+ input.gsub!(r) do |_|
124
+ yield Regexp.last_match, temp_filename
125
+ end
126
+ end
127
+ end
128
+ File.open temp_filename, 'w' do |output_file|
129
+ output_file.write input
130
+ end
131
+ missing << path unless matching
132
+ temp_filename
133
+ end
134
+ at_exit do
135
+ FileUtils.remove_entry dir
136
+ end
137
+ raise "Expected to #{description} in #{fix_these_files} but we didn't find any expressions in #{missing}. Check if RSpec has been upgraded" if missing.any?
138
+ files_we_left_alone = starting_file_set - fix_these_files
139
+ files_we_left_alone + fixed_temp_files
140
+ end
141
+
142
+ # https://github.com/opal/opal/issues/1125
143
+ def remove_multiline_regexes(files)
144
+ replace_with_regex /(%r%$.*%)$/m, 'fix multiline regex', files, files_with_multiline_regex do |match, temp_filename|
145
+ multi_line_regex = match
146
+ .captures[0]
147
+ .gsub("\n", '')
148
+ parsed = instance_eval multi_line_regex # can just have ruby do this for us
149
+ escaped = parsed
150
+ .source
151
+ .gsub('/', '\/')
152
+ replace = "/#{escaped}/m"
153
+ puts "Replacing multiline regex with #{replace} in new temp file #{temp_filename}"
154
+ replace
155
+ end
156
+ end
157
+
158
+ def sub_in_files
159
+ files = get_file_list
160
+ with_sub = sub_in_end_of_line files
161
+ remove_multiline_regexes with_sub
162
+ end
163
+
164
+ # https://github.com/opal/opal/issues/821
165
+ def sub_in_end_of_line(files)
166
+ bad_regex = /^(.*)\\$/
167
+ fix_these_files = files.select { |f| files_with_line_continue.any? { |regex| regex.match(f) } }
168
+ return files unless fix_these_files.any?
169
+ dir = Dir.mktmpdir
170
+ missing = []
171
+ fixed_temp_files = fix_these_files.map do |path|
172
+ temp_filename = File.join dir, File.basename(path)
173
+ found_blackslash = false
174
+ File.open path, 'r' do |input_file|
175
+ File.open temp_filename, 'w' do |output_file|
176
+ fixed_lines = input_file.inject do |line1, line2|
177
+ existing_lines = [*line1]
178
+ if (a_match = bad_regex.match existing_lines.last)
179
+ found_blackslash = true
180
+ line_num = existing_lines.length
181
+ puts "Replacing trailing backlash, line #{line_num} in #{path} in new temp file #{temp_filename}"
182
+ without_last_line = existing_lines[0..-2]
183
+ without_backlash = a_match.captures[0]
184
+ without_last_line << (without_backlash + ' ' + line2)
185
+ else
186
+ existing_lines << line2
187
+ end
188
+ end
189
+ fixed_lines.each { |l| output_file << l }
190
+ end
191
+ end
192
+ missing << path unless found_blackslash
193
+ temp_filename
194
+ end
195
+ at_exit do
196
+ FileUtils.remove_entry dir
197
+ end
198
+ raise "Expected to fix blackslash continuation in #{fix_these_files} but we didn't find any backslashes in #{missing}. Check if RSpec has been upgraded (maybe those blackslashes are gone??)" if missing.any?
199
+ files_we_left_alone = files - fix_these_files
200
+ files_we_left_alone + fixed_temp_files
201
+ end
202
+
203
+ def execute_specs(name)
204
+ command_line = "SPEC_OPTS=\"--format Opal::RSpec::ProgressJsonFormatter\" rake #{name}"
205
+ puts "Running #{command_line}"
206
+ example_info = []
207
+ state = :progress
208
+ IO.popen(command_line).each do |line|
209
+ line.force_encoding 'UTF-8'
210
+ case state
211
+ when :progress
212
+ puts line
213
+ when :example_info
214
+ example_info << line
215
+ end
216
+ state = case line
217
+ when /BEGIN JSON/
218
+ :example_info
219
+ else
220
+ state
221
+ end
222
+ end.close
223
+ {
224
+ example_info: example_info,
225
+ success: $?.success?
226
+ }
227
+ end
228
+
229
+ def parse_results(results)
230
+ JSON.parse results[:example_info].join("\n")
231
+ end
232
+
233
+ def rake_tasks_for(name)
234
+ Opal::RSpec::RakeTask.new(name) do |server, task|
235
+ # A lot of specs, can take longer on slower machines
236
+ task.timeout = 80000
237
+ stub_requires
238
+ task.files = sub_in_files
239
+ append_additional_load_paths server
240
+ server.debug = ENV['OPAL_DEBUG']
241
+ end
242
+
243
+ desc "Verifies that #{name} work correctly"
244
+ task "verify_#{name}" do
245
+ results = execute_specs name
246
+ parsed_results = parse_results results
247
+ summary = parsed_results['summary']
248
+ total = summary['example_count']
249
+ failed = summary['failure_count']
250
+ pending = summary['pending_count']
251
+ actual_failures = parsed_results['examples']
252
+ .select { |ex| ex['status'] == 'failed' }
253
+ expected_failures = get_ignored_spec_failures
254
+ used_exclusions = []
255
+ remaining_failures = actual_failures.reject do |actual|
256
+ expected_failures.any? do |expected|
257
+ exclusion = expected[:exclusion]
258
+ actual_descr = actual['full_description']
259
+ matches = case exclusion
260
+ when Regexp
261
+ exclusion.match actual_descr
262
+ when String
263
+ exclusion == actual_descr
264
+ else
265
+ raise "Unknown filter expression type #{exclusion.class} in #{expected}!"
266
+ end
267
+ used_exclusions << expected if matches
268
+ matches
269
+ end
270
+ end
271
+ each_header = '----------------------------------------------------'
272
+ index = 0
273
+ remaining_failures = remaining_failures.map do |example|
274
+ index += 1
275
+ [
276
+ each_header,
277
+ "Example #{index}: #{example['full_description']}",
278
+ each_header,
279
+ example['exception']['message']
280
+ ].join "\n"
281
+ end
282
+ reasons = []
283
+ unless remaining_failures.empty?
284
+ reasons << 'Unexpected failures'
285
+ end
286
+ reasons << "Expected #{expected_pending_count} pending but got #{pending}" unless pending == expected_pending_count
287
+ reasons << 'no specs found' unless total > 0
288
+ reasons << 'No failures, but Rake task did not succeed' if (failed == 0 && !results[:success])
289
+ unused_exclusions = expected_failures.uniq - used_exclusions.uniq
290
+ if unused_exclusions.any?
291
+ msg = "WARNING: The following #{unused_exclusions.length} exclusion rules did not match an actual failure. Time to update exclusions? Duplicate exclusions??\n" +
292
+ unused_exclusions.map { |e| "File: #{e[:filename]}\nLine #{e[:line_number]}\nFilter: #{e[:exclusion]}" }.join("\n---------------------\n")
293
+ reasons << msg
294
+ end
295
+ if reasons.empty?
296
+ puts 'Test successful!'
297
+ puts "#{total} total specs, #{failed} expected failures, #{pending} expected pending"
298
+ else
299
+ puts "Test FAILED for the following reasons:\n"
300
+ puts reasons.join "\n\n"
301
+ if remaining_failures.any?
302
+ puts
303
+ puts "Unexpected failures:\n\n#{remaining_failures.join("\n")}\n"
304
+ end
305
+ puts '-----------Summary-----------'
306
+ puts "Total passed count: #{total - failed - pending}"
307
+ puts "Pending count #{pending}"
308
+ puts "Total 'failure' count: #{actual_failures.length}"
309
+ puts "Unexpected failure count: #{remaining_failures.length}"
310
+ raise 'Test failed!'
311
+ end
312
+ end
313
+ end
314
+
315
+ def run_rack_server(rack)
316
+ Opal::Processor.source_map_enabled = false
317
+
318
+ files = sub_in_files
319
+ sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern=nil, spec_exclude_pattern=nil, spec_files=files)
320
+ rack.run Opal::Server.new(sprockets: sprockets_env) { |s|
321
+ s.main = 'opal/rspec/sprockets_runner'
322
+ stub_requires
323
+ sprockets_env.add_spec_paths_to_sprockets
324
+ append_additional_load_paths s
325
+ s.debug = ENV['OPAL_DEBUG']
326
+ }
327
+ end
328
+
329
+ private
330
+
331
+ def get_compact_text_expressions(filename, wrap_in_regex)
332
+ line_num = 0
333
+ File.read(filename).split("\n").map do |line|
334
+ line_num += 1
335
+ {
336
+ exclusion: line,
337
+ filename: filename,
338
+ line_number: line_num
339
+ }
340
+ end.reject do |line|
341
+ exclusion = line[:exclusion]
342
+ exclusion.empty? or exclusion.start_with? '#'
343
+ end.map do |filter|
344
+ wrap_in_regex ? filter.merge({exclusion: Regexp.new(filter[:exclusion])}) : filter
345
+ end
346
+ end
347
+ end
348
+ end
349
+ end