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
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
unless Opal::RSpec::Compatibility.undef_within_exec_works?
|
2
|
+
module ::RSpec::Expectations::Syntax
|
3
|
+
def disable_expect(syntax_host=::RSpec::Matchers)
|
4
|
+
return unless expect_enabled?(syntax_host)
|
5
|
+
|
6
|
+
# undef not working on Opal 0.8
|
7
|
+
# syntax_host.module_exec do
|
8
|
+
# undef expect
|
9
|
+
# end
|
10
|
+
syntax_host.remove_method(:expect)
|
11
|
+
end
|
12
|
+
|
13
|
+
def disable_should(syntax_host=default_should_host)
|
14
|
+
return unless should_enabled?(syntax_host)
|
15
|
+
|
16
|
+
# undef not working on Opal 0.8
|
17
|
+
# syntax_host.module_exec do
|
18
|
+
# undef should
|
19
|
+
# undef should_not
|
20
|
+
# end
|
21
|
+
syntax_host.remove_method(:should)
|
22
|
+
syntax_host.remove_method(:should_not)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class ::RSpec::Matchers::BuiltIn::All
|
2
|
+
def indent_multiline_message(message)
|
3
|
+
# \z not supported in opal
|
4
|
+
#message = message.sub(/\n+\z/, '')
|
5
|
+
message = message.sub(/\n+$/, '')
|
6
|
+
message.lines.map do |line|
|
7
|
+
line =~ /\S/ ? ' ' + line : line
|
8
|
+
end.join
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ::RSpec::Matchers::BuiltIn::Compound
|
2
|
+
def multiline_message(message_1, message_2)
|
3
|
+
# \z and \A not supported in Opal
|
4
|
+
# [
|
5
|
+
# indent_multiline_message(message_1.sub(/\n+\z/, '')),
|
6
|
+
# "...#{conjunction}:",
|
7
|
+
# indent_multiline_message(message_2.sub(/\A\n+/, ''))
|
8
|
+
# ].join("\n\n")
|
9
|
+
[
|
10
|
+
indent_multiline_message(message_1.sub(/\n+$/, '')),
|
11
|
+
"...#{conjunction}:",
|
12
|
+
indent_multiline_message(message_2.sub(/^\n+/, ''))
|
13
|
+
].join("\n\n")
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ::RSpec::Matchers::BuiltIn
|
2
|
+
class StartAndEndWith
|
3
|
+
def failure_message
|
4
|
+
msg = super
|
5
|
+
if @actual_does_not_have_ordered_elements
|
6
|
+
msg += ", but it does not have ordered elements"
|
7
|
+
elsif !actual.respond_to?(:[])
|
8
|
+
msg += ", but it cannot be indexed using #[]"
|
9
|
+
end
|
10
|
+
msg
|
11
|
+
# string mutation
|
12
|
+
# super.tap do |msg|
|
13
|
+
# if @actual_does_not_have_ordered_elements
|
14
|
+
# msg << ", but it does not have ordered elements"
|
15
|
+
# elsif !actual.respond_to?(:[])
|
16
|
+
# msg << ", but it cannot be indexed using #[]"
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
end
|
20
|
+
|
21
|
+
# see StartWith and EndWith below
|
22
|
+
def check_ordered_element(actual)
|
23
|
+
# Opal arity checking off by default, will check it manually
|
24
|
+
arity = actual.method(:[]).arity
|
25
|
+
raise ArgumentError.new "wrong number of arguments (2 for #{arity})" unless arity == 2
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class StartWith
|
30
|
+
def subset_matches?
|
31
|
+
check_ordered_element actual
|
32
|
+
values_match?(expected, actual[0, expected.length])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class EndWith
|
37
|
+
def subset_matches?
|
38
|
+
check_ordered_element actual
|
39
|
+
values_match?(expected, actual[-expected.length, expected.length])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ::RSpec::Matchers::BuiltIn
|
2
|
+
class YieldWithArgs
|
3
|
+
def description
|
4
|
+
desc = "yield with args"
|
5
|
+
# string mutation
|
6
|
+
# desc << "(#{expected_arg_description})" unless @expected.empty?
|
7
|
+
desc += "(#{expected_arg_description})" unless @expected.empty?
|
8
|
+
desc
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class YieldSuccessiveArgs
|
13
|
+
def description
|
14
|
+
desc = "yield successive args"
|
15
|
+
# string mutation
|
16
|
+
# desc << "(#{expected_arg_description})"
|
17
|
+
desc += "(#{expected_arg_description})"
|
18
|
+
desc
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ::RSpec::Mocks
|
2
|
+
unless Opal::RSpec::Compatibility.constant_resolution_works_right?
|
3
|
+
class MockExpectationError < Exception
|
4
|
+
end
|
5
|
+
|
6
|
+
# Raised when a test double is used after it has been torn
|
7
|
+
# down (typically at the end of an rspec-core example).
|
8
|
+
class ExpiredTestDoubleError < MockExpectationError
|
9
|
+
end
|
10
|
+
|
11
|
+
# Raised when doubles or partial doubles are used outside of the per-test lifecycle.
|
12
|
+
class OutsideOfExampleError < StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
# @private
|
16
|
+
class UnsupportedMatcherError < StandardError
|
17
|
+
end
|
18
|
+
|
19
|
+
# @private
|
20
|
+
class NegationUnsupportedError < StandardError
|
21
|
+
end
|
22
|
+
|
23
|
+
# @private
|
24
|
+
class VerifyingDoubleNotDefinedError < StandardError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ErrorGenerator
|
29
|
+
def actual_method_call_args_description(count, args)
|
30
|
+
method_call_args_description(args) ||
|
31
|
+
if count > 0 && args.length > 0
|
32
|
+
# \A and \z not supported on Opal
|
33
|
+
# " with arguments: #{args.inspect.gsub(/\A\[(.+)\]\z/, '(\1)')}"
|
34
|
+
" with arguments: #{args.inspect.gsub(/^\[(.+)\]$/, '(\1)')}"
|
35
|
+
else
|
36
|
+
""
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Opal does not support ObjectSpace, so force object __id__'s
|
2
|
+
class RSpec::Mocks::Space
|
3
|
+
OPAL_NON_MOCKABLE_TYPES = [:String, :Number, :Numeric]
|
4
|
+
|
5
|
+
def id_for(object)
|
6
|
+
object.__id__
|
7
|
+
end
|
8
|
+
|
9
|
+
# originally had an alternate impl here due to Opal::RSpec::Compatibility.module_case_works_right?, now also doing checks
|
10
|
+
def proxy_not_found_for(id, object)
|
11
|
+
raise "#{object.class} #{object} cannot be used for mocking in Opal!" if OPAL_NON_MOCKABLE_TYPES.include?(object.class.name)
|
12
|
+
# case when SomeClass wasn't working properly
|
13
|
+
includes_test_double = [
|
14
|
+
InstanceVerifyingDouble,
|
15
|
+
ObjectVerifyingDouble,
|
16
|
+
ClassVerifyingDouble,
|
17
|
+
Double
|
18
|
+
]
|
19
|
+
proxies[id] = if object.is_a?(NilClass)
|
20
|
+
ProxyForNil.new(@expectation_ordering)
|
21
|
+
elsif includes_test_double.any? { |klass| object.is_a? klass }
|
22
|
+
object.__build_mock_proxy_unless_expired(@expectation_ordering)
|
23
|
+
elsif object.is_a?(Class)
|
24
|
+
if RSpec::Mocks.configuration.verify_partial_doubles?
|
25
|
+
VerifyingPartialClassDoubleProxy.new(self, object, @expectation_ordering)
|
26
|
+
else
|
27
|
+
PartialClassDoubleProxy.new(self, object, @expectation_ordering)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
if RSpec::Mocks.configuration.verify_partial_doubles?
|
31
|
+
VerifyingPartialDoubleProxy.new(object, @expectation_ordering)
|
32
|
+
else
|
33
|
+
PartialDoubleProxy.new(object, @expectation_ordering)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
unless Opal::RSpec::Compatibility.multiple_module_include_super_works_right?
|
2
|
+
module ::RSpec::Mocks::TestDouble
|
3
|
+
# With multiple modules included in a class, Opal doesn't let module 2 (VerifyingDouble) invoke super from module 1 (TestDouble)
|
4
|
+
def call_method_missing(message, *args, &block)
|
5
|
+
proxy = __mock_proxy
|
6
|
+
proxy.record_message_received(message, *args, &block)
|
7
|
+
|
8
|
+
if proxy.null_object?
|
9
|
+
case message
|
10
|
+
when :to_int then
|
11
|
+
return 0
|
12
|
+
when :to_a, :to_ary then
|
13
|
+
return nil
|
14
|
+
when :to_str then
|
15
|
+
return to_s
|
16
|
+
else
|
17
|
+
return self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Defined private and protected methods will still trigger `method_missing`
|
22
|
+
# when called publicly. We want ruby's method visibility error to get raised,
|
23
|
+
# so we simply delegate to `super` in that case.
|
24
|
+
# ...well, we would delegate to `super`, but there's a JRuby
|
25
|
+
# bug, so we raise our own visibility error instead:
|
26
|
+
# https://github.com/jruby/jruby/issues/1398
|
27
|
+
visibility = proxy.visibility_for(message)
|
28
|
+
if visibility == :private || visibility == :protected
|
29
|
+
ErrorGenerator.new(self, @name).raise_non_public_error(
|
30
|
+
message, visibility
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Required wrapping doubles in an Array on Ruby 1.9.2
|
35
|
+
raise NoMethodError if [:to_a, :to_ary].include? message
|
36
|
+
proxy.raise_unexpected_message_error(message, *args)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
unless Opal::RSpec::Compatibility.multiple_module_include_super_works_right?
|
2
|
+
module Opal::RSpec::VerifyingDoubleFixes
|
3
|
+
def method_missing(message, *args, &block)
|
4
|
+
# Null object conditional is an optimization. If not a null object,
|
5
|
+
# validity of method expectations will have been checked at definition
|
6
|
+
# time.
|
7
|
+
if null_object?
|
8
|
+
if @__sending_message == message
|
9
|
+
__mock_proxy.ensure_implemented(message)
|
10
|
+
else
|
11
|
+
__mock_proxy.ensure_publicly_implemented(message, self)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
call_method_missing message, *args, &block
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ::RSpec::Mocks
|
20
|
+
module VerifyingDouble
|
21
|
+
include ::Opal::RSpec::VerifyingDoubleFixes
|
22
|
+
end
|
23
|
+
|
24
|
+
# In Opala 0.9, this also
|
25
|
+
class ObjectVerifyingDouble
|
26
|
+
include ::Opal::RSpec::VerifyingDoubleFixes
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
unless Opal::RSpec::Compatibility.lambda_zero_arg_throws_arg_error?
|
2
|
+
module ::RSpec::Support::FuzzyMatcher
|
3
|
+
def self.values_match?(expected, actual)
|
4
|
+
if Array === expected && Enumerable === actual && !(Struct === actual)
|
5
|
+
return arrays_match?(expected, actual.to_a)
|
6
|
+
elsif Hash === expected && Hash === actual
|
7
|
+
return hashes_match?(expected, actual)
|
8
|
+
elsif actual == expected
|
9
|
+
return true
|
10
|
+
elsif expected.is_a?(Proc)
|
11
|
+
return expected == actual
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
expected === actual
|
16
|
+
rescue ArgumentError
|
17
|
+
# Some objects, like 0-arg lambdas on 1.9+, raise
|
18
|
+
# ArgumentError for `expected === actual`.
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module ::RSpec::Support::RecursiveConstMethods
|
2
|
+
def normalize_const_name(const_name)
|
3
|
+
#const_name.sub(/\A::/, '')
|
4
|
+
# the \A, which means 'beginning of string' does not work in Opal/JS regex, ^ is beginning of line, which for constant names, should work OK
|
5
|
+
const_name.sub(/^::/, '')
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rspec/support/ruby_features'
|
2
|
+
|
3
|
+
module ::RSpec::Support::RubyFeatures
|
4
|
+
# Weird behavior when optional_and_splat_args_supported? is false (which is the case on Opal) and required_kw_args_supported? is true, so forcing this to false
|
5
|
+
def required_kw_args_supported?
|
6
|
+
false
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ::RSpec
|
2
|
+
module Support
|
3
|
+
module Warnings
|
4
|
+
def warn_with(message, options={})
|
5
|
+
call_site = options.fetch(:call_site) { CallerFilter.first_non_rspec_line }
|
6
|
+
# mutable strings
|
7
|
+
# message << " Use #{options[:replacement]} instead." if options[:replacement]
|
8
|
+
message += " Use #{options[:replacement]} instead." if options[:replacement]
|
9
|
+
# message << " Called from #{call_site}." if call_site
|
10
|
+
message += " Called from #{call_site}." if call_site
|
11
|
+
::Kernel.warn message
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_method :support_warn_with, :warn_with
|
15
|
+
end
|
16
|
+
end
|
17
|
+
extend RSpec::Support::Warnings
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'document_io'
|
2
|
+
require_relative 'html_printer'
|
3
|
+
|
4
|
+
module Opal
|
5
|
+
module RSpec
|
6
|
+
class BrowserFormatter < ::RSpec::Core::Formatters::HtmlFormatter
|
7
|
+
::RSpec::Core::Formatters.register self, :example_group_finished
|
8
|
+
|
9
|
+
def initialize(output)
|
10
|
+
super DocumentIO.new
|
11
|
+
@printer = Opal::RSpec::HtmlPrinter.new(@output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def example_group_started(notification)
|
15
|
+
# Since we hook print_example_group_end, we override this method
|
16
|
+
@example_group_red = false
|
17
|
+
@example_group_number += 1
|
18
|
+
|
19
|
+
@printer.print_example_group_start(example_group_number, notification.group.description, notification.group.parent_groups.size)
|
20
|
+
@printer.flush
|
21
|
+
end
|
22
|
+
|
23
|
+
def example_group_finished(notification)
|
24
|
+
@printer.print_example_group_end
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_dump(_notification)
|
28
|
+
# Don't need to call "print_example_group_end" like base does since we hook that event
|
29
|
+
end
|
30
|
+
|
31
|
+
def extra_failure_content(failure)
|
32
|
+
backtrace = failure.exception.backtrace.map { |line| ::RSpec.configuration.backtrace_formatter.backtrace_line(line) }
|
33
|
+
# No snippet extractor due to code ray dependency
|
34
|
+
" <pre class=\"ruby\"><code>#{backtrace.compact}</code></pre>"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
class DocumentIO < IO
|
4
|
+
include IO::Writable
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
`document.open();`
|
8
|
+
end
|
9
|
+
|
10
|
+
def close
|
11
|
+
@closed = true
|
12
|
+
`document.close()`
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(html)
|
16
|
+
if @closed
|
17
|
+
`console.error(#{"DOC closed, can't write #{html}" })`
|
18
|
+
else
|
19
|
+
`document.write(#{html})`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def flush
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
class Element
|
4
|
+
attr_reader :native
|
5
|
+
|
6
|
+
def self.id(id)
|
7
|
+
new(`document.getElementById(id)`)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.klass(klass)
|
11
|
+
new(`document.getElementsByClassName(#{klass})[0]`)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from_string(str)
|
15
|
+
dummy_div = `document.createElement('div')`
|
16
|
+
`#{dummy_div}.innerHTML = #{str}`
|
17
|
+
new(`#{dummy_div}.children[0]`)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(el, attrs={})
|
21
|
+
if String === el
|
22
|
+
@native = `document.createElement(el)`
|
23
|
+
else
|
24
|
+
@native = el
|
25
|
+
end
|
26
|
+
|
27
|
+
attrs.each { |name, val| __send__ "#{name}=", val }
|
28
|
+
end
|
29
|
+
|
30
|
+
def class_name
|
31
|
+
`#@native.className`
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_child_by_tag_name(tag)
|
35
|
+
Element.new(`#@native.getElementsByTagName(#{tag})[0]`)
|
36
|
+
end
|
37
|
+
|
38
|
+
def class_name=(name)
|
39
|
+
`#@native.className = #{name}`
|
40
|
+
end
|
41
|
+
|
42
|
+
def native
|
43
|
+
`#@native`
|
44
|
+
end
|
45
|
+
|
46
|
+
def outer_html
|
47
|
+
`#@native.outerHTML`
|
48
|
+
end
|
49
|
+
|
50
|
+
def html=(html)
|
51
|
+
`#@native.innerHTML = #{html}`
|
52
|
+
end
|
53
|
+
|
54
|
+
def text=(text)
|
55
|
+
self.html = text.gsub(/</, '<').gsub(/>/, '>')
|
56
|
+
end
|
57
|
+
|
58
|
+
def type=(type)
|
59
|
+
`#@native.type = #{type}`
|
60
|
+
end
|
61
|
+
|
62
|
+
def append(child)
|
63
|
+
`#@native.appendChild(#{child.native})`
|
64
|
+
end
|
65
|
+
|
66
|
+
alias << append
|
67
|
+
|
68
|
+
def css_text=(text)
|
69
|
+
%x{
|
70
|
+
if (#@native.styleSheet) {
|
71
|
+
#@native.styleSheet.cssText = #{text};
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
#@native.appendChild(document.createTextNode(#{text}));
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def style(name, value)
|
80
|
+
`#@native.style[#{name}] = value`
|
81
|
+
end
|
82
|
+
|
83
|
+
def append_to_head
|
84
|
+
`document.getElementsByTagName('head')[0].appendChild(#@native)`
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|