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,21 @@
|
|
1
|
+
describe 'Opal ExpectationTarget' do
|
2
|
+
context 'when constructed via #expect' do
|
3
|
+
it 'fails an invalid negative expectation' do
|
4
|
+
# Fixnum = Numeric on Opal
|
5
|
+
# message = /expected 5 not to be a kind of Fixnum/
|
6
|
+
message = /expected 5 not to be a kind of Num.*/
|
7
|
+
expect {
|
8
|
+
expect(5).not_to be_a(Fixnum)
|
9
|
+
}.to fail_with(message)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'fails an invalid negative expectation with a split infinitive' do
|
13
|
+
# Fixnum = Numeric on Opal
|
14
|
+
# message = /expected 5 not to be a kind of Fixnum/
|
15
|
+
message = /expected 5 not to be a kind of Num.*/
|
16
|
+
expect {
|
17
|
+
expect(5).to_not be_a(Fixnum)
|
18
|
+
}.to fail_with(message)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
describe 'Opal yield_successive_args matcher' do
|
2
|
+
include YieldHelpers
|
3
|
+
extend YieldHelpers
|
4
|
+
|
5
|
+
it 'has a description' do
|
6
|
+
expect(yield_successive_args(1, 3).description).to eq("yield successive args(1, 3)")
|
7
|
+
# symbols == string in opal
|
8
|
+
# expect(yield_successive_args([:a, 1], [:b, 2]).description).to eq("yield successive args([:a, 1], [:b, 2])")
|
9
|
+
expect(yield_successive_args([:a, 1], [:b, 2]).description).to eq('yield successive args(["a", 1], ["b", 2])')
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
+
require_relative 'fixes/missing_constants'
|
7
|
+
require_relative 'fixes/not_compatible'
|
8
|
+
require_relative 'fixes/opal_itself'
|
9
|
+
require_relative 'spec_helper_opal'
|
10
|
+
require 'support/matchers'
|
11
|
+
require 'rspec/support/spec/deprecation_helpers'
|
12
|
+
require 'opal/fixes/deprecation_helpers'
|
13
|
+
require 'opal/fixes/rspec_helpers'
|
14
|
+
require_relative 'config'
|
15
|
+
require_relative 'shared_examples'
|
16
|
+
require 'support/shared_examples'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
RSpec.shared_context "with #should enabled", :uses_should do
|
2
|
+
orig_syntax = nil
|
3
|
+
|
4
|
+
before(:all) do
|
5
|
+
orig_syntax = RSpec::Matchers.configuration.syntax
|
6
|
+
RSpec::Matchers.configuration.syntax = [:expect, :should]
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:context) do
|
10
|
+
RSpec::Matchers.configuration.syntax = orig_syntax
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.shared_context "with the default expectation syntax" do
|
15
|
+
orig_syntax = nil
|
16
|
+
|
17
|
+
before(:context) do
|
18
|
+
orig_syntax = RSpec::Matchers.configuration.syntax
|
19
|
+
RSpec::Matchers.configuration.reset_syntaxes_to_default
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:context) do
|
23
|
+
RSpec::Matchers.configuration.syntax = orig_syntax
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.shared_context "with #should exclusively enabled", :uses_only_should do
|
29
|
+
orig_syntax = nil
|
30
|
+
|
31
|
+
before(:context) do
|
32
|
+
orig_syntax = RSpec::Matchers.configuration.syntax
|
33
|
+
RSpec::Matchers.configuration.syntax = :should
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:context) do
|
37
|
+
RSpec::Matchers.configuration.syntax = orig_syntax
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
RSpec.shared_context "isolate include_chain_clauses_in_custom_matcher_descriptions" do
|
42
|
+
around do |ex|
|
43
|
+
orig = RSpec::Expectations.configuration.include_chain_clauses_in_custom_matcher_descriptions?
|
44
|
+
ex.run
|
45
|
+
RSpec::Expectations.configuration.include_chain_clauses_in_custom_matcher_descriptions = orig
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
module OpalVersionStuff
|
4
|
+
def at_least_opal_0_9?
|
5
|
+
# it's ok if we have a pre-release version
|
6
|
+
Gem::Dependency.new('opal', '>= 0.9').match?('opal', Gem::Version.new(opal_version).release.to_s)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FilterProcessor
|
11
|
+
attr_reader :all_filters
|
12
|
+
attr_accessor :filename
|
13
|
+
|
14
|
+
include OpalVersionStuff
|
15
|
+
|
16
|
+
class GuardCheck
|
17
|
+
attr_reader :opal_version
|
18
|
+
|
19
|
+
include Opal::RSpec::OpalVersionStuff
|
20
|
+
|
21
|
+
def initialize(current_filters, opal_version)
|
22
|
+
@current_filters = current_filters
|
23
|
+
@opal_version = opal_version
|
24
|
+
end
|
25
|
+
|
26
|
+
def unless(&block)
|
27
|
+
result = instance_eval(&block)
|
28
|
+
remove_filter if result
|
29
|
+
end
|
30
|
+
|
31
|
+
def if(&block)
|
32
|
+
result = instance_eval(&block)
|
33
|
+
remove_filter unless result
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def remove_filter
|
39
|
+
@current_filters.pop
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
@all_filters = []
|
46
|
+
@current_title = nil
|
47
|
+
@current_filters = []
|
48
|
+
end
|
49
|
+
|
50
|
+
def rspec_filter(title)
|
51
|
+
@current_filters = []
|
52
|
+
@current_title = title
|
53
|
+
yield
|
54
|
+
@all_filters += @current_filters.map do |filter|
|
55
|
+
filter.merge({title: @current_title})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def filter(value)
|
60
|
+
call_info = caller[0]
|
61
|
+
line_number = /.*:(\d+)/.match(call_info).captures[0]
|
62
|
+
@current_filters << {
|
63
|
+
filename: filename,
|
64
|
+
line_number: line_number,
|
65
|
+
exclusion: value
|
66
|
+
}
|
67
|
+
GuardCheck.new(@current_filters, opal_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def opal_version
|
73
|
+
Opal::VERSION
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# any_instance related
|
2
|
+
and_call_original on a partial double when using any_instance works for instance methods defined on the class
|
3
|
+
and_call_original on a partial double when using any_instance works for instance methods defined on the superclass of the class
|
4
|
+
and_call_original on a partial double when using any_instance works when mocking the method on one class and calling the method on an instance of a subclass
|
5
|
+
and_call_original on a partial double on an object that defines method_missing works for an any_instance partial mock
|
6
|
+
and_call_original on a partial double on an object that defines method_missing raises an error for an unhandled message for an any_instance partial mock
|
7
|
+
|
8
|
+
# SimpleDelegator
|
9
|
+
and_call_original on a partial double for singleton methods works for SimpleDelegator subclasses
|
@@ -0,0 +1,24 @@
|
|
1
|
+
rspec_filter filter '#any_instance' do
|
2
|
+
filter '#any_instance when used after the test has finished restores the original behaviour, even if the expectation fails'
|
3
|
+
filter '#any_instance when used after the test has finished restores the original behavior of a stubbed method'
|
4
|
+
filter '#any_instance when directed at a method defined on a superclass mocks the method correctly'
|
5
|
+
filter '#any_instance when resetting post-verification existing method with stubbing private methods restores a stubbed private method after the spec is run'
|
6
|
+
filter '#any_instance when resetting post-verification existing method with expectations private methods restores a stubbed private method after the spec is run'
|
7
|
+
filter '#any_instance passing the receiver to the implementation block when configured to pass the instance an any instance stub does not pass the instance to and_call_original'
|
8
|
+
filter '#any_instance setting a message expectation with an expectation is set on a method that exists after any one instance has received a message fails if the method is invoked on a second instance'
|
9
|
+
filter "#any_instance setting a message expectation with an expectation is set on a method which does not exist behaves as 'exactly one instance' fails if the method is invoked on a second instance"
|
10
|
+
filter('#any_instance setting a message expectation works with a SimpleDelegator subclass').unless { at_least_opal_0_9? }
|
11
|
+
filter "#any_instance when stubbing behaves as 'every instance' handles freeze and duplication correctly"
|
12
|
+
filter "#any_instance when stubbing behaves as 'every instance' handles method restoration on subclasses"
|
13
|
+
filter /#any_instance when stubbing with #and_call_original and competing #with can combine and_call_original, with, and_return.*/
|
14
|
+
filter("#any_instance when stubbing with #and_raise can stub a method that doesn't exist").unless { at_least_opal_0_9? }
|
15
|
+
filter('#any_instance when stubbing with #and_raise can stub a method that exists').unless { at_least_opal_0_9? }
|
16
|
+
filter '#any_instance when stubbing when partially mocking objects resets partially mocked objects correctly'
|
17
|
+
filter '#any_instance unstubbing using `and_call_original` replaces the stubbed method with the original method'
|
18
|
+
filter '#any_instance unstubbing using `and_call_original` removes all stubs with the supplied method name'
|
19
|
+
filter '#any_instance unstubbing using `and_call_original` removes stubs even if they have already been invoked'
|
20
|
+
filter '#any_instance unstubbing using `and_call_original` removes stubs from sub class after invokation when super class was originally stubbed'
|
21
|
+
filter '#any_instance unstubbing using `and_call_original` removes any stubs set directly on an instance'
|
22
|
+
filter '#any_instance unstubbing using `and_call_original` does not get confused about string vs symbol usage for the message'
|
23
|
+
filter("#any_instance when stubbing behaves as 'every instance' handles stubbing on super and subclasses").if { at_least_opal_0_9? }
|
24
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# any_instance
|
2
|
+
RSpec::Mocks.with_temporary_scope in a before\(:all\) with an any_instance stub does not allow the double to be used in the examples
|
3
|
+
RSpec::Mocks.with_temporary_scope in a before\(:all\) with an any_instance stub does not allow the double to be used after the scope in before\(:all\)
|
4
|
+
|
5
|
+
# current issue with bridged classes (string in this case) and mocking
|
6
|
+
RSpec::Mocks.teardown does not put rspec-mocks into an inconsistent state when called extra times
|
@@ -0,0 +1,8 @@
|
|
1
|
+
rspec_filter 'partial double' do
|
2
|
+
# super/inheritance problems prevent verifying partial doubles except in cases where and_call_original is used
|
3
|
+
filter 'when verify_partial_doubles configuration option is set allows the mock to raise an error with yield'
|
4
|
+
filter 'when verify_partial_doubles configuration option is set allows stubbing and calls the stubbed implementation'
|
5
|
+
|
6
|
+
# not sure what's broken here on 0.8
|
7
|
+
filter(/Using a partial mock on a proxy object.*/).unless { at_least_opal_0_9? }
|
8
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# can't change expect/should right now due to undef/Opal
|
2
|
+
RSpec::Mocks::Matchers::Receive when used in a test framework without rspec-expectations can toggle the available syntax
|
3
|
+
|
4
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like an expect syntax expectation behaves like a receive matcher allows chaining off a `do...end` block implementation to be provided
|
5
|
+
RSpec::Mocks::Matchers::Receive allow\(...\).to receive behaves like an expect syntax allowance behaves like a receive matcher allows chaining off a `do...end` block implementation to be provided
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# ClassVerifyingDouble inheriting from Module to support transferring nested constants, but that doesn't work on Opal
|
2
|
+
the spy family of methods class_spy.*
|
3
|
+
|
4
|
+
# depends on proper initializer behavior in ObjectVerifyingDoubleMethods
|
5
|
+
the spy family of methods object_spy.*
|
@@ -0,0 +1,9 @@
|
|
1
|
+
rspec_filter 'stub implementation' do
|
2
|
+
# stubs class methods
|
3
|
+
filter('unstubbing with `and_call_original` when partial doubles are verified restores the correct implementations when stubbed and unstubbed on a grandparent and grandchild class')
|
4
|
+
.unless { at_least_opal_0_9? }
|
5
|
+
filter('unstubbing with `and_call_original` when partial doubles are verified restores the correct implementations when stubbed and unstubbed on a parent and child class')
|
6
|
+
.unless { at_least_opal_0_9? }
|
7
|
+
filter('unstubbing with `and_call_original` when partial doubles are not verified restores the correct implementations when stubbed and unstubbed on a grandparent and grandchild class')
|
8
|
+
filter('unstubbing with `and_call_original` when partial doubles are not verified restores the correct implementations when stubbed and unstubbed on a parent and child class')
|
9
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
rspec_filter 'any_instance' do
|
2
|
+
# Mock strings
|
3
|
+
filter '#any_instance when stubbing core ruby objects works with the non-standard constructor ""'
|
4
|
+
filter "#any_instance when stubbing core ruby objects works with the non-standard constructor ''"
|
5
|
+
filter '#any_instance setting a message expectation does not set the expectation on every instance'
|
6
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
rspec_filter 'argument_matchers' do
|
2
|
+
# Fixnum == Float on Opal
|
3
|
+
filter 'argument matchers matching handling non-matcher arguments fails a class against an object of a different type'
|
4
|
+
filter('argument matchers matching instance_of handles non matching instances nicely').unless { at_least_opal_0_9? }
|
5
|
+
filter('argument matchers matching instance_of does NOT accept float as instance_of(Numeric)').unless { at_least_opal_0_9? }
|
6
|
+
filter('argument matchers matching instance_of does NOT accept fixnum as instance_of(Numeric)').unless { at_least_opal_0_9? }
|
7
|
+
|
8
|
+
# symbols and strings are different to this example but they are the same in Opal
|
9
|
+
filter 'argument matchers matching handling non-matcher arguments fails for a hash w/ wrong keys'
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
rspec_filter 'combining_implementation_instructions' do
|
2
|
+
# Opal 0.8 does not support catch
|
3
|
+
filter('Combining implementation instructions can combine and_yield and and_throw').unless { at_least_opal_0_9? }
|
4
|
+
filter('Combining implementation instructions can combine and_yield, a block implementation and and_throw').unless { at_least_opal_0_9? }
|
5
|
+
filter('Combining implementation instructions allows the terminal action to be overriden').unless { at_least_opal_0_9? }
|
6
|
+
|
7
|
+
# line # / backtrace
|
8
|
+
filter 'Combining implementation instructions warns when the inner implementation block is overriden'
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
rspec_filter 'double' do
|
2
|
+
# private methods
|
3
|
+
filter "RSpec::Mocks::Double does not respond_to? method_missing (because it's private)"
|
4
|
+
|
5
|
+
# backtrace/line number
|
6
|
+
filter /RSpec::Mocks::Double reports line number of expectation of unreceived message.*/
|
7
|
+
|
8
|
+
# depends on eval
|
9
|
+
filter 'RSpec::Mocks::Double fails when calling yielding method with invalid kw args'
|
10
|
+
|
11
|
+
# throw not supported on Opal 0.8
|
12
|
+
filter('RSpec::Mocks::Double throws when told to').unless { at_least_opal_0_9? }
|
13
|
+
|
14
|
+
# private methods
|
15
|
+
filter('RSpec::Mocks::Double has method_missing as private')
|
16
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# depends on private methods
|
2
|
+
An instance double with the doubled class loaded gives a descriptive error message for NoMethodError
|
3
|
+
An instance double with the doubled class loaded for null objects reports that it responds to protected methods when the appropriate arg is passed
|
4
|
+
An instance double with the doubled class loaded for null objects reports that it responds to defined private methods when the appropriate arg is passed
|
5
|
+
An instance double with the doubled class loaded for null objects includes the double's name in a private method error
|
6
|
+
|
7
|
+
# arity, Opal can't tell the difference between send(*) and send() right now
|
8
|
+
An instance double with the doubled class loaded allows `send` to be stubbed if it is defined on the class
|
@@ -0,0 +1,8 @@
|
|
1
|
+
rspec_filter 'mocks' do
|
2
|
+
# Dir usage
|
3
|
+
filter 'RSpec::Mocks behaves like a library that issues no warnings when loaded issues no warnings when loaded'
|
4
|
+
|
5
|
+
# string mocking
|
6
|
+
filter 'RSpec::Mocks.teardown resets method stubs'
|
7
|
+
filter 'RSpec::Mocks.with_temporary_scope in a before(:all) with an any_instance stub allows the stub to be used'
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
rspec_filter 'nil_expectation_warning' do
|
2
|
+
# marshal not supported on Opal, other issues were fixed in 0.9 that allow this to pass
|
3
|
+
filter('#allow_message_expectations_on_nil does not affect subsequent examples').unless { at_least_opal_0_9? }
|
4
|
+
filter '#allow_message_expectations_on_nil doesnt error when marshalled'
|
5
|
+
|
6
|
+
# backtrace / line number
|
7
|
+
filter 'an expectation set on nil issues a warning with file and line number information'
|
8
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
rspec_filter 'partial_double' do
|
2
|
+
# not sure what broke this on 0.8. public_methods impl?
|
3
|
+
filter('Method visibility when using partial mocks keeps public methods public').unless { at_least_opal_0_9? }
|
4
|
+
filter 'Method visibility when using partial mocks keeps private methods private'
|
5
|
+
filter 'Method visibility when using partial mocks keeps protected methods protected'
|
6
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen and Opal
|
2
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like resets partial mocks cleanly on a frozen object includes the spec location in the warning
|
3
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like resets partial mocks cleanly on a frozen object warns about being unable to remove the method double
|
4
|
+
RSpec::Mocks::Matchers::Receive allow\(...\).to receive behaves like resets partial mocks cleanly on a frozen object includes the spec location in the warning
|
5
|
+
|
6
|
+
# line #
|
7
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like an expect syntax expectation reports the line number of expectation of unreceived message
|
8
|
+
RSpec::Mocks::Matchers::Receive allow\(...\).to receive behaves like resets partial mocks cleanly on a frozen object warns about being unable to remove the method double
|
9
|
+
|
10
|
+
# Fixnum and Float will be considered the same in Opal
|
11
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like an expect syntax expectation behaves like a receive matcher allows the caller to constrain the received arguments by matcher
|
12
|
+
RSpec::Mocks::Matchers::Receive allow\(...\).to receive behaves like an expect syntax allowance behaves like a receive matcher allows the caller to constrain the received arguments by matcher
|
13
|
+
RSpec::Mocks::Matchers::Receive expect\(...\).to receive behaves like an expect syntax expectation sets up a message expectation that formats argument matchers correctly
|