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,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RSpec::Core
|
4
|
+
RSpec.describe 'Opal MemoizedHelpers' do
|
5
|
+
before(:each) { RSpec.configuration.configure_expectation_framework }
|
6
|
+
|
7
|
+
context "using 'self' as an explicit subject" do
|
8
|
+
it "delegates matcher to the ExampleGroup" do
|
9
|
+
group = ExampleGroup.describe("group") do
|
10
|
+
subject { self }
|
11
|
+
def ok?; true; end
|
12
|
+
def not_ok?; false; end
|
13
|
+
|
14
|
+
it { should eq(self) }
|
15
|
+
it { should be_ok }
|
16
|
+
it { should_not be_not_ok }
|
17
|
+
end
|
18
|
+
|
19
|
+
#expect(group.run).to be true
|
20
|
+
expect(group.run).to be_a Promise
|
21
|
+
expect(group.run.value).to be_truthy
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'supports a new expect-based syntax' do
|
25
|
+
group = ExampleGroup.describe([1, 2, 3]) do
|
26
|
+
it { is_expected.to be_an Array }
|
27
|
+
it { is_expected.not_to include 4 }
|
28
|
+
end
|
29
|
+
|
30
|
+
#expect(group.run).to be true
|
31
|
+
expect(group.run).to be_a Promise
|
32
|
+
expect(group.run.value).to be_truthy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RSpec::Core
|
4
|
+
RSpec.describe 'Opal Metadata' do
|
5
|
+
describe "backwards compatibility" do
|
6
|
+
before { allow_deprecation }
|
7
|
+
|
8
|
+
describe ":example_group" do
|
9
|
+
it 'allows integration libraries like VCR to infer a fixture name from the example description by walking up nesting structure' do
|
10
|
+
fixture_name_for = lambda do |metadata|
|
11
|
+
description = metadata[:description]
|
12
|
+
|
13
|
+
if example_group = metadata[:example_group]
|
14
|
+
[fixture_name_for[example_group], description].join('/')
|
15
|
+
else
|
16
|
+
description
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ex = inferred_fixture_name = nil
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.before(:example, :infer_fixture) { |e| inferred_fixture_name = fixture_name_for[e.metadata] }
|
24
|
+
end
|
25
|
+
|
26
|
+
# run returns a promise
|
27
|
+
# RSpec.describe "Group", :infer_fixture do
|
28
|
+
# ex = example("ex") {}
|
29
|
+
# end.run
|
30
|
+
#
|
31
|
+
# raise ex.execution_result.exception if ex.execution_result.exception
|
32
|
+
#
|
33
|
+
# expect(inferred_fixture_name).to eq("Group/ex")
|
34
|
+
|
35
|
+
group = RSpec.describe "Group", :infer_fixture do
|
36
|
+
ex = example("ex") {}
|
37
|
+
end
|
38
|
+
|
39
|
+
group.run.then do
|
40
|
+
raise ex.execution_result.exception if ex.execution_result.exception
|
41
|
+
|
42
|
+
expect(inferred_fixture_name).to eq("Group/ex")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ::RSpec::Core::Ordering::Random
|
2
|
+
# there are a lot of these in the RSpec specs that create noise
|
3
|
+
HIDE_RANDOM_WARNINGS = true
|
4
|
+
end
|
5
|
+
|
6
|
+
# dealing with dynamic requires
|
7
|
+
require 'rspec/support'
|
8
|
+
require 'rspec/support/spec/deprecation_helpers'
|
9
|
+
require 'rspec/support/spec/with_isolated_stderr'
|
10
|
+
require 'rspec/support/spec/stderr_splitter'
|
11
|
+
require 'rspec/support/spec/formatting_support'
|
12
|
+
require 'rspec/support/spec/with_isolated_directory'
|
13
|
+
require 'rspec/support/ruby_features'
|
14
|
+
require 'support/shared_example_groups'
|
15
|
+
require 'support/helper_methods'
|
16
|
+
require 'support/matchers'
|
17
|
+
require 'support/formatter_support'
|
18
|
+
require 'sandboxing'
|
19
|
+
require_relative 'fixes/missing_constants'
|
20
|
+
require_relative 'fixes/shared_examples'
|
21
|
+
require 'rspec/support/spec'
|
22
|
+
require_relative 'config'
|
23
|
+
require 'opal/fixes/deprecation_helpers'
|
24
|
+
require 'opal/fixes/rspec_helpers'
|
25
|
+
require_relative 'fixes/opal_itself'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
RSpec.configure do |c|
|
2
|
+
c.around { |ex| Sandboxing.sandboxed { ex.run } }
|
3
|
+
end
|
4
|
+
|
5
|
+
class NullObject
|
6
|
+
private
|
7
|
+
def method_missing(method, *args, &block)
|
8
|
+
# ignore
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Sandboxing
|
13
|
+
def self.sandboxed(&block)
|
14
|
+
# No load path in Opal
|
15
|
+
# orig_load_path = $LOAD_PATH.dup
|
16
|
+
orig_config = RSpec.configuration
|
17
|
+
orig_world = RSpec.world
|
18
|
+
orig_example = RSpec.current_example
|
19
|
+
new_config = RSpec::Core::Configuration.new
|
20
|
+
new_config.expose_dsl_globally = false
|
21
|
+
new_config.expecting_with_rspec = true
|
22
|
+
new_world = RSpec::Core::World.new(new_config)
|
23
|
+
RSpec.configuration = new_config
|
24
|
+
RSpec.world = new_world
|
25
|
+
object = Object.new
|
26
|
+
object.extend(RSpec::Core::SharedExampleGroup)
|
27
|
+
|
28
|
+
# Before https://github.com/opal/opal/commit/f73f766b261b881e6cd3256287b8afa28af99693, the stock class_exec won't work in Opal
|
29
|
+
# (class << RSpec::Core::ExampleGroup; self; end).class_exec do
|
30
|
+
# alias_method :orig_run, :run
|
31
|
+
# def run(reporter=nil)
|
32
|
+
# RSpec.current_example = nil
|
33
|
+
# orig_run(reporter || NullObject.new)
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
RSpec::Core::ExampleGroup.class_eval do
|
38
|
+
class << self
|
39
|
+
alias_method :orig_run, :run
|
40
|
+
|
41
|
+
def run(reporter=nil)
|
42
|
+
RSpec.current_example = nil
|
43
|
+
orig_run(reporter || NullObject.new)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec::Mocks.with_temporary_scope do
|
49
|
+
object.instance_exec(&block)
|
50
|
+
end
|
51
|
+
ensure
|
52
|
+
# See above comment
|
53
|
+
# (class << RSpec::Core::ExampleGroup; self; end).class_exec do
|
54
|
+
# remove_method :run
|
55
|
+
# alias_method :run, :orig_run
|
56
|
+
# remove_method :orig_run
|
57
|
+
# end
|
58
|
+
RSpec::Core::ExampleGroup.class_eval do
|
59
|
+
class << self
|
60
|
+
remove_method :run
|
61
|
+
alias_method :run, :orig_run
|
62
|
+
remove_method :orig_run
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
RSpec.configuration = orig_config
|
67
|
+
RSpec.world = orig_world
|
68
|
+
RSpec.current_example = orig_example
|
69
|
+
# No load path in Opal
|
70
|
+
# $LOAD_PATH.replace(orig_load_path)
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# InSubProcess - requires forking
|
2
|
+
**/dsl_spec.rb
|
3
|
+
**/core/configuration_spec.rb
|
4
|
+
**/shared_example_group_spec.rb
|
5
|
+
|
6
|
+
# requires running services
|
7
|
+
**/drb_spec.rb
|
8
|
+
|
9
|
+
# opal does not like %W on line 107
|
10
|
+
**/rspec/core/configuration_options_spec.rb
|
11
|
+
|
12
|
+
# Nokogiri/filesystem heavy
|
13
|
+
**/html_formatter_spec.rb
|
14
|
+
|
15
|
+
# Coderay gem/opal
|
16
|
+
**/snippet_extractor_spec.rb
|
17
|
+
|
18
|
+
# Don't have Rake in Opal
|
19
|
+
**/rake_task_spec.rb
|
20
|
+
|
21
|
+
# Do not have the option parser std lib
|
22
|
+
**/option_parser_spec.rb
|
23
|
+
|
24
|
+
# We have to use our own runner anyways
|
25
|
+
**/runner_spec.rb
|
26
|
+
|
27
|
+
# uses heavy I/O
|
28
|
+
**/order_spec.rb
|
29
|
+
|
30
|
+
# I/O heavy test
|
31
|
+
**/backtrace_formatter_spec.rb
|
32
|
+
|
33
|
+
# Random - RSpec::Core::Backports::Random locks up the browser
|
34
|
+
**/ordering_spec.rb
|
35
|
+
**/random_spec.rb
|
36
|
+
|
37
|
+
# I/O heavy and opal-rspec has to do its own initializing anyways
|
38
|
+
**/project_initializer_spec.rb
|
39
|
+
|
40
|
+
# profiling isn't supported on Opal
|
41
|
+
**/profile_formatter_spec.rb
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'opal/progress_json_formatter' # verify case uses this
|
2
|
+
|
3
|
+
RSpec::configure do |config|
|
4
|
+
config.color = true
|
5
|
+
|
6
|
+
config.include FormattingSupport
|
7
|
+
config.include RSpecHelpers
|
8
|
+
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
$default_expectation_syntax = expectations.syntax
|
11
|
+
expectations.syntax = :expect
|
12
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
13
|
+
end
|
14
|
+
|
15
|
+
#config.full_description = 'RSpec::Matchers once required includes itself in Minitest::Test'
|
16
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require_relative '../opal_rspec_spec_loader'
|
2
|
+
|
3
|
+
module Opal
|
4
|
+
module RSpec
|
5
|
+
module ExpectationSpecLoader
|
6
|
+
extend Opal::RSpec::OpalRSpecSpecLoader
|
7
|
+
|
8
|
+
def self.expected_pending_count
|
9
|
+
0
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.base_dir
|
13
|
+
'spec/rspec/expectations'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.spec_glob
|
17
|
+
%w{rspec-expectations/spec/**/*_spec.rb spec/rspec/expectations/opal_alternates/**/*_spec.rb}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.files_with_line_continue
|
21
|
+
[/matchers\/dsl_spec.rb/]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.files_with_multiline_regex
|
25
|
+
[/matchers\/built_in\/match_spec.rb/]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.post_requires
|
29
|
+
%w{fixes/example_patches.rb}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.sub_in_files
|
33
|
+
files = super
|
34
|
+
files = symbols_in_expectations files
|
35
|
+
files = integer_decimals files
|
36
|
+
anonymous_examples_operators files
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.symbol_files
|
40
|
+
[
|
41
|
+
/respond_to_spec.rb/,
|
42
|
+
/include_spec.rb/,
|
43
|
+
/have_attributes_spec.rb/,
|
44
|
+
/has_spec.rb/,
|
45
|
+
/raise_error_spec.rb/
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.integer_float_files
|
50
|
+
[/be_within_spec.rb/]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.anonymous_examples_operators(files)
|
54
|
+
example_number = 0
|
55
|
+
replace_with_regex /specify do(.*?)end/m, 'anonymous examples we cannot filter', files, [/aliases_spec.rb/] do |match, temp_filename|
|
56
|
+
example_number += 1
|
57
|
+
body = match.captures[0]
|
58
|
+
contains_operator = /a_value [<>]/.match(body) || /a_value <=/.match(body)
|
59
|
+
next match.to_s unless contains_operator
|
60
|
+
fixed = "specify 'alias example #{example_number}' do\n#{body}\nend"
|
61
|
+
puts "#{temp_filename} - anonymous examples we cannot filter - replacing #{match.to_s} with #{fixed}"
|
62
|
+
fixed
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.integer_decimals(files)
|
67
|
+
matching_exp = [
|
68
|
+
/fail_\w+\((.*)\)/,
|
69
|
+
/expect.*description\)\.to eq (.*)/
|
70
|
+
]
|
71
|
+
# In Opal, 5.0 will be considered 5. Rather than muck with all of the code, any time we're expecting 5.0, just change it to 5
|
72
|
+
replace_with_regex matching_exp, 'expected integers when given integers', files, integer_float_files do |match, temp_filename|
|
73
|
+
integer_regex = /(\d+)\.0/
|
74
|
+
has_integers = integer_regex.match(match.captures[0])
|
75
|
+
next match.to_s unless has_integers
|
76
|
+
fixed = match.to_s.gsub(integer_regex, "\\1")
|
77
|
+
puts "#{temp_filename} - float/integer fix, replacing #{match.to_s} with #{fixed} in new temp file"
|
78
|
+
fixed
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.stubbed_requires
|
83
|
+
[
|
84
|
+
'timeout', # not part of opal stdlib
|
85
|
+
'rubygems',
|
86
|
+
'simplecov', # hooks aren't available on Opal
|
87
|
+
'open3', # File I/O
|
88
|
+
'rake/file_utils', # Rake not around
|
89
|
+
'complex', # not part of opal stdlib
|
90
|
+
'rspec/support/spec/shell_out', # only does stuff Opal can't support anyways
|
91
|
+
'bigdecimal',
|
92
|
+
# 'aruba/api', # Cucumber lib that supports file creation during testing, N/A for us
|
93
|
+
# 'tmpdir',
|
94
|
+
# 'rspec/support/spec/shell_out', # only does stuff Opal can't support anyways
|
95
|
+
# 'rspec/support/spec/prevent_load_time_warnings'
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.additional_load_paths
|
100
|
+
[
|
101
|
+
'rspec-expectations/spec' # a few spec support files live outside of rspec-expectations/spec/rspec and live in support
|
102
|
+
]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
rspec_filter 'aliases' do
|
2
|
+
unless at_least_opal_0_9?
|
3
|
+
# Opal is interpretting the == and === literally (as a boolean)
|
4
|
+
filter 'RSpec::Matchers should have an alias for "be == 3" with description: "a value == 3"'
|
5
|
+
filter 'RSpec::Matchers should have an alias for "be === 3" with description: "a value === 3"'
|
6
|
+
|
7
|
+
# https://github.com/opal/opal/pull/1136 - operators and method missing issues with a_value > < etc
|
8
|
+
# These are the specify matchers inside aliases_spec and they are poorly named, our rake task gives them a name for us
|
9
|
+
filter 'RSpec::Matchers alias example 6'
|
10
|
+
filter 'RSpec::Matchers alias example 7'
|
11
|
+
filter 'RSpec::Matchers alias example 8'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
rspec_filter 'be_instance_of' do
|
2
|
+
unless at_least_opal_0_9?
|
3
|
+
# Maybe Numeric shouldn't == Fixnum but it does in Opal
|
4
|
+
filter('expect(actual).to be_an_instance_of(expected) fails if actual is instance of subclass of expected class')
|
5
|
+
filter('expect(actual).to be_instance_of(expected) fails if actual is instance of subclass of expected class')
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# in opal, currently can't undefine methods in a module when that module has been included in other classes (in this case, the example group) - see sandbox/undef.rb
|
2
|
+
RSpec::Expectations::Configuration configuring rspec-expectations directly behaves like configuring the expectation syntax can limit the syntax to :should
|
3
|
+
RSpec::Expectations::Configuration configuring rspec-expectations directly behaves like configuring the expectation syntax can limit the syntax to :expect
|
4
|
+
RSpec::Expectations::Configuration configuring using the rspec-core config API behaves like configuring the expectation syntax can limit the syntax to :should
|
5
|
+
RSpec::Expectations::Configuration configuring using the rspec-core config API behaves like configuring the expectation syntax can limit the syntax to :expect
|
6
|
+
|
7
|
+
# global config problem
|
8
|
+
RSpec::Expectations::Configuration#backtrace_formatter defaults to a null formatter when rspec-core is not loaded
|
@@ -0,0 +1,13 @@
|
|
1
|
+
rspec_filter 'contain_exactly' do
|
2
|
+
# https://github.com/opal/opal/pull/1136 - operators and method missing issues with a_value > < etc
|
3
|
+
filter /should_not =~ \[:with, :multiple, :args\] fails when the arrays match.*/
|
4
|
+
unless at_least_opal_0_9?
|
5
|
+
filter('should =~ array when the array undefines `=~` still works')
|
6
|
+
filter('using contain_exactly with expect passes for an out of order valid positive expectation with hashes')
|
7
|
+
filter('using contain_exactly with expect passes for an in order valid positive expectation with hashes')
|
8
|
+
end
|
9
|
+
filter('should =~ array when the array defines a `send` method still works')
|
10
|
+
filter('should =~ array when the array defines a `=~` method delegates to that method rather than using the contain_exactly matcher')
|
11
|
+
filter('should =~ array fails an invalid positive expectation')
|
12
|
+
filter('should =~ array passes a valid positive expectation')
|
13
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
rspec_filter 'define_negated_matcher' do
|
2
|
+
# method owner (no issue/PR) and block (https://github.com/opal/opal/pull/1132)
|
3
|
+
filter('RSpec::Matchers.define_negated_matcher when the negated description is overriden overrides the failure message with the provided block')
|
4
|
+
filter('RSpec::Matchers.define_negated_matcher when the negated description is overriden overrides the description with the provided block').unless { at_least_opal_0_9? }
|
5
|
+
filter('RSpec::Matchers.define_negated_matcher when no block is passed when matched negatively fails matches against values that pass the original matcher')
|
6
|
+
filter('RSpec::Matchers.define_negated_matcher when no block is passed when matched positively fails matches against values that pass the original matcher')
|
7
|
+
filter('RSpec::Matchers.define_negated_matcher the failure message for a matcher with default failure messages when failing negatively uses the phrasing from the provided defined matcher alias')
|
8
|
+
filter('RSpec::Matchers.define_negated_matcher the failure message for a matcher with default failure messages when failing positively uses the phrasing from the provided defined matcher alias')
|
9
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# probably due to an Opal bug in 0.8
|
2
|
+
RSpec::Matchers::DSL::Matcher allows chainable methods to accept blocks
|
3
|
+
|
4
|
+
# something w/ inheritance is wrong here
|
5
|
+
RSpec::Matchers::DSL::Matcher defined using the dsl can get a method object for methods in the running example
|
6
|
+
|
7
|
+
# probably class scoping issue since new_matcher creates a new DSL matcher class, probably https://github.com/opal/opal/issues/1110 related
|
8
|
+
RSpec::Matchers::DSL::Matcher#match_unless_raises without a specified error class passes if no error is raised
|
9
|
+
|
10
|
+
# not sure, class scoping issue? (see above)
|
11
|
+
RSpec::Matchers::DSL::Matcher#match_unless_raises with an unexpected error raises the error
|
12
|
+
RSpec::Matchers::DSL::Matcher#match_unless_raises with an assertion with passing assertion passes
|
13
|
+
RSpec::Matchers::DSL::Matcher with an included module allows multiple modules to be included at once
|
14
|
+
RSpec::Matchers::DSL::Matcher allows an early `return` to be used from a `match_unless_raises` block
|