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
@@ -1,225 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Opal
|
4
|
-
module RSpec
|
5
|
-
class BrowserFormatter < ::RSpec::Core::Formatters::BaseFormatter
|
6
|
-
include ERB::Util
|
7
|
-
|
8
|
-
::RSpec::Core::Formatters.register self, :dump_summary, :example_group_finished, :example_failed, :example_passed, :example_pending, :message
|
9
|
-
|
10
|
-
CSS_STYLES = ::RSpec::Core::Formatters::HtmlPrinter::GLOBAL_STYLES
|
11
|
-
|
12
|
-
def start(example_count)
|
13
|
-
super
|
14
|
-
target = Element.new(`document.body`)
|
15
|
-
target << Element.new(:div, html: REPORT_TEMPLATE)
|
16
|
-
@rspec_results = Element.id('rspec-results')
|
17
|
-
|
18
|
-
css_text = CSS_STYLES + "\n body { padding: 0; margin: 0 }"
|
19
|
-
styles = Element.new(:style, type: 'text/css', css_text: css_text)
|
20
|
-
styles.append_to_head
|
21
|
-
end
|
22
|
-
|
23
|
-
def message(notification)
|
24
|
-
@rspec_group = Element.new(:div, class_name: "example_group passed")
|
25
|
-
@rspec_dl = Element.new(:dl)
|
26
|
-
@rspec_dt = Element.new(:dt, class_name: "passed", text: notification.message)
|
27
|
-
@rspec_group << @rspec_dl
|
28
|
-
@rspec_dl << @rspec_dt
|
29
|
-
|
30
|
-
parents = @example_group.parent_groups.size
|
31
|
-
@rspec_dl.style 'margin-left', "#{(parents - 2) * 15}px"
|
32
|
-
|
33
|
-
@rspec_results << @rspec_group
|
34
|
-
end
|
35
|
-
|
36
|
-
def example_group_started(notification)
|
37
|
-
super
|
38
|
-
|
39
|
-
@example_group_failed = false
|
40
|
-
parents = @example_group.parent_groups.size
|
41
|
-
|
42
|
-
@rspec_group = Element.new(:div, class_name: "example_group passed")
|
43
|
-
@rspec_dl = Element.new(:dl)
|
44
|
-
@rspec_dt = Element.new(:dt, class_name: "passed", text: example_group.description)
|
45
|
-
@rspec_group << @rspec_dl
|
46
|
-
@rspec_dl << @rspec_dt
|
47
|
-
|
48
|
-
@rspec_dl.style 'margin-left', "#{(parents - 2) * 15}px"
|
49
|
-
|
50
|
-
@rspec_results << @rspec_group
|
51
|
-
end
|
52
|
-
|
53
|
-
def example_group_finished(_notification)
|
54
|
-
if @example_group_failed
|
55
|
-
@rspec_group.class_name = "example_group failed"
|
56
|
-
@rspec_dt.class_name = "failed"
|
57
|
-
Element.id('rspec-header').class_name = 'failed'
|
58
|
-
end
|
59
|
-
|
60
|
-
if @example_group_pending
|
61
|
-
@rspec_group.class_name = "example_group not_implemented"
|
62
|
-
@rspec_dt.class_name = "pending"
|
63
|
-
header = Element.id('rspec-header')
|
64
|
-
# Don't want to override failed with pending, which is less important
|
65
|
-
header.class_name = 'not_implemented' unless header.class_name == 'failed'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def example_pending(notification)
|
70
|
-
example = notification.example
|
71
|
-
duration = sprintf("%0.5f", example.execution_result.run_time)
|
72
|
-
|
73
|
-
pending_message = example.execution_result.pending_message
|
74
|
-
|
75
|
-
@example_group_pending = true
|
76
|
-
|
77
|
-
@rspec_dl << Element.new(:dd, class_name: "example not_implemented", html: <<-HTML)
|
78
|
-
<span class="not_implemented_spec_name">#{h example.description} (PENDING: #{h(pending_message)})</span>
|
79
|
-
HTML
|
80
|
-
end
|
81
|
-
|
82
|
-
def example_failed(notification)
|
83
|
-
example = notification.example
|
84
|
-
duration = sprintf("%0.5f", example.execution_result.run_time)
|
85
|
-
|
86
|
-
error = example.execution_result.exception
|
87
|
-
error_name = error.class.name.to_s
|
88
|
-
output = "#{short_padding}#{error_name}:\n"
|
89
|
-
error.message.to_s.split("\n").each { |line| output += "#{long_padding} #{line}\n" }
|
90
|
-
error.backtrace.each {|trace| output += "#{long_padding} #{trace}\n"}
|
91
|
-
|
92
|
-
@example_group_failed = true
|
93
|
-
|
94
|
-
@rspec_dl << Element.new(:dd, class_name: "example failed", html: <<-HTML)
|
95
|
-
<span class="failed_spec_name">#{h example.description}</span>
|
96
|
-
<span class="duration">#{duration}s</span>
|
97
|
-
<div class="failure">
|
98
|
-
<div class="message"><pre>#{h output}</pre></div>
|
99
|
-
</div>
|
100
|
-
HTML
|
101
|
-
end
|
102
|
-
|
103
|
-
def example_passed(notification)
|
104
|
-
example = notification.example
|
105
|
-
duration = sprintf("%0.5f", example.execution_result.run_time)
|
106
|
-
|
107
|
-
@rspec_dl << Element.new(:dd, class_name: "example passed", html: <<-HTML)
|
108
|
-
<span class="passed_spec_name">#{h example.description}</span>
|
109
|
-
<span class="duration">#{duration}s</span>
|
110
|
-
HTML
|
111
|
-
end
|
112
|
-
|
113
|
-
def dump_summary(notification)
|
114
|
-
totals = "#{notification.example_count} examples, #{notification.failure_count} failures, #{notification.pending_count} pending"
|
115
|
-
Element.id('totals').html = totals
|
116
|
-
|
117
|
-
duration = "Finished in <strong>#{sprintf("%.5f", notification.duration)} seconds</strong>"
|
118
|
-
Element.id('duration').html = duration
|
119
|
-
|
120
|
-
add_scripts
|
121
|
-
end
|
122
|
-
|
123
|
-
def add_scripts
|
124
|
-
content = ::RSpec::Core::Formatters::HtmlPrinter::GLOBAL_SCRIPTS
|
125
|
-
`window.eval(#{content})`
|
126
|
-
end
|
127
|
-
|
128
|
-
def short_padding
|
129
|
-
' '
|
130
|
-
end
|
131
|
-
|
132
|
-
def long_padding
|
133
|
-
' '
|
134
|
-
end
|
135
|
-
|
136
|
-
class Element
|
137
|
-
attr_reader :native
|
138
|
-
|
139
|
-
def self.id(id)
|
140
|
-
new(`document.getElementById(id)`)
|
141
|
-
end
|
142
|
-
|
143
|
-
def initialize(el, attrs={})
|
144
|
-
if String === el
|
145
|
-
@native = `document.createElement(el)`
|
146
|
-
else
|
147
|
-
@native = el
|
148
|
-
end
|
149
|
-
|
150
|
-
attrs.each { |name, val| __send__ "#{name}=", val }
|
151
|
-
end
|
152
|
-
|
153
|
-
def class_name
|
154
|
-
`#@native.className`
|
155
|
-
end
|
156
|
-
|
157
|
-
def class_name=(name)
|
158
|
-
`#@native.className = #{name}`
|
159
|
-
end
|
160
|
-
|
161
|
-
def html=(html)
|
162
|
-
`#@native.innerHTML = #{html}`
|
163
|
-
end
|
164
|
-
|
165
|
-
def text=(text)
|
166
|
-
self.html = text.gsub(/</, '<').gsub(/>/, '>')
|
167
|
-
end
|
168
|
-
|
169
|
-
def type=(type)
|
170
|
-
`#@native.type = #{type}`
|
171
|
-
end
|
172
|
-
|
173
|
-
def append(child)
|
174
|
-
`#@native.appendChild(#{child.native})`
|
175
|
-
end
|
176
|
-
|
177
|
-
alias << append
|
178
|
-
|
179
|
-
def css_text=(text)
|
180
|
-
%x{
|
181
|
-
if (#@native.styleSheet) {
|
182
|
-
#@native.styleSheet.cssText = #{text};
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
#@native.appendChild(document.createTextNode(#{text}));
|
186
|
-
}
|
187
|
-
}
|
188
|
-
end
|
189
|
-
|
190
|
-
def style(name, value)
|
191
|
-
`#@native.style[#{name}] = value`
|
192
|
-
end
|
193
|
-
|
194
|
-
def append_to_head
|
195
|
-
`document.getElementsByTagName('head')[0].appendChild(#@native)`
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
REPORT_TEMPLATE = <<-EOF
|
200
|
-
<div class="rspec-report">
|
201
|
-
|
202
|
-
<div id="rspec-header">
|
203
|
-
<div id="label">
|
204
|
-
<h1>RSpec Code Examples</h1>
|
205
|
-
</div>
|
206
|
-
|
207
|
-
<div id="display-filters">
|
208
|
-
<input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="1" /> <label for="passed_checkbox">Passed</label>
|
209
|
-
<input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="2" /> <label for="failed_checkbox">Failed</label>
|
210
|
-
<input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="3" /> <label for="pending_checkbox">Pending</label>
|
211
|
-
</div>
|
212
|
-
|
213
|
-
<div id="summary">
|
214
|
-
<p id="totals"> </p>
|
215
|
-
<p id="duration"> </p>
|
216
|
-
</div>
|
217
|
-
</div>
|
218
|
-
|
219
|
-
<div id="rspec-results" class="results">
|
220
|
-
</div>
|
221
|
-
</div>
|
222
|
-
EOF
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module RSpec::ExampleGroups
|
2
|
-
# opal cannot use mutable strings AND opal doesnt support `\A` or `\z` anchors
|
3
|
-
def self.base_name_for(group)
|
4
|
-
return "Anonymous" if group.description.empty?
|
5
|
-
|
6
|
-
# convert to CamelCase
|
7
|
-
name = ' ' + group.description
|
8
|
-
name = name.gsub(/[^0-9a-zA-Z]+([0-9a-zA-Z])/) { |m| m[1].upcase }
|
9
|
-
|
10
|
-
name = name.lstrip # Remove leading whitespace
|
11
|
-
name = name.gsub(/\W/, '') # JRuby, RBX and others don't like non-ascii in const names
|
12
|
-
|
13
|
-
# Ruby requires first const letter to be A-Z. Use `Nested`
|
14
|
-
# as necessary to enforce that.
|
15
|
-
name = name.gsub(/^([^A-Z]|$)/, 'Nested\1')
|
16
|
-
|
17
|
-
name
|
18
|
-
end
|
19
|
-
|
20
|
-
# opal cannot use mutable strings
|
21
|
-
def self.disambiguate(name, const_scope)
|
22
|
-
return name unless const_scope.const_defined?(name)
|
23
|
-
|
24
|
-
# Add a trailing number if needed to disambiguate from an existing constant.
|
25
|
-
name = name + "_2"
|
26
|
-
while const_scope.const_defined?(name)
|
27
|
-
name = name.next
|
28
|
-
end
|
29
|
-
|
30
|
-
name
|
31
|
-
end
|
32
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
RSpec::Core::Formatters::DeprecationFormatter::GeneratedDeprecationMessage.class_eval do
|
2
|
-
def to_s
|
3
|
-
msg = "#{@data[:deprecated]} is deprecated."
|
4
|
-
msg += " Use #{@data[:replacement]} instead." if @data[:replacement]
|
5
|
-
msg += " Called from #{@data[:call_site]}." if @data[:call_site]
|
6
|
-
msg
|
7
|
-
end
|
8
|
-
|
9
|
-
def too_many_warnings_message
|
10
|
-
msg = "Too many uses of deprecated '#{type}'."
|
11
|
-
msg += " Set config.deprecation_stream to a File for full output."
|
12
|
-
msg
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class RSpec::Core::Formatters::DeprecationFormatter
|
17
|
-
# mutable strings not supported
|
18
|
-
SpecifiedDeprecationMessage = Struct.new(:type) do
|
19
|
-
def initialize(data)
|
20
|
-
@message = data.message
|
21
|
-
super deprecation_type_for(data)
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_s
|
25
|
-
output_formatted @message
|
26
|
-
end
|
27
|
-
|
28
|
-
def too_many_warnings_message
|
29
|
-
"Too many similar deprecation messages reported, disregarding further reports. " + DEPRECATION_STREAM_NOTICE
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def output_formatted(str)
|
35
|
-
return str unless str.lines.count > 1
|
36
|
-
separator = "#{'-' * 80}"
|
37
|
-
"#{separator}\n#{str.chomp}\n#{separator}"
|
38
|
-
end
|
39
|
-
|
40
|
-
def deprecation_type_for(data)
|
41
|
-
data.message.gsub(/(\w+\/)+\w+\.rb:\d+/, '')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
GeneratedDeprecationMessage = Struct.new(:type) do
|
46
|
-
def initialize(data)
|
47
|
-
@data = data
|
48
|
-
super data.deprecated
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_s
|
52
|
-
msg = "#{@data.deprecated} is deprecated."
|
53
|
-
msg = msg + " Use #{@data.replacement} instead." if @data.replacement
|
54
|
-
msg = msg + " Called from #{@data.call_site}." if @data.call_site
|
55
|
-
msg
|
56
|
-
end
|
57
|
-
|
58
|
-
def too_many_warnings_message
|
59
|
-
"Too many uses of deprecated '#{type}'. " + DEPRECATION_STREAM_NOTICE
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# RSpec tries to add context with this. something like this: https://github.com/stacktracejs/stacktrace.js would be better than this but
|
2
|
-
# avoiding adding an NPM dependency for now
|
3
|
-
module Kernel
|
4
|
-
def caller
|
5
|
-
%x{
|
6
|
-
function getErrorObject(){
|
7
|
-
try { throw Error('') } catch(err) { return err; }
|
8
|
-
}
|
9
|
-
|
10
|
-
|
11
|
-
var err = getErrorObject();
|
12
|
-
}
|
13
|
-
stack = `err.stack`
|
14
|
-
caller_lines = stack.split("\n")[4..-1]
|
15
|
-
caller_lines.reject! {|l| l.strip.empty? }
|
16
|
-
|
17
|
-
result_formatter = lambda do |filename, line, method=nil|
|
18
|
-
"#{filename}:#{line} in `(#{method ? method : 'unknown method'})'"
|
19
|
-
end
|
20
|
-
|
21
|
-
caller_lines.map do |raw_line|
|
22
|
-
if match = /\s*at (.*) \((\S+):(\d+):\d+/.match(raw_line)
|
23
|
-
method, filename, line = match.captures
|
24
|
-
result_formatter[filename, line, method]
|
25
|
-
elsif match = /\s*at (\S+):(\d+):\d+/.match(raw_line)
|
26
|
-
filename, line = match.captures
|
27
|
-
result_formatter[filename, line]
|
28
|
-
# catch phantom/no 2nd line/col #
|
29
|
-
elsif match = /\s*at (.*) \((\S+):(\d+)/.match(raw_line)
|
30
|
-
method, filename, line = match.captures
|
31
|
-
result_formatter[filename, line, method]
|
32
|
-
elsif match = /\s*at (.*):(\d+)/.match(raw_line)
|
33
|
-
filename, line = match.captures
|
34
|
-
result_formatter[filename, line]
|
35
|
-
# Firefox - Opal.modules["rspec/core/metadata"]/</</</</def.$populate@http://192.168.59.103:9292/assets/rspec/core/metadata.self.js?body=1:102:13
|
36
|
-
elsif match = /(.*?)@(\S+):(\d+):\d+/.match(raw_line)
|
37
|
-
method, filename, line = match.captures
|
38
|
-
result_formatter[filename, line, method]
|
39
|
-
# webkit - http://192.168.59.103:9292/assets/opal/rspec/sprockets_runner.js:45117:314
|
40
|
-
elsif match = /(\S+):(\d+):\d+/.match(raw_line)
|
41
|
-
filename,line = match.captures
|
42
|
-
result_formatter[filename, line]
|
43
|
-
else
|
44
|
-
"#{filename}:-1 in `(can't parse this stack trace)`"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Opal does not support ObjectSpace, so force object __id__'s
|
2
|
-
class RSpec::Mocks::Space
|
3
|
-
def id_for(object)
|
4
|
-
object.__id__
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
# Buggy under Opal?
|
9
|
-
class RSpec::Mocks::MethodDouble
|
10
|
-
def save_original_method!
|
11
|
-
@original_method ||= @method_stasher.original_method
|
12
|
-
end
|
13
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class RSpec::Core::Reporter
|
2
|
-
# https://github.com/opal/opal/issues/858
|
3
|
-
# The problem is not directly related to the Reporter class (it has more to do with Formatter's call in add using a splat in the args list and right now, Opal does not run a to_a on a splat before the callee method takes over)
|
4
|
-
def register_listener(listener, *notifications)
|
5
|
-
# Without this, we won't flatten out each notification properly (e.g. example_started, finished, etc.)
|
6
|
-
notifications = notifications[0].to_a unless notifications[0].is_a? Array
|
7
|
-
notifications.each do |notification|
|
8
|
-
@listeners[notification.to_sym] << listener
|
9
|
-
end
|
10
|
-
true
|
11
|
-
end
|
12
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Opal
|
2
|
-
module RSpec
|
3
|
-
class TextFormatter < ::RSpec::Core::Formatters::BaseFormatter
|
4
|
-
|
5
|
-
::RSpec::Core::Formatters.register self, :dump_summary, :dump_failures, :message
|
6
|
-
|
7
|
-
def dump_failures(notification)
|
8
|
-
failed_examples = notification.failed_examples
|
9
|
-
if failed_examples.empty?
|
10
|
-
puts "\nFinished"
|
11
|
-
else
|
12
|
-
puts "\nFailures:"
|
13
|
-
failed_examples.each_with_index do |example, index|
|
14
|
-
puts "\n"
|
15
|
-
dump_failure(example, index)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def message(notification)
|
21
|
-
puts notification.message
|
22
|
-
end
|
23
|
-
|
24
|
-
def dump_failure(example, index)
|
25
|
-
puts "#{short_padding}#{index.next}) #{example.full_description}"
|
26
|
-
dump_failure_info(example)
|
27
|
-
end
|
28
|
-
|
29
|
-
def dump_failure_info(example)
|
30
|
-
exception = example.execution_result.exception
|
31
|
-
exception_class_name = exception.class.name.to_s
|
32
|
-
red "#{long_padding}#{exception_class_name}:"
|
33
|
-
exception.message.to_s.split("\n").each { |line| red "#{long_padding} #{line}" }
|
34
|
-
end
|
35
|
-
|
36
|
-
def dump_summary(notification)
|
37
|
-
@duration = notification.duration
|
38
|
-
@example_count = notification.example_count
|
39
|
-
@failure_count = notification.failure_count
|
40
|
-
@pending_count = notification.pending_count
|
41
|
-
|
42
|
-
msg = "\n#{@example_count} examples, #{@failure_count} failures, #{@pending_count} pending (time taken: #{@duration})"
|
43
|
-
|
44
|
-
if @pending_count > 0
|
45
|
-
yellow msg
|
46
|
-
finish_with_code(1)
|
47
|
-
elsif @failure_count == 0
|
48
|
-
green msg
|
49
|
-
finish_with_code(0)
|
50
|
-
else
|
51
|
-
red msg
|
52
|
-
finish_with_code(1)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def finish_with_code(code)
|
57
|
-
%x{
|
58
|
-
if (typeof(phantom) !== "undefined") {
|
59
|
-
phantom.exit(code);
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
Opal.global.OPAL_SPEC_CODE = code;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
def green(str)
|
68
|
-
`console.log('\033[32m' + str + '\033[0m')`
|
69
|
-
end
|
70
|
-
|
71
|
-
def red(str)
|
72
|
-
`console.log('\033[31m' + str + '\033[0m')`
|
73
|
-
end
|
74
|
-
|
75
|
-
def yellow(str)
|
76
|
-
`console.log('\033[33m' + str + '\033[0m')`
|
77
|
-
end
|
78
|
-
|
79
|
-
def short_padding
|
80
|
-
' '
|
81
|
-
end
|
82
|
-
|
83
|
-
def long_padding
|
84
|
-
' '
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|