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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +23 -4
- data/CHANGELOG.md +22 -1
- data/Gemfile +10 -3
- data/README.md +142 -36
- data/Rakefile +101 -75
- data/config.ru +8 -6
- data/gemfiles/opal_master.gemfile +18 -0
- data/lib/opal/rspec.rb +6 -10
- data/lib/opal/rspec/cached_environment.rb +23 -0
- data/lib/opal/rspec/post_rack_locator.rb +20 -0
- data/lib/opal/rspec/pre_rack_locator.rb +68 -0
- data/lib/opal/rspec/rake_task.rb +97 -20
- data/lib/opal/rspec/sprockets_environment.rb +35 -0
- data/lib/opal/rspec/version.rb +1 -1
- data/opal-rspec.gemspec +9 -12
- data/opal/opal/rspec.rb +11 -8
- data/opal/opal/rspec/async.rb +1 -0
- data/opal/opal/rspec/async/async_example.rb +27 -18
- data/opal/opal/rspec/async/example_group.rb +23 -21
- data/opal/opal/rspec/async/hooks.rb +0 -36
- data/opal/opal/rspec/async/reporter.rb +9 -0
- data/opal/opal/rspec/fixes.rb +3 -10
- data/opal/opal/rspec/fixes/opal.rb +5 -0
- data/opal/opal/rspec/fixes/opal/class.rb +8 -0
- data/opal/opal/rspec/fixes/opal/compatibility.rb +228 -0
- data/opal/opal/rspec/fixes/opal/corelib.rb +3 -0
- data/opal/opal/rspec/fixes/opal/corelib/error.rb +61 -0
- data/opal/opal/rspec/fixes/opal/corelib/regexp.rb +92 -0
- data/opal/opal/rspec/fixes/opal/corelib/struct.rb +260 -0
- data/opal/opal/rspec/fixes/opal/kernel.rb +80 -0
- data/opal/opal/rspec/fixes/opal/stdlib.rb +2 -0
- data/opal/opal/rspec/fixes/opal/stdlib/pp.rb +23 -0
- data/opal/opal/rspec/fixes/opal/stdlib/set.rb +36 -0
- data/opal/opal/rspec/fixes/rspec.rb +7 -0
- data/opal/opal/rspec/fixes/{caller_filter.rb → rspec/caller_filter.rb} +0 -0
- data/opal/opal/rspec/fixes/rspec/core.rb +9 -0
- data/opal/opal/rspec/fixes/rspec/core/configuration.rb +11 -0
- data/opal/opal/rspec/fixes/{example.rb → rspec/core/example.rb} +1 -1
- data/opal/opal/rspec/fixes/rspec/core/example_group.rb +9 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters.rb +6 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/backtrace_formatter.rb +20 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/console_codes.rb +11 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/deprecation_formatter.rb +20 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/generated_deprecation_message.rb +15 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/json_formatter.rb +10 -0
- data/opal/opal/rspec/fixes/rspec/core/formatters/loader.rb +38 -0
- data/opal/opal/rspec/fixes/rspec/core/metadata.rb +39 -0
- data/opal/opal/rspec/fixes/rspec/core/notifications.rb +3 -0
- data/opal/opal/rspec/fixes/rspec/core/notifications/examples_notification.rb +30 -0
- data/opal/opal/rspec/fixes/rspec/core/notifications/failed_example_notification.rb +20 -0
- data/opal/opal/rspec/fixes/rspec/core/notifications/summary_notification.rb +26 -0
- data/opal/opal/rspec/fixes/rspec/core/ordering.rb +1 -0
- data/opal/opal/rspec/fixes/rspec/core/ordering/random.rb +13 -0
- data/opal/opal/rspec/fixes/rspec/core/reporter.rb +14 -0
- data/opal/opal/rspec/fixes/rspec/core/warnings.rb +18 -0
- data/opal/opal/rspec/fixes/rspec/example_groups.rb +49 -0
- data/opal/opal/rspec/fixes/rspec/expectations.rb +2 -0
- data/opal/opal/rspec/fixes/{expectations.rb → rspec/expectations/fail_with.rb} +0 -0
- data/opal/opal/rspec/fixes/rspec/expectations/syntax.rb +25 -0
- data/opal/opal/rspec/fixes/rspec/matchers.rb +2 -0
- data/opal/opal/rspec/fixes/rspec/matchers/built_in.rb +4 -0
- data/opal/opal/rspec/fixes/rspec/matchers/built_in/all.rb +10 -0
- data/opal/opal/rspec/fixes/rspec/matchers/built_in/compound.rb +15 -0
- data/opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb +42 -0
- data/opal/opal/rspec/fixes/rspec/matchers/built_in/yield.rb +21 -0
- data/opal/opal/rspec/fixes/{matchers.rb → rspec/matchers/pretty.rb} +0 -0
- data/opal/opal/rspec/fixes/rspec/mocks.rb +4 -0
- data/opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +40 -0
- data/opal/opal/rspec/fixes/rspec/mocks/space.rb +37 -0
- data/opal/opal/rspec/fixes/rspec/mocks/test_double.rb +39 -0
- data/opal/opal/rspec/fixes/rspec/mocks/verifying_double.rb +29 -0
- data/opal/opal/rspec/fixes/rspec/support.rb +4 -0
- data/opal/opal/rspec/fixes/rspec/support/encoded_string.rb +10 -0
- data/opal/opal/rspec/fixes/rspec/support/fuzzy_matcher.rb +23 -0
- data/opal/opal/rspec/fixes/rspec/support/recursive_const_methods.rb +7 -0
- data/opal/opal/rspec/fixes/rspec/support/ruby_features.rb +8 -0
- data/opal/opal/rspec/fixes/rspec/support/warnings.rb +18 -0
- data/opal/opal/rspec/formatter/browser_formatter.rb +38 -0
- data/opal/opal/rspec/formatter/document_io.rb +27 -0
- data/opal/opal/rspec/formatter/element.rb +88 -0
- data/opal/opal/rspec/formatter/html_printer.rb +109 -0
- data/opal/opal/rspec/formatter/noop_flush_string_io.rb +9 -0
- data/opal/opal/rspec/formatter/opal_closed_tty_io.rb +27 -0
- data/opal/opal/rspec/pre_require_fixes.rb +7 -0
- data/opal/opal/rspec/requires.rb +32 -0
- data/opal/opal/rspec/runner.rb +71 -53
- data/opal/opal/rspec/spec_opts.rb.erb +28 -0
- data/opal/opal/rspec/sprockets_runner.rb.erb +5 -3
- data/spec/mri/integration/browser_spec.rb +31 -0
- data/spec/mri/integration/rack/sprockets_runner_js_errors.rb.erb +20 -0
- data/spec/mri/integration/spec_opts_spec.rb +81 -0
- data/spec/mri/unit/opal/rspec/browser_formatter_spec.rb +35 -0
- data/spec/mri/unit/opal/rspec/cached_environment_spec.rb +103 -0
- data/spec/mri/unit/opal/rspec/opal/browser_formatter_spec.rb +14 -0
- data/spec/mri/unit/opal/rspec/rack/config.ru +12 -0
- data/spec/mri/unit/opal/rspec/rake_task_spec.rb +245 -0
- data/spec/mri/unit/opal/rspec/sprockets_environment_spec.rb +94 -0
- data/spec/mri/unit/opal/rspec/temp_dir_helper.rb +19 -0
- data/spec/{after_hooks_spec.rb → opal/after_hooks_spec.rb} +0 -0
- data/spec/{around_hooks_spec.rb → opal/around_hooks_spec.rb} +46 -105
- data/spec/{async_spec.rb → opal/async_spec.rb} +0 -0
- data/spec/{before_hooks_spec.rb → opal/before_hooks_spec.rb} +0 -0
- data/spec/{example_spec.rb → opal/example_spec.rb} +0 -0
- data/spec/opal/expected_failures.txt +40 -0
- data/spec/{matchers_spec.rb → opal/matchers_spec.rb} +0 -0
- data/spec/{mock_spec.rb → opal/mock_spec.rb} +0 -0
- data/spec/{should_syntax_spec.rb → opal/should_syntax_spec.rb} +0 -0
- data/spec/{skip_pending_spec.rb → opal/skip_pending_spec.rb} +0 -0
- data/spec/{subject_spec.rb → opal/subject_spec.rb} +16 -16
- data/spec/other/color_on_by_default_spec.rb +9 -0
- data/spec/other/dummy_spec.rb +5 -0
- data/spec/other/formatter_dependency.rb +3 -0
- data/spec/other/ignored_spec.opal +5 -0
- data/spec/other/test_formatter.rb +9 -0
- data/spec/rspec/core/config.rb +5 -0
- data/spec/rspec/core/config.ru +4 -0
- data/spec/rspec/core/core_spec_loader.rb +42 -0
- data/spec/rspec/core/filter/core/async/example_group.txt +13 -0
- data/spec/rspec/core/filter/core/async/hooks.rb +12 -0
- data/spec/rspec/core/filter/core/async/memoized_helpers.txt +3 -0
- data/spec/rspec/core/filter/core/async/metadata.txt +2 -0
- data/spec/rspec/core/filter/core/bugs/filter_manager.txt +4 -0
- data/spec/rspec/core/filter/core/bugs/formatters.txt +4 -0
- data/spec/rspec/core/filter/core/bugs/memoized_helpers.rb +11 -0
- data/spec/rspec/core/filter/core/bugs/metadata.txt +5 -0
- data/spec/rspec/core/filter/core/bugs/sandbox/subject_issue_test.rb +328 -0
- data/spec/rspec/core/filter/core/bugs/warnings_deprecations.txt +3 -0
- data/spec/rspec/core/filter/core/unsupported/core.txt +5 -0
- data/spec/rspec/core/filter/core/unsupported/example.txt +7 -0
- data/spec/rspec/core/filter/core/unsupported/example_group.txt +13 -0
- data/spec/rspec/core/filter/core/unsupported/filter_manager.txt +7 -0
- data/spec/rspec/core/filter/core/unsupported/formatters.txt +27 -0
- data/spec/rspec/core/filter/core/unsupported/hooks.txt +2 -0
- data/spec/rspec/core/filter/core/unsupported/memoized_helpers.txt +6 -0
- data/spec/rspec/core/filter/core/unsupported/metadata.txt +14 -0
- data/spec/rspec/core/filter/core/unsupported/metadata_filter.txt +2 -0
- data/spec/rspec/core/filter/core/unsupported/notifications.txt +8 -0
- data/spec/rspec/core/filter/core/unsupported/world.txt +3 -0
- data/spec/rspec/core/fixes/missing_constants.rb +20 -0
- data/spec/rspec/core/fixes/opal_itself.rb +38 -0
- data/spec/rspec/core/fixes/shared_examples.rb +3 -0
- data/spec/rspec/core/opal_alternates/rspec/core/example_group_spec.rb +145 -0
- data/spec/rspec/core/opal_alternates/rspec/core/failed_example_notification_spec.rb +31 -0
- data/spec/rspec/core/opal_alternates/rspec/core/hooks_spec.rb +113 -0
- data/spec/rspec/core/opal_alternates/rspec/core/memoized_helpers_spec.rb +36 -0
- data/spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb +48 -0
- data/spec/rspec/core/require_specs.rb +25 -0
- data/spec/rspec/core/sandboxing.rb +72 -0
- data/spec/rspec/core/spec_files_exclude.txt +41 -0
- data/spec/rspec/expectations/config.rb +16 -0
- data/spec/rspec/expectations/config.ru +4 -0
- data/spec/rspec/expectations/expectation_spec_loader.rb +106 -0
- data/spec/rspec/expectations/filter/bugs/aliased_matcher.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/aliases.rb +13 -0
- data/spec/rspec/expectations/filter/bugs/base_matcher.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/be.rb +4 -0
- data/spec/rspec/expectations/filter/bugs/be_instance_of.rb +7 -0
- data/spec/rspec/expectations/filter/bugs/be_spec.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/configuration.txt +8 -0
- data/spec/rspec/expectations/filter/bugs/contain_exactly.rb +13 -0
- data/spec/rspec/expectations/filter/bugs/define_negated_matcher.rb +9 -0
- data/spec/rspec/expectations/filter/bugs/description_generation.rb +4 -0
- data/spec/rspec/expectations/filter/bugs/dsl.txt +14 -0
- data/spec/rspec/expectations/filter/bugs/equal.txt +3 -0
- data/spec/rspec/expectations/filter/bugs/expectation_target.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/expectations.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/have_attributes.rb +8 -0
- data/spec/rspec/expectations/filter/bugs/include.rb +4 -0
- data/spec/rspec/expectations/filter/bugs/operators.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/raise_error.txt +2 -0
- data/spec/rspec/expectations/filter/bugs/respond_to.rb +13 -0
- data/spec/rspec/expectations/filter/bugs/sandbox/undef.rb +20 -0
- data/spec/rspec/expectations/filter/unsupported/aliases.txt +5 -0
- data/spec/rspec/expectations/filter/unsupported/be.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/be_instance_of.txt +3 -0
- data/spec/rspec/expectations/filter/unsupported/change.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/configuration.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/contain_exactly.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/description_generation.txt +6 -0
- data/spec/rspec/expectations/filter/unsupported/dsl.txt +8 -0
- data/spec/rspec/expectations/filter/unsupported/eq.txt +10 -0
- data/spec/rspec/expectations/filter/unsupported/equal.txt +3 -0
- data/spec/rspec/expectations/filter/unsupported/expectation_target.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/expectations.txt +8 -0
- data/spec/rspec/expectations/filter/unsupported/has.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/include.txt +3 -0
- data/spec/rspec/expectations/filter/unsupported/match.txt +2 -0
- data/spec/rspec/expectations/filter/unsupported/matchers.txt +11 -0
- data/spec/rspec/expectations/filter/unsupported/output.txt +14 -0
- data/spec/rspec/expectations/filter/unsupported/raise_error.txt +3 -0
- data/spec/rspec/expectations/filter/unsupported/respond_to.rb +5 -0
- data/spec/rspec/expectations/filter/unsupported/syntax.txt +3 -0
- data/spec/rspec/expectations/filter/unsupported/yield.txt +2 -0
- data/spec/rspec/expectations/fixes/example_patches.rb +32 -0
- data/spec/rspec/expectations/fixes/missing_constants.rb +12 -0
- data/spec/rspec/expectations/fixes/not_compatible.rb +6 -0
- data/spec/rspec/expectations/fixes/opal_itself.rb +140 -0
- data/spec/rspec/expectations/opal_alternates/be_instance_of_spec.rb +11 -0
- data/spec/rspec/expectations/opal_alternates/dsl_spec.rb +66 -0
- data/spec/rspec/expectations/opal_alternates/expectation_target_spec.rb +21 -0
- data/spec/rspec/expectations/opal_alternates/yield_spec.rb +11 -0
- data/spec/rspec/expectations/require_specs.rb +16 -0
- data/spec/rspec/expectations/shared_examples.rb +47 -0
- data/spec/rspec/expectations/spec_files_exclude.txt +2 -0
- data/spec/rspec/expectations/spec_helper_opal.rb +13 -0
- data/spec/rspec/filter_processor.rb +77 -0
- data/spec/rspec/mocks/config.ru +4 -0
- data/spec/rspec/mocks/filter/bugs/and_call_original.txt +9 -0
- data/spec/rspec/mocks/filter/bugs/and_wrap_original.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/any_instance.rb +24 -0
- data/spec/rspec/mocks/filter/bugs/argument_matchers.rb +3 -0
- data/spec/rspec/mocks/filter/bugs/configuration.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/double.txt +3 -0
- data/spec/rspec/mocks/filter/bugs/expiration.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/instance_method_stasher.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/methods.rb +5 -0
- data/spec/rspec/mocks/filter/bugs/mocks.txt +6 -0
- data/spec/rspec/mocks/filter/bugs/mutate_const.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/partial_double.rb +8 -0
- data/spec/rspec/mocks/filter/bugs/receive.txt +5 -0
- data/spec/rspec/mocks/filter/bugs/should_syntax.txt +5 -0
- data/spec/rspec/mocks/filter/bugs/space.txt +2 -0
- data/spec/rspec/mocks/filter/bugs/spy.txt +5 -0
- data/spec/rspec/mocks/filter/bugs/stub_implementation.rb +9 -0
- data/spec/rspec/mocks/filter/unsupported/and_call_original.txt +5 -0
- data/spec/rspec/mocks/filter/unsupported/and_return.txt +2 -0
- data/spec/rspec/mocks/filter/unsupported/any_instance.rb +6 -0
- data/spec/rspec/mocks/filter/unsupported/argument_matchers.rb +10 -0
- data/spec/rspec/mocks/filter/unsupported/combining_implementation_instructions.rb +9 -0
- data/spec/rspec/mocks/filter/unsupported/double.rb +16 -0
- data/spec/rspec/mocks/filter/unsupported/expected_arg_verification.txt +2 -0
- data/spec/rspec/mocks/filter/unsupported/have_received.txt +2 -0
- data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.txt +8 -0
- data/spec/rspec/mocks/filter/unsupported/mocks.rb +8 -0
- data/spec/rspec/mocks/filter/unsupported/nil_expectation_warning.rb +8 -0
- data/spec/rspec/mocks/filter/unsupported/partial_double.rb +6 -0
- data/spec/rspec/mocks/filter/unsupported/receive.txt +13 -0
- data/spec/rspec/mocks/filter/unsupported/receive_message_chain.rb +4 -0
- data/spec/rspec/mocks/filter/unsupported/receive_messages.txt +2 -0
- data/spec/rspec/mocks/filter/unsupported/should_syntax.txt +1 -0
- data/spec/rspec/mocks/filter/unsupported/space.rb +7 -0
- data/spec/rspec/mocks/filter/unsupported/stub.rb +7 -0
- data/spec/rspec/mocks/fixes/doubled_classes.rb +76 -0
- data/spec/rspec/mocks/fixes/missing_constants.rb +3 -0
- data/spec/rspec/mocks/fixes/opal_itself.rb +59 -0
- data/spec/rspec/mocks/mocks_spec_loader.rb +87 -0
- data/spec/rspec/mocks/require_specs.rb +15 -0
- data/spec/rspec/mocks/spec_files_exclude.txt +11 -0
- data/spec/rspec/mocks/spec_helper_opal.rb +129 -0
- data/spec/rspec/opal_rspec_spec_loader.rb +349 -0
- data/spec/rspec/shared/opal/fixes/deprecation_helpers.rb +31 -0
- data/spec/rspec/shared/opal/fixes/rspec_helpers.rb +6 -0
- data/spec/rspec/shared/opal/progress_json_formatter.rb +29 -0
- data/spec/rspec/support/config.rb +5 -0
- data/spec/rspec/support/config.ru +4 -0
- data/spec/rspec/support/filter/bugs/recursive_const_methods.txt +3 -0
- data/spec/rspec/support/filter/bugs/sandbox/basic_object.rb +30 -0
- data/spec/rspec/support/filter/bugs/stderr_splitter_spec.txt +2 -0
- data/spec/rspec/support/filter/bugs/support.txt +2 -0
- data/spec/rspec/support/filter/unsupported/fuzzy_matcher.txt +2 -0
- data/spec/rspec/support/filter/unsupported/support.rb +7 -0
- data/spec/rspec/support/filter/unsupported/warnings.txt +6 -0
- data/spec/rspec/support/fixes/missing_constants.rb +3 -0
- data/spec/rspec/support/fixes/opal_itself.rb +13 -0
- data/spec/rspec/support/require_specs.rb +15 -0
- data/spec/rspec/support/spec_files_exclude.txt +26 -0
- data/spec/rspec/support/spec_helper.rb +27 -0
- data/spec/rspec/support/support_spec_loader.rb +34 -0
- data/util/create_requires.rb +6 -2
- data/vendor/spec_runner.js +14 -0
- metadata +255 -43
- data/opal/opal/rspec/browser_formatter.rb +0 -225
- data/opal/opal/rspec/fixes/example_groups.rb +0 -32
- data/opal/opal/rspec/fixes/formatter.rb +0 -62
- data/opal/opal/rspec/fixes/kernel.rb +0 -48
- data/opal/opal/rspec/fixes/mocks.rb +0 -13
- data/opal/opal/rspec/fixes/reporter.rb +0 -12
- data/opal/opal/rspec/text_formatter.rb +0 -88
- data/spec_mri/integration/browser_spec.rb +0 -37
data/opal/opal/rspec/async.rb
CHANGED
@@ -1,37 +1,44 @@
|
|
1
|
-
class ::RSpec::Core::Example
|
1
|
+
class ::RSpec::Core::Example
|
2
2
|
def core_block_run
|
3
3
|
example_promise = Promise.value(@example_group_instance.instance_exec(self, &@example_block))
|
4
4
|
example_promise.then do |result|
|
5
|
-
result
|
5
|
+
result
|
6
6
|
end.rescue do |ex|
|
7
7
|
ex ||= Exception.new 'Async promise failed for unspecified reason'
|
8
8
|
ex = Exception.new ex unless ex.kind_of?(Exception)
|
9
9
|
ex
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
|
+
# TODO: Use subject! to create a before hook on the fly, might be cleaner than this
|
14
|
+
# Might be a better way to do this, but then you end up with promises around the expectation handlers, which could get ugly
|
13
15
|
def resolve_subject
|
14
|
-
|
15
|
-
example_group_instance.subject
|
16
|
-
|
17
|
-
|
16
|
+
begin
|
17
|
+
subj = example_group_instance.subject
|
18
|
+
if subj.is_a? Promise
|
19
|
+
return subj.then do |resolved_subject|
|
20
|
+
# This is a private method, but we're using Opal
|
21
|
+
example_group_instance.__memoized[:subject] = resolved_subject
|
22
|
+
end
|
18
23
|
end
|
19
|
-
|
20
|
-
|
24
|
+
rescue
|
25
|
+
# Exception occurred while checking the subject, might be that the example group had a described class, was not intending on using it as the subject,
|
26
|
+
# and the initializer for that described class failed
|
21
27
|
end
|
28
|
+
Promise.value
|
22
29
|
end
|
23
|
-
|
30
|
+
|
24
31
|
def run_after_example
|
25
32
|
@example_group_class.hooks.run(:after, :example, self).then do
|
26
33
|
verify_mocks
|
27
|
-
assign_generated_description if RSpec.configuration.expecting_with_rspec?
|
34
|
+
assign_generated_description if RSpec.configuration.expecting_with_rspec?
|
28
35
|
end.rescue do |e|
|
29
36
|
set_exception(e, "in an `after(:example)` hook")
|
30
37
|
end.ensure do
|
31
38
|
@example_group_instance.teardown_mocks_for_rspec
|
32
|
-
end
|
39
|
+
end
|
33
40
|
end
|
34
|
-
|
41
|
+
|
35
42
|
def run(example_group_instance, reporter)
|
36
43
|
@example_group_instance = example_group_instance
|
37
44
|
RSpec.current_example = self
|
@@ -61,13 +68,13 @@ class ::RSpec::Core::Example
|
|
61
68
|
end
|
62
69
|
end.rescue do |e|
|
63
70
|
# no-op, required metadata has already been set by the `skip`
|
64
|
-
# method.
|
71
|
+
# method.
|
65
72
|
unless e.is_a? Pending::SkipDeclaredInExample
|
66
73
|
set_exception(e)
|
67
74
|
end
|
68
75
|
end.ensure do
|
69
76
|
run_after_example
|
70
|
-
end
|
77
|
+
end
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end.rescue do |e|
|
@@ -77,11 +84,13 @@ class ::RSpec::Core::Example
|
|
77
84
|
@example_group_instance.instance_variable_set(ivar, nil)
|
78
85
|
end
|
79
86
|
@example_group_instance = nil
|
80
|
-
end
|
87
|
+
end
|
81
88
|
end.then do
|
82
89
|
finish(reporter)
|
83
|
-
end.ensure do
|
90
|
+
end.ensure do |result|
|
84
91
|
RSpec.current_example = nil
|
92
|
+
# promise always/ensure do not behave exactly like ensure, need to be explicit about value being returned
|
93
|
+
result
|
85
94
|
end
|
86
|
-
end
|
95
|
+
end
|
87
96
|
end
|
@@ -5,32 +5,31 @@ class ::RSpec::Core::ExampleGroup
|
|
5
5
|
def delay(duration, &block)
|
6
6
|
`setTimeout(block, duration * 1000)`
|
7
7
|
self
|
8
|
-
end
|
9
|
-
|
8
|
+
end
|
9
|
+
|
10
10
|
def delay_with_promise(duration, &block)
|
11
11
|
result = Promise.new
|
12
12
|
delay(duration) { result.resolve }
|
13
13
|
result.then &block
|
14
|
-
end
|
14
|
+
end
|
15
15
|
|
16
16
|
def self.process_descendants(our_examples_result, reporter)
|
17
17
|
descendants = ordering_strategy.order(children)
|
18
|
-
return Promise.value our_examples_result if descendants.empty?
|
19
|
-
|
18
|
+
return Promise.value our_examples_result if descendants.empty?
|
19
|
+
|
20
20
|
results_for_descendants = []
|
21
21
|
# Can use true for this because we're AND'ing everything anyways
|
22
22
|
seed = Promise.value(true)
|
23
23
|
latest_descendant = descendants.inject(seed) do |previous_promise, next_descendant|
|
24
24
|
previous_promise.then do |result|
|
25
25
|
results_for_descendants << result
|
26
|
-
next_descendant.run reporter
|
26
|
+
next_descendant.run reporter
|
27
27
|
end
|
28
28
|
end
|
29
29
|
latest_descendant.then do |result|
|
30
30
|
results_for_descendants << result
|
31
|
-
|
32
|
-
|
33
|
-
end
|
31
|
+
our_examples_result && results_for_descendants.all?
|
32
|
+
end
|
34
33
|
end
|
35
34
|
|
36
35
|
# Promise oriented version
|
@@ -39,8 +38,8 @@ class ::RSpec::Core::ExampleGroup
|
|
39
38
|
RSpec.world.clear_remaining_example_groups if top_level?
|
40
39
|
return
|
41
40
|
end
|
42
|
-
|
43
|
-
reporter.example_group_started(self)
|
41
|
+
|
42
|
+
reporter.example_group_started(self)
|
44
43
|
Promise.value.then do
|
45
44
|
run_before_context_hooks(new)
|
46
45
|
end.then do
|
@@ -49,37 +48,40 @@ class ::RSpec::Core::ExampleGroup
|
|
49
48
|
process_descendants(our_examples_result, reporter)
|
50
49
|
end.rescue do |ex|
|
51
50
|
result = if ex.is_a? Pending::SkipDeclaredInExample
|
52
|
-
for_filtered_examples(reporter) { |example| example.skip_with_exception(reporter, ex) }
|
51
|
+
for_filtered_examples(reporter) { |example| example.skip_with_exception(reporter, ex) }
|
53
52
|
else
|
54
53
|
RSpec.world.wants_to_quit = true if fail_fast?
|
55
54
|
for_filtered_examples(reporter) { |example| example.fail_with_exception(reporter, ex) }
|
56
55
|
end
|
57
56
|
result
|
58
|
-
end.always do
|
57
|
+
end.always do |result|
|
59
58
|
run_after_context_hooks(new)
|
60
59
|
before_context_ivars.clear
|
61
60
|
reporter.example_group_finished(self)
|
61
|
+
# promise always do not behave exactly like ensure, need to be explicit about value being returned
|
62
|
+
result
|
62
63
|
end
|
63
64
|
end
|
64
|
-
|
65
|
+
|
65
66
|
# Promise oriented version
|
66
|
-
def self.run_examples(reporter)
|
67
|
+
def self.run_examples(reporter)
|
67
68
|
examples = ordering_strategy.order(filtered_examples)
|
68
|
-
return Promise.value true if examples.empty?
|
69
|
+
return Promise.value true if examples.empty?
|
69
70
|
|
70
71
|
example_promise = lambda do |example|
|
72
|
+
next Promise.value(nil) if RSpec.world.wants_to_quit
|
71
73
|
instance = new
|
72
74
|
set_ivars(instance, before_context_ivars)
|
73
75
|
# Always returns a promise since we modified the Example class
|
74
|
-
example.run(instance, reporter)
|
75
|
-
end
|
76
|
-
|
76
|
+
example.run(instance, reporter)
|
77
|
+
end
|
78
|
+
|
77
79
|
results = []
|
78
80
|
# Can use true for this because we're AND'ing everything anyways
|
79
81
|
seed = Promise.value true
|
80
|
-
latest_promise = examples.inject(seed) do |previous_promise, next_example|
|
82
|
+
latest_promise = examples.inject(seed) do |previous_promise, next_example|
|
81
83
|
previous_promise.then do |succeeded|
|
82
|
-
RSpec.world.wants_to_quit = true if fail_fast? && !succeeded
|
84
|
+
RSpec.world.wants_to_quit = true if fail_fast? && !succeeded
|
83
85
|
results << succeeded
|
84
86
|
example_promise[next_example]
|
85
87
|
end
|
@@ -8,39 +8,3 @@ class RSpec::Core::Hooks::HookCollection
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
12
|
-
# Need to be able to work with a promise, but without modifying proxy, we can't get a promise back from our around hook
|
13
|
-
# therefore, modify this so that we pass a promise in
|
14
|
-
class RSpec::Core::Hooks::AroundHook
|
15
|
-
def execute_with_promise(use_promise, example, procsy)
|
16
|
-
Promise.value(example.instance_exec(procsy, &block)).then do
|
17
|
-
unless procsy.executed?
|
18
|
-
Pending.mark_skipped!(example, "#{hook_description} did not execute the example")
|
19
|
-
end
|
20
|
-
use_promise.resolve
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# This is an odd one because of the way around hooks subclass themselves. We mirror the original code, we just carry
|
26
|
-
# around a promise with the procsy
|
27
|
-
class RSpec::Core::Hooks::AroundHookCollection
|
28
|
-
def run
|
29
|
-
seed = [@initial_procsy, Promise.value]
|
30
|
-
last_procsy, last_promise = hooks.inject(seed) do |procsy_and_around_hook_promise, around_hook|
|
31
|
-
procsy, previous_hook_promise = procsy_and_around_hook_promise
|
32
|
-
new_hook_promise = Promise.new
|
33
|
-
new_procsy = procsy.wrap do
|
34
|
-
previous_hook_promise.then do
|
35
|
-
around_hook.execute_with_promise new_hook_promise, @example, procsy
|
36
|
-
end.rescue do |ex|
|
37
|
-
# because of the way Procsy works, we need to set this here and not in the execute_with_promise method
|
38
|
-
new_hook_promise.reject ex
|
39
|
-
end
|
40
|
-
end
|
41
|
-
[new_procsy, new_hook_promise]
|
42
|
-
end
|
43
|
-
last_procsy.call
|
44
|
-
last_promise
|
45
|
-
end
|
46
|
-
end
|
data/opal/opal/rspec/fixes.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
require 'encoding'
|
1
|
+
require 'encoding' unless Object.const_defined? :Encoding
|
2
2
|
# Thread usage in core.rb
|
3
3
|
require 'thread'
|
4
|
-
|
5
|
-
|
6
|
-
require 'opal/rspec/fixes/example_groups'
|
7
|
-
require 'opal/rspec/fixes/mocks'
|
8
|
-
require 'opal/rspec/fixes/kernel'
|
9
|
-
require 'opal/rspec/fixes/reporter'
|
10
|
-
require 'opal/rspec/fixes/formatter'
|
11
|
-
require 'opal/rspec/fixes/example'
|
12
|
-
require 'opal/rspec/fixes/expectations'
|
4
|
+
require_relative 'fixes/rspec'
|
5
|
+
require_relative 'fixes/opal'
|
@@ -0,0 +1,228 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
module Compatibility
|
4
|
+
# https://github.com/opal/opal/commit/78016aa11955e4cff3d6bbf06f1222d40b03a9e6, fixed in Opal 0.9
|
5
|
+
def self.clones_singleton_methods?
|
6
|
+
obj = Object.new
|
7
|
+
|
8
|
+
def obj.special()
|
9
|
+
:the_one
|
10
|
+
end
|
11
|
+
|
12
|
+
clone = obj.clone
|
13
|
+
clone.respond_to?(:special) && clone.special == :the_one
|
14
|
+
end
|
15
|
+
|
16
|
+
# https://github.com/opal/opal/pull/1104, fixed in Opal 0.9
|
17
|
+
def self.pp_uses_stdout_default?
|
18
|
+
require 'stringio'
|
19
|
+
require 'pp'
|
20
|
+
|
21
|
+
stdout = $stdout
|
22
|
+
$stdout = StringIO.new
|
23
|
+
msg = 'opal-rspec - checking pp/pretty print features'
|
24
|
+
PP.pp msg
|
25
|
+
$stdout.string == "\"#{msg}\"\n"
|
26
|
+
ensure
|
27
|
+
$stdout = stdout
|
28
|
+
end
|
29
|
+
|
30
|
+
# https://github.com/opal/opal/issues/1079, fixed in Opal 0.9
|
31
|
+
def self.full_class_names?
|
32
|
+
Opal::RSpec::Compatibility.to_s == 'Opal::RSpec::Compatibility'
|
33
|
+
end
|
34
|
+
|
35
|
+
# https://github.com/opal/opal/pull/1123, SHOULD be fixed in Opal 0.9
|
36
|
+
def self.is_struct_hash_correct?
|
37
|
+
s = Struct.new(:id)
|
38
|
+
s.new(1) == s.new(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
# https://github.com/opal/opal/issues/1080, fixed in Opal 0.9
|
42
|
+
def self.is_constants_a_clone?
|
43
|
+
mod = Opal::RSpec::Compatibility
|
44
|
+
`#{mod.constants} !== #{mod.constants}`
|
45
|
+
end
|
46
|
+
|
47
|
+
# https://github.com/opal/opal/issues/1077, fixed in Opal 0.9
|
48
|
+
def self.class_descendant_of_self_fixed?
|
49
|
+
!(String < String)
|
50
|
+
end
|
51
|
+
|
52
|
+
# https://github.com/opal/opal/issues/1090, fixed in Opal 0.9
|
53
|
+
def self.and_works_with_lhs_nil?
|
54
|
+
value = nil
|
55
|
+
(value && nil) == nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# https://github.com/opal/opal/issues/858
|
59
|
+
def self.is_set_coerced_to_array?
|
60
|
+
require 'set'
|
61
|
+
|
62
|
+
obj = Object.new
|
63
|
+
|
64
|
+
def obj.splat(*data)
|
65
|
+
return data[0]
|
66
|
+
end
|
67
|
+
|
68
|
+
obj.splat(*Set.new(Set.new([:foo, :bar]))) == :foo
|
69
|
+
end
|
70
|
+
|
71
|
+
# https://github.com/opal/opal/pull/1117, status pending
|
72
|
+
def self.fail_raise_matches_mri?
|
73
|
+
ex = nil
|
74
|
+
%x{
|
75
|
+
try {
|
76
|
+
#{fail}
|
77
|
+
}
|
78
|
+
catch(e) {
|
79
|
+
#{ex} = e;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
ex.is_a? RuntimeError
|
83
|
+
end
|
84
|
+
|
85
|
+
TEST_CLASS = Class.new do
|
86
|
+
class ClassWithinClassNewWorks
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.does_class_exist?
|
90
|
+
Compatibility.const_defined? :ClassWithinClassNewWorks
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# https://github.com/opal/opal/issues/1110, fixed in Opal 0.9
|
95
|
+
def self.class_within_class_new_works?
|
96
|
+
TEST_CLASS.does_class_exist?
|
97
|
+
end
|
98
|
+
|
99
|
+
# Fixed in Opal 0.9
|
100
|
+
def self.undef_within_exec_works?
|
101
|
+
klass = Class.new do
|
102
|
+
def bar
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
klass.class_exec do
|
107
|
+
undef bar
|
108
|
+
end
|
109
|
+
|
110
|
+
!klass.new.respond_to? :bar
|
111
|
+
end
|
112
|
+
|
113
|
+
# https://github.com/opal/opal/pull/1129
|
114
|
+
def self.multiline_regex_works?
|
115
|
+
/foo.bar/m.match("foo\nbar").to_a == ["foo\nbar"]
|
116
|
+
end
|
117
|
+
|
118
|
+
# https://github.com/opal/opal/pull/1129
|
119
|
+
def self.empty_regex_works?
|
120
|
+
empty = //
|
121
|
+
begin
|
122
|
+
empty.options == 0 && empty.match('foo').to_s == ''
|
123
|
+
rescue
|
124
|
+
false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# https://github.com/opal/opal/pull/1129
|
129
|
+
def self.regex_case_compare_works?
|
130
|
+
begin
|
131
|
+
(/abc/ === nil) == false && (/abc/ === /abc/) == false
|
132
|
+
rescue
|
133
|
+
false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class ConstTest
|
138
|
+
end
|
139
|
+
|
140
|
+
module ModuleConstTest
|
141
|
+
end
|
142
|
+
|
143
|
+
# https://github.com/opal/opal/issues/1085
|
144
|
+
def self.constant_resolution_works_right?
|
145
|
+
begin
|
146
|
+
ModuleConstTest::ConstTest.new
|
147
|
+
false
|
148
|
+
rescue
|
149
|
+
true
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# https://github.com/opal/opal/pull/1134
|
154
|
+
def self.exception_inspect_matches?
|
155
|
+
Exception.new.inspect == '#<Exception: Exception>'
|
156
|
+
end
|
157
|
+
|
158
|
+
# https://github.com/opal/opal/pull/1151, should be fixed in Opal 0.9
|
159
|
+
def self.exception_exception_method_works?
|
160
|
+
Exception.respond_to?(:exception) && Exception.exception.is_a?(Exception)
|
161
|
+
end
|
162
|
+
|
163
|
+
# https://github.com/opal/opal/pull/1135
|
164
|
+
def self.ostruct_works_right?
|
165
|
+
require 'ostruct'
|
166
|
+
|
167
|
+
s = OpenStruct.new(:exist? => true)
|
168
|
+
s.respond_to? :exist?
|
169
|
+
end
|
170
|
+
|
171
|
+
module ModuleCase
|
172
|
+
end
|
173
|
+
|
174
|
+
module ModuleCase2
|
175
|
+
include ModuleCase
|
176
|
+
end
|
177
|
+
|
178
|
+
class ModuleCase3
|
179
|
+
include ModuleCase2
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.module_case_works_right?
|
183
|
+
instance = ModuleCase3.new
|
184
|
+
ModuleCase === instance && instance.kind_of?(ModuleCase)
|
185
|
+
end
|
186
|
+
|
187
|
+
module MultModSuper1
|
188
|
+
def stuff
|
189
|
+
:howdy
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
module MultModSuper2
|
194
|
+
def stuff
|
195
|
+
super
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
module MultModSuper3
|
200
|
+
include MultModSuper1
|
201
|
+
include MultModSuper2
|
202
|
+
end
|
203
|
+
|
204
|
+
class MultModSuperClass
|
205
|
+
include MultModSuper3
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.multiple_module_include_super_works_right?
|
209
|
+
MultModSuperClass.new.stuff == :howdy
|
210
|
+
rescue
|
211
|
+
false
|
212
|
+
end
|
213
|
+
|
214
|
+
# https://github.com/opal/opal/pull/1152
|
215
|
+
def self.set_has_superset?
|
216
|
+
require 'set'
|
217
|
+
Set.new.respond_to?(:superset?)
|
218
|
+
end
|
219
|
+
|
220
|
+
# MRI does does, Opal does not yet
|
221
|
+
def self.lambda_zero_arg_throws_arg_error?
|
222
|
+
!(lambda { 3 } === lambda { 4 })
|
223
|
+
rescue
|
224
|
+
true
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|