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,109 @@
|
|
1
|
+
require_relative 'noop_flush_string_io'
|
2
|
+
require_relative 'element'
|
3
|
+
|
4
|
+
module Opal
|
5
|
+
module RSpec
|
6
|
+
class HtmlPrinter < ::RSpec::Core::Formatters::HtmlPrinter
|
7
|
+
def initialize(output)
|
8
|
+
super
|
9
|
+
@group_stack = []
|
10
|
+
@update_stack = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_html_start
|
14
|
+
# Will output the header
|
15
|
+
super
|
16
|
+
# Now close out the doc so we can use DOM manipulation for the rest
|
17
|
+
@output.puts "</div>"
|
18
|
+
@output.puts "</div>"
|
19
|
+
@output.puts "</body>"
|
20
|
+
@output.puts "</html>"
|
21
|
+
@output.close
|
22
|
+
# From here, we'll do more direct DOM manipulation
|
23
|
+
reset_output
|
24
|
+
@root_node = Element.klass 'results'
|
25
|
+
end
|
26
|
+
|
27
|
+
def flush_output
|
28
|
+
node = @group_stack.last ? @group_stack.last : @root_node
|
29
|
+
new_node = Element.from_string(@output.string)
|
30
|
+
node.append new_node
|
31
|
+
reset_output
|
32
|
+
end
|
33
|
+
|
34
|
+
def reset_output
|
35
|
+
@output = NoopFlushStringIO.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def print_example_group_start(group_id, description, number_of_parents)
|
39
|
+
super
|
40
|
+
@output.puts '</dl></div>'
|
41
|
+
parent_node = @group_stack.last ? @group_stack.last : @root_node
|
42
|
+
new_node = Element.from_string(@output.string)
|
43
|
+
reset_output
|
44
|
+
parent_node << new_node
|
45
|
+
@group_stack << new_node.get_child_by_tag_name('dl')
|
46
|
+
# We won't have this in the DOM until group ends, so need to queue up yellow/red updates
|
47
|
+
@update_stack << []
|
48
|
+
end
|
49
|
+
|
50
|
+
def print_example_group_end
|
51
|
+
@group_stack.pop
|
52
|
+
@update_stack.pop.each(&:call)
|
53
|
+
end
|
54
|
+
|
55
|
+
def print_example_passed(description, run_time)
|
56
|
+
super
|
57
|
+
flush_output
|
58
|
+
end
|
59
|
+
|
60
|
+
def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content, escape_backtrace=false)
|
61
|
+
super
|
62
|
+
flush_output
|
63
|
+
end
|
64
|
+
|
65
|
+
def print_example_pending(description, pending_message)
|
66
|
+
super
|
67
|
+
flush_output
|
68
|
+
end
|
69
|
+
|
70
|
+
def print_summary(duration, example_count, failure_count, pending_count)
|
71
|
+
# string mutation
|
72
|
+
totals = "#{example_count} example#{'s' unless example_count == 1}, "
|
73
|
+
totals += "#{failure_count} failure#{'s' unless failure_count == 1}"
|
74
|
+
totals += ", #{pending_count} pending" if pending_count > 0
|
75
|
+
|
76
|
+
formatted_duration = "%.5f" % duration
|
77
|
+
Element.id('duration').html = "Finished in <strong>#{formatted_duration} seconds</strong>"
|
78
|
+
Element.id('totals').html = totals
|
79
|
+
end
|
80
|
+
|
81
|
+
# Directly manipulate scripts here
|
82
|
+
def move_progress(percent_done)
|
83
|
+
`moveProgressBar(#{percent_done})`
|
84
|
+
end
|
85
|
+
|
86
|
+
def make_header_red
|
87
|
+
`makeRed('rspec-header')`
|
88
|
+
end
|
89
|
+
|
90
|
+
def make_header_yellow
|
91
|
+
`makeYellow('rspec-header')`
|
92
|
+
end
|
93
|
+
|
94
|
+
def make_example_group_header_red(group_id)
|
95
|
+
@update_stack.last << lambda do
|
96
|
+
`makeRed(#{"div_group_#{group_id}"})`
|
97
|
+
`makeRed(#{"example_group_#{group_id}"})`
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def make_example_group_header_yellow(group_id)
|
102
|
+
@update_stack.last << lambda do
|
103
|
+
`makeYellow(#{"div_group_#{group_id}"})`
|
104
|
+
`makeYellow(#{"example_group_#{group_id}"})`
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class OpalClosedTtyIO < IO
|
2
|
+
include IO::Writable
|
3
|
+
|
4
|
+
def initialize(runner_type, io_type)
|
5
|
+
raise "Unknown IO type #{io_type}!" unless [:stdout, :stderr].include?(io_type)
|
6
|
+
self.write_proc = case runner_type
|
7
|
+
when :phantom
|
8
|
+
`function(str){callPhantom([#{io_type}, str])}`
|
9
|
+
when :node, :browser
|
10
|
+
# opal io is already node aware, browser works as well, but we can't do anything about puts vs. print with the browser
|
11
|
+
case io_type
|
12
|
+
when :stdout
|
13
|
+
$stdout.write_proc
|
14
|
+
when :stderr
|
15
|
+
$stderr.write_proc
|
16
|
+
end
|
17
|
+
else
|
18
|
+
raise "Unknown runner type #{runner_type}"
|
19
|
+
end
|
20
|
+
@tty = true
|
21
|
+
end
|
22
|
+
|
23
|
+
# We're deferring to stdout here, which doesn't need to be closed, but RSpec::BaseTextFormatter doesn't know that, so override this
|
24
|
+
def closed?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
@@ -2,3 +2,10 @@
|
|
2
2
|
RUBY_DESCRIPTION = RUBY_VERSION unless defined?(RUBY_DESCRIPTION)
|
3
3
|
|
4
4
|
class SecurityError < Exception; end unless defined?(SecurityError)
|
5
|
+
|
6
|
+
# This completely changes the struct class, so need it before RSpec runs
|
7
|
+
require_relative 'fixes/opal/compatibility'
|
8
|
+
require_relative 'fixes/opal/corelib/struct'
|
9
|
+
|
10
|
+
# RSpec code changes based on this
|
11
|
+
require_relative 'fixes/rspec/support/ruby_features'
|
data/opal/opal/rspec/requires.rb
CHANGED
@@ -7,6 +7,7 @@ require 'diff/lcs/change'
|
|
7
7
|
require 'diff/lcs/hunk'
|
8
8
|
require 'diff/lcs/internals'
|
9
9
|
require 'erb'
|
10
|
+
require 'json'
|
10
11
|
require 'optparse'
|
11
12
|
require 'pathname'
|
12
13
|
require 'pp'
|
@@ -25,9 +26,14 @@ require 'rspec/core/filter_manager'
|
|
25
26
|
require 'rspec/core/flat_map'
|
26
27
|
require 'rspec/core/formatters'
|
27
28
|
require 'rspec/core/formatters/base_formatter'
|
29
|
+
require 'rspec/core/formatters/base_text_formatter'
|
30
|
+
require 'rspec/core/formatters/console_codes'
|
28
31
|
require 'rspec/core/formatters/deprecation_formatter'
|
32
|
+
require 'rspec/core/formatters/documentation_formatter'
|
29
33
|
require 'rspec/core/formatters/helpers'
|
30
34
|
require 'rspec/core/formatters/html_printer'
|
35
|
+
require 'rspec/core/formatters/json_formatter'
|
36
|
+
require 'rspec/core/formatters/progress_formatter'
|
31
37
|
require 'rspec/core/hooks'
|
32
38
|
require 'rspec/core/memoized_helpers'
|
33
39
|
require 'rspec/core/metadata'
|
@@ -54,7 +60,33 @@ require 'rspec/expectations/version'
|
|
54
60
|
require 'rspec/matchers'
|
55
61
|
require 'rspec/matchers/aliased_matcher'
|
56
62
|
require 'rspec/matchers/built_in'
|
63
|
+
require 'rspec/matchers/built_in/all'
|
57
64
|
require 'rspec/matchers/built_in/base_matcher'
|
65
|
+
require 'rspec/matchers/built_in/be'
|
66
|
+
require 'rspec/matchers/built_in/be_between'
|
67
|
+
require 'rspec/matchers/built_in/be_instance_of'
|
68
|
+
require 'rspec/matchers/built_in/be_kind_of'
|
69
|
+
require 'rspec/matchers/built_in/be_within'
|
70
|
+
require 'rspec/matchers/built_in/change'
|
71
|
+
require 'rspec/matchers/built_in/compound'
|
72
|
+
require 'rspec/matchers/built_in/contain_exactly'
|
73
|
+
require 'rspec/matchers/built_in/cover'
|
74
|
+
require 'rspec/matchers/built_in/eq'
|
75
|
+
require 'rspec/matchers/built_in/eql'
|
76
|
+
require 'rspec/matchers/built_in/equal'
|
77
|
+
require 'rspec/matchers/built_in/exist'
|
78
|
+
require 'rspec/matchers/built_in/has'
|
79
|
+
require 'rspec/matchers/built_in/have_attributes'
|
80
|
+
require 'rspec/matchers/built_in/include'
|
81
|
+
require 'rspec/matchers/built_in/match'
|
82
|
+
require 'rspec/matchers/built_in/operators'
|
83
|
+
require 'rspec/matchers/built_in/output'
|
84
|
+
require 'rspec/matchers/built_in/raise_error'
|
85
|
+
require 'rspec/matchers/built_in/respond_to'
|
86
|
+
require 'rspec/matchers/built_in/satisfy'
|
87
|
+
require 'rspec/matchers/built_in/start_and_end_with'
|
88
|
+
require 'rspec/matchers/built_in/throw_symbol'
|
89
|
+
require 'rspec/matchers/built_in/yield'
|
58
90
|
require 'rspec/matchers/composable'
|
59
91
|
require 'rspec/matchers/dsl'
|
60
92
|
require 'rspec/matchers/generated_descriptions'
|
data/opal/opal/rspec/runner.rb
CHANGED
@@ -1,72 +1,90 @@
|
|
1
|
-
|
2
|
-
module RSpec
|
3
|
-
class Runner
|
1
|
+
require_relative 'formatter/opal_closed_tty_io'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
`typeof(phantom) !== 'undefined' || typeof(OPAL_SPEC_PHANTOM) !== 'undefined'`
|
12
|
-
end
|
13
|
-
|
14
|
-
def default_formatter
|
15
|
-
if phantom?
|
16
|
-
TextFormatter
|
17
|
-
else # browser
|
18
|
-
BrowserFormatter
|
19
|
-
end
|
20
|
-
end
|
3
|
+
module ::RSpec::Core
|
4
|
+
class Runner
|
5
|
+
class << self
|
6
|
+
def browser?
|
7
|
+
`typeof(document) !== "undefined"`
|
8
|
+
end
|
21
9
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
10
|
+
def phantom?
|
11
|
+
`typeof(phantom) !== 'undefined' || typeof(OPAL_SPEC_PHANTOM) !== 'undefined'`
|
25
12
|
end
|
26
13
|
|
27
|
-
def
|
28
|
-
|
29
|
-
@world = ::RSpec.world
|
30
|
-
@configuration = ::RSpec.configuration
|
14
|
+
def node?
|
15
|
+
`typeof(process) !== 'undefined' && typeof(process.versions) !== 'undefined'`
|
31
16
|
end
|
32
17
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
18
|
+
def non_browser?
|
19
|
+
phantom? || node?
|
20
|
+
end
|
36
21
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
def get_opal_closed_tty_io
|
23
|
+
runner_type = if phantom?
|
24
|
+
:phantom
|
25
|
+
elsif node?
|
26
|
+
:node
|
27
|
+
else
|
28
|
+
:browser
|
29
|
+
end
|
30
|
+
std_out = OpalClosedTtyIO.new runner_type,
|
31
|
+
:stdout
|
32
|
+
std_err = OpalClosedTtyIO.new runner_type,
|
33
|
+
:stderr
|
34
|
+
[std_err, std_out]
|
41
35
|
end
|
42
36
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
def autorun
|
38
|
+
# see NoCarriageReturnIO source for why this is being done (not on Node though)
|
39
|
+
err, out = get_opal_closed_tty_io
|
40
|
+
# Have to do this in 2 places. This will ensure the default formatter gets the right IO, but need to do this in config for custom formatters
|
41
|
+
# that will be constructed BEFORE this runs, see rspec.rb
|
42
|
+
run(ARGV, err, out).then do |status|
|
43
|
+
exit_with_code status.to_i
|
44
|
+
end
|
45
|
+
end
|
50
46
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
47
|
+
def exit_with_code(code)
|
48
|
+
# have to ignore OPAL_SPEC_PHANTOM for this one
|
49
|
+
if `typeof(phantom) !== "undefined"`
|
50
|
+
`phantom_exit(#{code})`
|
51
|
+
elsif node?
|
52
|
+
`process.exit(#{code})`
|
53
|
+
else
|
54
|
+
`Opal.global.OPAL_SPEC_CODE = #{code}`
|
55
|
+
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
58
|
+
def run(args, err=$stderr, out=$stdout)
|
59
|
+
options = ConfigurationOptions.new(args)
|
60
|
+
new(options).run(err, out)
|
59
61
|
end
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
def run_groups_async(example_groups, reporter)
|
65
|
+
results = []
|
66
|
+
last_promise = example_groups.inject(Promise.value(true)) do |previous_promise, group|
|
67
|
+
previous_promise.then do |result|
|
68
|
+
results << result
|
69
|
+
group.run reporter
|
70
|
+
end
|
71
|
+
end
|
72
|
+
last_promise.then do |result|
|
73
|
+
results << result
|
74
|
+
results.all? ? 0 : @configuration.failure_exit_code
|
65
75
|
end
|
76
|
+
end
|
66
77
|
|
67
|
-
|
68
|
-
|
69
|
-
|
78
|
+
def run_specs(example_groups)
|
79
|
+
@configuration.reporter.report_async(@world.example_count(example_groups)) do |reporter|
|
80
|
+
hook_context = SuiteHookContext.new
|
81
|
+
Promise.value.then do
|
82
|
+
@configuration.hooks.run(:before, :suite, hook_context)
|
83
|
+
run_groups_async example_groups, reporter
|
84
|
+
end.ensure do |result|
|
85
|
+
@configuration.hooks.run(:after, :suite, hook_context)
|
86
|
+
result
|
87
|
+
end
|
70
88
|
end
|
71
89
|
end
|
72
90
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%
|
2
|
+
spec_opts = ENV['SPEC_OPTS']
|
3
|
+
if spec_opts && !spec_opts.empty?
|
4
|
+
%>
|
5
|
+
RSpec.configure do |config|
|
6
|
+
<%
|
7
|
+
if (match = /--(no-)?color\b/.match(spec_opts))
|
8
|
+
color_value = !match.captures[0]
|
9
|
+
# Have to use instance_variable_set because config.color= is designed to not allow overriding color once it's set, but
|
10
|
+
# we do not yet have true SPEC_OPTS parsing via RSpec config to get it initially set
|
11
|
+
%>
|
12
|
+
config.instance_variable_set(:@color, <%=color_value.to_s%>)
|
13
|
+
<%
|
14
|
+
end
|
15
|
+
if (requires = spec_opts.scan(/--require \S+/)).any?
|
16
|
+
requires.map {|r| /--require (.*)/.match(r).captures[0]}.each do |req| %>
|
17
|
+
|
18
|
+
require "<%= req %>"
|
19
|
+
|
20
|
+
<% end
|
21
|
+
end
|
22
|
+
if (match = /--format (\S+)/.match(spec_opts))
|
23
|
+
formatter = match.captures[0]
|
24
|
+
%>
|
25
|
+
config.formatter = "<%=formatter%>"
|
26
|
+
<% end %>
|
27
|
+
end
|
28
|
+
<% end %>
|
@@ -4,8 +4,10 @@
|
|
4
4
|
require 'opal'
|
5
5
|
require 'opal-rspec'
|
6
6
|
|
7
|
-
<%
|
8
|
-
|
7
|
+
<%
|
8
|
+
environment.get_opal_spec_requires.each do |s| %>
|
9
|
+
require <%= s.inspect %>
|
9
10
|
<% end %>
|
11
|
+
require 'opal/rspec/spec_opts'
|
10
12
|
|
11
|
-
|
13
|
+
::RSpec::Core::Runner.autorun
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'capybara/rspec'
|
3
|
+
require 'capybara-webkit'
|
4
|
+
|
5
|
+
# Use Rack config exactly as shipped in the GEM
|
6
|
+
Capybara.app = Rack::Builder.new_from_string(File.read('config.ru'))
|
7
|
+
|
8
|
+
describe 'browser formatter', type: :feature do
|
9
|
+
RSpec.shared_examples :browser do |driver, error_fetcher|
|
10
|
+
context "in #{driver}", driver: driver do
|
11
|
+
before do
|
12
|
+
visit '/'
|
13
|
+
# Specs should run in 12 seconds but in case Travis takes longer, provide some cushion
|
14
|
+
Capybara.default_wait_time = 40
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
js_errors = error_fetcher[page]
|
19
|
+
puts "Javascript errors: #{js_errors}" if js_errors.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'matches test results' do
|
23
|
+
expect(page).to have_content '142 examples, 40 failures, 12 pending'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Travis version (4.x QT) might be causing this to fail
|
29
|
+
#include_examples :browser, :webkit, lambda {|page| page.driver.error_messages}
|
30
|
+
include_examples :browser, :selenium, lambda {|page| page.evaluate_script('window.jsErrors') }
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is used by Opal::Server to basically load all spec files that
|
2
|
+
# can be found in the spec/ directory.
|
3
|
+
|
4
|
+
require 'opal'
|
5
|
+
# Hard to capture errors w/ Selenium
|
6
|
+
%x{
|
7
|
+
window.jsErrors = [];
|
8
|
+
window.onerror = function (errorMessage) {
|
9
|
+
window.jsErrors.push(errorMessage);
|
10
|
+
};
|
11
|
+
}
|
12
|
+
|
13
|
+
require 'opal-rspec'
|
14
|
+
|
15
|
+
<%
|
16
|
+
environment.get_opal_spec_requires.each do |s| %>
|
17
|
+
require <%= s.inspect %>
|
18
|
+
<% end %>
|
19
|
+
require 'opal/rspec/spec_opts'
|
20
|
+
::RSpec::Core::Runner.autorun
|