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
@@ -0,0 +1,3 @@
|
|
1
|
+
# Long standing issue with doing defined?(@instance_var) - See https://github.com/opal/opal/blob/master/lib/opal/nodes/defined.rb, compile_ivar method
|
2
|
+
# RSpec::Matchers::BuiltIn::BaseMatcher#description does one of these and when @expected is nil, it will not appear defined but it should be
|
3
|
+
equal when the expected object is falsey in conditinal semantics describes itself with the expected object
|
@@ -0,0 +1,8 @@
|
|
1
|
+
rspec_filter 'have_attributes' do
|
2
|
+
# https://github.com/opal/opal/pull/1136 - operators and method missing issues with a_value > < etc
|
3
|
+
unless at_least_opal_0_9?
|
4
|
+
filter('#have_attributes matcher expect(...).to have_attributes(with_one_attribute) expect(...).to have_attributes(key => matcher) fails with a clear message when the matcher does not match')
|
5
|
+
filter('#have_attributes matcher expect(...).to have_attributes(with_one_attribute) expect(...).to have_attributes(key => matcher) provides a description')
|
6
|
+
filter('#have_attributes matcher expect(...).to have_attributes(with_one_attribute) expect(...).to have_attributes(key => matcher) passes when the matchers match')
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
rspec_filter 'include' do
|
2
|
+
# https://github.com/opal/opal/pull/1136 - operators and method missing issues with a_value > < etc
|
3
|
+
filter('#include matcher Composing matchers with `include` expect(array).to include(matcher) works with comparison matchers').unless { at_least_opal_0_9? }
|
4
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
rspec_filter 'respond_to' do
|
2
|
+
# Also arity related, but looks like opal is returning the optional arg splat as arity
|
3
|
+
filter('expect(...).not_to respond_to(:sym).with(1).argument fails if target responds to :sym with one or more args').unless { at_least_opal_0_9? }
|
4
|
+
filter('expect(...).to respond_to(:sym).with(2).arguments passes if target responds to two or more arguments').unless { at_least_opal_0_9? }
|
5
|
+
filter 'expect(...).to respond_to(:sym).with(2).arguments passes if target responds to any number of arguments'
|
6
|
+
filter('expect(...).to respond_to(:sym).with(1).argument passes if target responds to one or more arguments').unless { at_least_opal_0_9? }
|
7
|
+
|
8
|
+
# arity related
|
9
|
+
filter('expect(...).to respond_to(:sym).with(1).argument passes if target responds to any number of arguments').if { at_least_opal_0_9? }
|
10
|
+
filter('expect(...).to respond_to(:sym).with(2).arguments passes if target responds to one or more arguments').if { at_least_opal_0_9? }
|
11
|
+
filter('expect(...).not_to respond_to(:sym).with(1).argument fails if target responds to :sym with any number of args').if { at_least_opal_0_9? }
|
12
|
+
filter('expect(...).not_to respond_to(:sym).with(2).arguments fails if target responds to :sym with one or more args').if { at_least_opal_0_9? }
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Foo
|
2
|
+
def howdy
|
3
|
+
puts 'howdy'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class Stuff
|
8
|
+
include Foo
|
9
|
+
end
|
10
|
+
|
11
|
+
# This approach fails on opal-master
|
12
|
+
# module Foo
|
13
|
+
# undef howdy
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# Stuff.new.howdy
|
17
|
+
|
18
|
+
# This approach also fails on opal-master
|
19
|
+
Foo.send(:remove_method, :howdy)
|
20
|
+
Stuff.new.howdy
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# opal symbols are strings
|
2
|
+
RSpec::Matchers should have an alias for "have attributes \{\\"age\\" => 32\}" with description: "an object having attributes \{:age => 32\}"
|
3
|
+
RSpec::Matchers should have an alias for "include \{\\"a\\" => 5\}" with description: "a hash including \{:a => 5\}"
|
4
|
+
RSpec::Matchers should have an alias for "throw foo" with description: "a block throwing :foo"
|
5
|
+
RSpec::Matchers should have an alias for "throw foo" with description: "throwing :foo"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Symbols are strings
|
2
|
+
Matchers should be able to generate their own descriptions expect\(...\).to have_key
|
3
|
+
Matchers should be able to generate their own descriptions expect\(...\).not_to eql
|
4
|
+
|
5
|
+
# throw not in Opal
|
6
|
+
Matchers should be able to generate their own descriptions expect\(...\).to throw symbol.*
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# mutable strings, see opal alternates
|
2
|
+
RSpec::Matchers::DSL::Matcher defined using the dsl raises NoMethodError for methods not in the running_example
|
3
|
+
|
4
|
+
# Fixnum = Numeric on Opal, see opal alternates
|
5
|
+
Spec::Matchers::DSL::Matcher wrapping another expectation \(expect\(...\).to eq ...\) can use the `include` matcher from a `match` block
|
6
|
+
|
7
|
+
# regex compatibility, see opal alternates
|
8
|
+
RSpec::Matchers::DSL::Matcher wrapping another expectation \(expect\(...\).to eq ...\) can use the `match` matcher from a `match` block
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# no bigdecimal on opal
|
2
|
+
eq with BigDecimal objects fails with a conventional representation of the decimal
|
3
|
+
|
4
|
+
# no activesupport on opal
|
5
|
+
eq Time Equality with DateTime objects.*
|
6
|
+
eq Time Equality with Time objects produces different output for Times differing by milliseconds
|
7
|
+
|
8
|
+
# symbols
|
9
|
+
eq #description with "symbol" is "eq :symbol"
|
10
|
+
eq #description with {"foo"=>"bar"} is "eq {:foo=>:bar}"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# diff on Opal
|
2
|
+
RSpec::Expectations includes a diff if expected and actual are diffable
|
3
|
+
RSpec::Expectations does not include the diff if expected and actual are not diffable
|
4
|
+
RSpec::Expectations uses matcher descriptions in place of matchers in diffs
|
5
|
+
RSpec::Expectations tells the differ to use color
|
6
|
+
|
7
|
+
# Dir
|
8
|
+
RSpec::Expectations behaves like a library that issues no warnings when loaded issues no warnings when loaded
|
@@ -0,0 +1,3 @@
|
|
1
|
+
# Diff
|
2
|
+
.include matcher expect\(...\).to include\(with_one_arg\) for a string target includes a diff when actual is multiline and there are multiple expecteds
|
3
|
+
.include matcher expect\(...\).to include\(with_one_arg\) for a string target includes a diff when actual is multiline
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# diffs not yet supported on Opal
|
2
|
+
RSpec::Matchers::DSL::Matcher handles multiline string diffs
|
3
|
+
|
4
|
+
# throw not in Opal
|
5
|
+
RSpec::Matchers::BuiltIn::ThrowSymbol.*
|
6
|
+
|
7
|
+
# subprocess/threading
|
8
|
+
RSpec::Matchers can be mixed into `main`
|
9
|
+
|
10
|
+
# minitest/opal compatibility
|
11
|
+
built in matchers RSpec::Matchers method_missing hook when invoked in a Minitest::Test behaves like a well-behaved method_missing hook raises a NoMethodError \(and not SystemStackError\) for an undefined method
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# diff
|
2
|
+
output.to_stdout matcher expect { ... }.to_not output\(matcher\).to_stdout fails if the block outputs a string to stdout that passes the given matcher
|
3
|
+
output.to_stdout matcher expect { ... }.to output\(matcher\).to_stdout fails if the block outputs a string to stdout that does not pass the given matcher
|
4
|
+
output.to_stdout matcher expect { ... }.to_not output\(/regex/\).to_stdout fails if the block outputs a string to stdout that matches the regex
|
5
|
+
output.to_stdout matcher expect { ... }.to output\(/regex/\).to_stdout fails if the block outputs a string to stdout that does not match
|
6
|
+
output.to_stdout matcher expect { ... }.to output\(/regex/\).to_stdout fails if the block does not output to stdout
|
7
|
+
output.to_stderr matcher expect { ... }.to_not output\(matcher\).to_stderr fails if the block outputs a string to stderr that passes the given matcher
|
8
|
+
output.to_stderr matcher expect { ... }.to output\(matcher\).to_stderr fails if the block outputs a string to stderr that does not pass the given matcher
|
9
|
+
output.to_stderr matcher expect { ... }.to_not output\(/regex/\).to_stderr fails if the block outputs a string to stderr that matches the regex
|
10
|
+
output.to_stderr matcher expect { ... }.to output\(/regex/\).to_stderr fails if the block outputs a string to stderr that does not match
|
11
|
+
output.to_stderr matcher expect { ... }.to output\(/regex/\).to_stderr fails if the block does not output to stderr
|
12
|
+
|
13
|
+
# $VERBOSE global variable
|
14
|
+
output..* matcher does not produce warnings when the failure message is accessed first
|
@@ -0,0 +1,5 @@
|
|
1
|
+
rspec_filter 'respond_to' do
|
2
|
+
# arity
|
3
|
+
filter('expect(...).not_to respond_to(:sym).with(2).arguments fails if target responds to :sym with two or more args').unless { at_least_opal_0_9? }
|
4
|
+
filter('expect(...).not_to respond_to(:sym).with(2).arguments fails if target responds to :sym with any number args')
|
5
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
# these tests are using symbols but in Opal symbols are strings
|
2
|
+
RSpec::Expectations::Syntax when passing a message to an expectation expect\(...\).to prints a warning when the message object isn't a String
|
3
|
+
RSpec::Expectations::Syntax when passing a message to an expectation expect\(...\).not_to prints a warning when the message object isn't a String
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
def self.get_constants_for(object)
|
4
|
+
result = []
|
5
|
+
%x{
|
6
|
+
for (var prop in #{object}) {
|
7
|
+
if (#{object}.hasOwnProperty(prop) && #{!`prop`.start_with?('$')}) {
|
8
|
+
#{result << `prop`}
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
result.reject { |c| c == 'constructor' }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
unless Opal::RSpec::Compatibility.constant_resolution_works_right?
|
18
|
+
groups_are_in = RSpec::ExampleGroups
|
19
|
+
built_in_spec = :BuiltInMatchers
|
20
|
+
# in case we aren't running all of the examples
|
21
|
+
if groups_are_in.const_defined? built_in_spec
|
22
|
+
example_group = groups_are_in.const_get built_in_spec
|
23
|
+
example_group.let(:matchers) do
|
24
|
+
# .constants is broken in Opal, this is a hack
|
25
|
+
constants = Opal::RSpec.get_constants_for(RSpec::Matchers::BuiltIn) - [:NullCapture, :CaptureStdOut, :CaptureStdErr]
|
26
|
+
constants.map { |n| RSpec::Matchers::BuiltIn.const_get(n) }.select do |m|
|
27
|
+
#BuiltIn.constants.map { |n| BuiltIn.const_get(n) }.select do |m|
|
28
|
+
m.method_defined?(:matches?) && m.method_defined?(:failure_message)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# https://github.com/opal/opal/issues/1110, fixed in Opal 0.9
|
2
|
+
unless Opal::RSpec::Compatibility.class_within_class_new_works?
|
3
|
+
require 'delegate'
|
4
|
+
|
5
|
+
class ArrayDelegate < DelegateClass(Array)
|
6
|
+
def initialize(array)
|
7
|
+
@internal_array = array
|
8
|
+
super(@internal_array)
|
9
|
+
end
|
10
|
+
|
11
|
+
def large?
|
12
|
+
@internal_array.size >= 5
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class FooError < StandardError
|
17
|
+
def foo;
|
18
|
+
:bar;
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# description_generaiton_spec
|
23
|
+
class Parent;
|
24
|
+
end
|
25
|
+
class Child < Parent
|
26
|
+
def child_of?(*parents)
|
27
|
+
parents.all? { |parent| self.is_a?(parent) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# be_between spec
|
32
|
+
class SizeMatters
|
33
|
+
include Comparable
|
34
|
+
attr :str
|
35
|
+
|
36
|
+
def <=>(other)
|
37
|
+
str.size <=> other.str.size
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(str)
|
41
|
+
@str = str
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
@str
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# https://github.com/opal/opal/pull/1135
|
51
|
+
unless Opal::RSpec::Compatibility.ostruct_works_right?
|
52
|
+
class OpenStruct
|
53
|
+
def initialize(hash = nil)
|
54
|
+
@table = {}
|
55
|
+
|
56
|
+
hash.each_pair { |key, value|
|
57
|
+
@table[new_ostruct_member(key)] = value
|
58
|
+
} if hash
|
59
|
+
end
|
60
|
+
|
61
|
+
def []=(name, value)
|
62
|
+
@table[new_ostruct_member(name)] = value
|
63
|
+
end
|
64
|
+
|
65
|
+
def method_missing(name, *args)
|
66
|
+
if args.length > 2
|
67
|
+
raise NoMethodError.new "undefined method `#{name}' for #<OpenStruct>"
|
68
|
+
end
|
69
|
+
if name.end_with? '='
|
70
|
+
if args.length != 1
|
71
|
+
raise ArgumentError.new "wrong number of arguments (0 for 1)"
|
72
|
+
end
|
73
|
+
@table[new_ostruct_member(name[0 .. -2])] = args[0]
|
74
|
+
else
|
75
|
+
@table[name.to_sym]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_reader :table
|
80
|
+
|
81
|
+
def delete_field(name)
|
82
|
+
sym = name.to_sym
|
83
|
+
begin
|
84
|
+
singleton_class.__send__(:remove_method, sym, "#{sym}=")
|
85
|
+
rescue NameError
|
86
|
+
end
|
87
|
+
@table.delete sym
|
88
|
+
end
|
89
|
+
|
90
|
+
def new_ostruct_member(name)
|
91
|
+
name = name.to_sym
|
92
|
+
unless respond_to?(name)
|
93
|
+
define_singleton_method(name) { @table[name] }
|
94
|
+
define_singleton_method("#{name}=") { |x| @table[name] = x }
|
95
|
+
end
|
96
|
+
name
|
97
|
+
end
|
98
|
+
|
99
|
+
`var ostruct_ids;`
|
100
|
+
|
101
|
+
def inspect
|
102
|
+
%x{
|
103
|
+
var top = (ostruct_ids === undefined),
|
104
|
+
ostruct_id = self.$object_id();
|
105
|
+
}
|
106
|
+
begin
|
107
|
+
result = "#<#{self.class}"
|
108
|
+
%x{
|
109
|
+
if (top) {
|
110
|
+
ostruct_ids = {};
|
111
|
+
}
|
112
|
+
|
113
|
+
if (ostruct_ids.hasOwnProperty(ostruct_id)) {
|
114
|
+
return #{result + ' ...>'};
|
115
|
+
}
|
116
|
+
|
117
|
+
ostruct_ids[ostruct_id] = true;
|
118
|
+
}
|
119
|
+
|
120
|
+
result += ' ' if @table.any?
|
121
|
+
|
122
|
+
result += each_pair.map { |name, value|
|
123
|
+
"#{name}=#{value.inspect}"
|
124
|
+
}.join ", "
|
125
|
+
|
126
|
+
result += ">"
|
127
|
+
|
128
|
+
result
|
129
|
+
ensure
|
130
|
+
%x{
|
131
|
+
if (top) {
|
132
|
+
ostruct_ids = undefined;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
alias to_s inspect
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
[:be_an_instance_of, :be_instance_of].each do |method|
|
2
|
+
describe "Opal expect(actual).to #{method}(expected)" do
|
3
|
+
it "provides a description" do
|
4
|
+
matcher = be_an_instance_of(Fixnum)
|
5
|
+
matcher.matches?(Numeric)
|
6
|
+
# opal fixnum == numeric
|
7
|
+
# expect(matcher.description).to eq "be an instance of Fixnum"
|
8
|
+
expect(matcher.description).to eq "be an instance of Numeric"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
describe 'Opal RSpec::Matchers::DSL::Matcher' do
|
2
|
+
context "defined using the dsl" do
|
3
|
+
it "raises NoMethodError for methods not in the running_example" do |example|
|
4
|
+
RSpec::Matchers.define(:__raise_no_method_error) do
|
5
|
+
match do |actual|
|
6
|
+
self.a_method_not_in_the_example == "method defined in the example"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# mutable strings
|
11
|
+
#expected_msg = "RSpec::Matchers::DSL::Matcher"
|
12
|
+
#expected_msg << " __raise_no_method_error" unless rbx?
|
13
|
+
expected_msg = "RSpec::Matchers::DSL::Matcher" + " __raise_no_method_error"
|
14
|
+
|
15
|
+
expect {
|
16
|
+
expect(example).to __raise_no_method_error
|
17
|
+
}.to raise_error(NoMethodError, /#{expected_msg}/)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "wrapping another expectation (expect(...).to eq ...)" do
|
22
|
+
it "can use the `include` matcher from a `match` block" do
|
23
|
+
RSpec::Matchers.define(:descend_from) do |mod|
|
24
|
+
match do |klass|
|
25
|
+
expect(klass.ancestors).to include(mod)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
expect(Fixnum).to descend_from(Object)
|
30
|
+
expect(Fixnum).not_to descend_from(Array)
|
31
|
+
|
32
|
+
expect {
|
33
|
+
expect(Fixnum).to descend_from(Array)
|
34
|
+
}.to fail_with(/expected Numeric to descend from Array/)
|
35
|
+
# Fixnum = Numeric on Opal
|
36
|
+
#}.to fail_with(/expected Fixnum to descend from Array/)
|
37
|
+
|
38
|
+
expect {
|
39
|
+
expect(Fixnum).not_to descend_from(Object)
|
40
|
+
# Fixnum = Numeric on Opal
|
41
|
+
}.to fail_with(/expected Numeric not to descend from Object/)
|
42
|
+
#}.to fail_with(/expected Fixnum not to descend from Object/)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can use the `match` matcher from a `match` block" do
|
46
|
+
RSpec::Matchers.define(:be_a_phone_number_string) do
|
47
|
+
match do |string|
|
48
|
+
# \A and \Z in JS regex
|
49
|
+
# expect(string).to match(/\A\d{3}\-\d{3}\-\d{4}\z/)
|
50
|
+
expect(string).to match(/^\d{3}\-\d{3}\-\d{4}$/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
expect("206-123-1234").to be_a_phone_number_string
|
55
|
+
expect("foo").not_to be_a_phone_number_string
|
56
|
+
|
57
|
+
expect {
|
58
|
+
expect("foo").to be_a_phone_number_string
|
59
|
+
}.to fail_with(/expected "foo" to be a phone number string/)
|
60
|
+
|
61
|
+
expect {
|
62
|
+
expect("206-123-1234").not_to be_a_phone_number_string
|
63
|
+
}.to fail_with(/expected "206-123-1234" not to be a phone number string/)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|