opal-rspec 0.8.0 → 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +7 -7
- data/.gitmodules +6 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +13 -0
- data/README.md +63 -59
- data/diff-lcs/spec/files_to_exclude.txt +1 -0
- data/diff-lcs/spec/requires.rb +4 -0
- data/diff-lcs/upstream/.autotest +5 -0
- data/diff-lcs/upstream/.fasterer.yml +3 -0
- data/{stubs/diff/lcs.rb → diff-lcs/upstream/.gemtest} +0 -0
- data/diff-lcs/upstream/.github/workflows/ci.yml +64 -0
- data/diff-lcs/upstream/.github/workflows/codeql-analysis.yml +70 -0
- data/diff-lcs/upstream/.gitignore +20 -0
- data/diff-lcs/upstream/.hoerc +52 -0
- data/diff-lcs/upstream/.rspec +1 -0
- data/diff-lcs/upstream/.standard.yml +6 -0
- data/diff-lcs/upstream/Code-of-Conduct.md +74 -0
- data/diff-lcs/upstream/Contributing.md +119 -0
- data/diff-lcs/upstream/Gemfile +28 -0
- data/diff-lcs/upstream/History.md +407 -0
- data/diff-lcs/upstream/License.md +41 -0
- data/diff-lcs/upstream/Manifest.txt +59 -0
- data/diff-lcs/upstream/README.rdoc +84 -0
- data/diff-lcs/upstream/Rakefile +127 -0
- data/diff-lcs/upstream/bin/htmldiff +35 -0
- data/diff-lcs/upstream/bin/ldiff +9 -0
- data/diff-lcs/upstream/diff-lcs.gemspec +48 -0
- data/diff-lcs/upstream/docs/COPYING.txt +339 -0
- data/diff-lcs/upstream/docs/artistic.txt +127 -0
- data/diff-lcs/upstream/lib/diff/lcs/array.rb +7 -0
- data/diff-lcs/upstream/lib/diff/lcs/backports.rb +9 -0
- data/diff-lcs/upstream/lib/diff/lcs/block.rb +37 -0
- data/diff-lcs/upstream/lib/diff/lcs/callbacks.rb +327 -0
- data/diff-lcs/upstream/lib/diff/lcs/change.rb +174 -0
- data/diff-lcs/upstream/lib/diff/lcs/htmldiff.rb +158 -0
- data/diff-lcs/upstream/lib/diff/lcs/hunk.rb +363 -0
- data/diff-lcs/upstream/lib/diff/lcs/internals.rb +308 -0
- data/diff-lcs/upstream/lib/diff/lcs/ldiff.rb +173 -0
- data/diff-lcs/upstream/lib/diff/lcs/string.rb +5 -0
- data/diff-lcs/upstream/lib/diff/lcs.rb +741 -0
- data/diff-lcs/upstream/lib/diff-lcs.rb +3 -0
- data/diff-lcs/upstream/spec/change_spec.rb +89 -0
- data/diff-lcs/upstream/spec/diff_spec.rb +51 -0
- data/diff-lcs/upstream/spec/fixtures/aX +1 -0
- data/diff-lcs/upstream/spec/fixtures/bXaX +1 -0
- data/diff-lcs/upstream/spec/fixtures/ds1.csv +50 -0
- data/diff-lcs/upstream/spec/fixtures/ds2.csv +51 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff +4 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff-c +7 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff-e +3 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff-f +3 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff-u +5 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef +4 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef-c +15 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef-e +3 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef-f +3 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef-u +9 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2 +7 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2-c +20 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2-d +7 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2-e +7 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2-f +7 -0
- data/diff-lcs/upstream/spec/fixtures/ldiff/output.diff.chef2-u +16 -0
- data/diff-lcs/upstream/spec/fixtures/new-chef +4 -0
- data/diff-lcs/upstream/spec/fixtures/new-chef2 +17 -0
- data/diff-lcs/upstream/spec/fixtures/old-chef +4 -0
- data/diff-lcs/upstream/spec/fixtures/old-chef2 +14 -0
- data/diff-lcs/upstream/spec/hunk_spec.rb +83 -0
- data/diff-lcs/upstream/spec/issues_spec.rb +160 -0
- data/diff-lcs/upstream/spec/lcs_spec.rb +56 -0
- data/diff-lcs/upstream/spec/ldiff_spec.rb +89 -0
- data/diff-lcs/upstream/spec/patch_spec.rb +416 -0
- data/diff-lcs/upstream/spec/sdiff_spec.rb +216 -0
- data/diff-lcs/upstream/spec/spec_helper.rb +376 -0
- data/diff-lcs/upstream/spec/traverse_balanced_spec.rb +312 -0
- data/diff-lcs/upstream/spec/traverse_sequences_spec.rb +137 -0
- data/lib/opal/rspec/runner.rb +11 -0
- data/lib/opal/rspec/sprockets.rb +6 -0
- data/lib/opal/rspec/version.rb +1 -1
- data/lib/opal/rspec.rb +1 -2
- data/lib-opal/opal/rspec/async/configuration.rb +39 -0
- data/lib-opal/opal/rspec/async/example.rb +80 -168
- data/lib-opal/opal/rspec/async/example_group.rb +71 -81
- data/lib-opal/opal/rspec/async/hooks.rb +98 -8
- data/lib-opal/opal/rspec/async/memoized_helpers.rb +32 -0
- data/lib-opal/opal/rspec/async/reporter.rb +6 -3
- data/lib-opal/opal/rspec/async/runner.rb +33 -24
- data/lib-opal/opal/rspec/async.rb +4 -1
- data/lib-opal/opal/rspec/browser.rb +0 -8
- data/lib-opal/opal/rspec/browser_early.rb +5 -0
- data/lib-opal/opal/rspec/fixes/diff-lcs/hunk.rb +164 -0
- data/lib-opal/opal/rspec/fixes/diff-lcs/lcs.rb +112 -0
- data/lib-opal/opal/rspec/fixes/diff-lcs.rb +2 -0
- data/lib-opal/opal/rspec/fixes/opal.rb +4 -17
- data/lib-opal/opal/rspec/fixes/rspec/core/example_status_persister.rb +11 -0
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/deprecation_formatter.rb +3 -12
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/exception_presenter.rb +28 -0
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/loader.rb +0 -32
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/snippet_extractor.rb +17 -0
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/syntax_highlighter.rb +17 -0
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters.rb +3 -4
- data/lib-opal/opal/rspec/fixes/rspec/core/metadata.rb +24 -8
- data/lib-opal/opal/rspec/fixes/rspec/core/notifications/examples_notification.rb +3 -20
- data/lib-opal/opal/rspec/fixes/rspec/core/notifications.rb +0 -2
- data/lib-opal/opal/rspec/fixes/rspec/core.rb +1 -2
- data/lib-opal/opal/rspec/fixes/rspec/expectations.rb +0 -1
- data/lib-opal/opal/rspec/fixes/rspec/matchers/built_in/base_matcher.rb +26 -0
- data/lib-opal/opal/rspec/fixes/rspec/matchers/built_in.rb +1 -3
- data/lib-opal/opal/rspec/fixes/rspec/matchers/expecteds_for_multiple_diffs.rb +13 -0
- data/lib-opal/opal/rspec/fixes/rspec/matchers.rb +1 -1
- data/lib-opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +26 -10
- data/lib-opal/opal/rspec/fixes/rspec/mocks/proxy.rb +19 -0
- data/lib-opal/opal/rspec/fixes/rspec/mocks.rb +1 -3
- data/lib-opal/opal/rspec/fixes/rspec/support/differ.rb +29 -0
- data/lib-opal/opal/rspec/fixes/rspec/support/encoded_string.rb +9 -5
- data/lib-opal/opal/rspec/fixes/rspec/support/ruby_features.rb +22 -0
- data/lib-opal/opal/rspec/fixes/rspec/support/source.rb +15 -0
- data/lib-opal/opal/rspec/fixes/rspec/support.rb +3 -3
- data/lib-opal/opal/rspec/fixes/rspec.rb +0 -1
- data/lib-opal/opal/rspec/fixes.rb +1 -0
- data/lib-opal/opal/rspec/formatter/html_printer.rb +1 -1
- data/lib-opal/opal/rspec/pre_require_fixes.rb +1 -5
- data/lib-opal/opal/rspec/requires.rb +32 -19
- data/lib-opal/opal/rspec/sprockets_runner.rb.erb +1 -0
- data/lib-opal/opal/rspec.rb +3 -0
- data/opal-rspec.gemspec +1 -1
- data/rspec/upstream/.document +1 -1
- data/rspec/upstream/.github/FUNDING.yml +5 -0
- data/rspec/upstream/.gitignore +1 -0
- data/rspec/upstream/LICENSE.md +27 -0
- data/rspec/upstream/README.md +26 -26
- data/rspec/upstream/Rakefile +1 -1
- data/rspec/upstream/certs/rspec.pem +32 -20
- data/rspec/upstream/certs/samphippen.asc +18 -0
- data/rspec/upstream/code_of_conduct.md +59 -0
- data/rspec/upstream/lib/rspec/version.rb +1 -1
- data/rspec/upstream/rspec.gemspec +7 -2
- data/rspec-core/upstream/.document +1 -1
- data/rspec-core/upstream/.github/FUNDING.yml +5 -0
- data/rspec-core/upstream/.github/workflows/ci.yml +150 -0
- data/rspec-core/upstream/.gitignore +2 -0
- data/rspec-core/upstream/.rspec +1 -0
- data/rspec-core/upstream/.rubocop.yml +64 -12
- data/rspec-core/upstream/.rubocop_rspec_base.yml +224 -38
- data/rspec-core/upstream/.rubocop_todo.yml +1031 -0
- data/rspec-core/upstream/.yardopts +2 -1
- data/rspec-core/upstream/BUILD_DETAIL.md +149 -0
- data/rspec-core/upstream/CODE_OF_CONDUCT.md +59 -0
- data/rspec-core/upstream/CONTRIBUTING.md +86 -0
- data/rspec-core/upstream/Changelog.md +721 -2
- data/rspec-core/upstream/DEV-README.md +2 -2
- data/rspec-core/upstream/DEVELOPMENT.md +131 -0
- data/rspec-core/upstream/Filtering.md +173 -0
- data/rspec-core/upstream/Gemfile +78 -9
- data/rspec-core/upstream/ISSUE_TEMPLATE.md +24 -0
- data/rspec-core/upstream/{License.txt → LICENSE.md} +6 -5
- data/rspec-core/upstream/README.md +165 -24
- data/rspec-core/upstream/REPORT_TEMPLATE.md +43 -0
- data/rspec-core/upstream/Rakefile +1 -1
- data/rspec-core/upstream/benchmarks/allocations/1000_groups_1_example.rb +124 -0
- data/rspec-core/upstream/benchmarks/allocations/1_group_1000_examples.rb +63 -0
- data/rspec-core/upstream/benchmarks/allocations/helper.rb +30 -0
- data/rspec-core/upstream/benchmarks/allocations/running_1000_groups_1_example.rb +100 -0
- data/rspec-core/upstream/benchmarks/allocations/running_1_group_1000_examples.rb +60 -0
- data/rspec-core/upstream/benchmarks/capture_block_vs_yield.rb +208 -0
- data/rspec-core/upstream/benchmarks/flat_map_vs_inject.rb +55 -0
- data/rspec-core/upstream/benchmarks/hash_functions.rb +74 -0
- data/rspec-core/upstream/benchmarks/keys_each_vs_each_key.rb +43 -0
- data/rspec-core/upstream/benchmarks/module_inclusion_filtering.rb +89 -0
- data/rspec-core/upstream/benchmarks/precalculate_absolute_file_path_or_not.rb +29 -0
- data/rspec-core/upstream/benchmarks/shuffle_vs_sort_by_for_random_ordering.rb +131 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/helper.rb +122 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/with_config_hooks.rb +28 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/with_config_hooks_module_inclusions_and_shared_context_inclusions.rb +35 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/with_module_inclusions.rb +28 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/with_no_config_hooks_or_inclusions.rb +22 -0
- data/rspec-core/upstream/benchmarks/singleton_example_groups/with_shared_context_inclusions.rb +28 -0
- data/rspec-core/upstream/benchmarks/threadsafe_let_block.rb +312 -0
- data/rspec-core/upstream/cucumber.yml +7 -2
- data/rspec-core/upstream/features/.nav +5 -1
- data/rspec-core/upstream/features/README.md +2 -2
- data/rspec-core/upstream/features/clear_examples.feature +106 -0
- data/rspec-core/upstream/features/command_line/bisect.feature +178 -0
- data/rspec-core/upstream/features/command_line/example_matches_name_option.feature +131 -0
- data/rspec-core/upstream/features/command_line/example_name_option.feature +2 -0
- data/rspec-core/upstream/features/command_line/fail_fast.feature +21 -4
- data/rspec-core/upstream/features/command_line/init.feature +2 -2
- data/rspec-core/upstream/features/command_line/line_number_appended_to_path.feature +2 -2
- data/rspec-core/upstream/features/command_line/only_failures.feature +113 -0
- data/rspec-core/upstream/features/command_line/order.md +8 -1
- data/rspec-core/upstream/features/command_line/pattern_option.feature +6 -3
- data/rspec-core/upstream/features/command_line/rake_task.feature +3 -3
- data/rspec-core/upstream/features/command_line/randomization.feature +5 -2
- data/rspec-core/upstream/features/command_line/ruby.feature +6 -2
- data/rspec-core/upstream/features/command_line/tag.feature +13 -11
- data/rspec-core/upstream/features/command_line/warnings_option.feature +20 -3
- data/rspec-core/upstream/features/configuration/backtrace_exclusion_patterns.feature +45 -29
- data/rspec-core/upstream/features/configuration/color.feature +22 -0
- data/rspec-core/upstream/features/configuration/custom_settings.feature +9 -13
- data/rspec-core/upstream/features/configuration/default_path.feature +1 -1
- data/rspec-core/upstream/features/configuration/enable_global_dsl.feature +15 -1
- data/rspec-core/upstream/features/configuration/error_exit_code.feature +52 -0
- data/rspec-core/upstream/features/configuration/fail_fast.feature +42 -12
- data/rspec-core/upstream/features/configuration/fail_if_no_examples.feature +31 -0
- data/rspec-core/upstream/features/configuration/failure_exit_code.feature +26 -0
- data/rspec-core/upstream/features/configuration/overriding_global_ordering.feature +1 -1
- data/rspec-core/upstream/features/configuration/pattern.feature +1 -1
- data/rspec-core/upstream/features/configuration/profile.feature +25 -0
- data/rspec-core/upstream/features/configuration/read_options_from_file.feature +25 -19
- data/rspec-core/upstream/features/configuration/run_all_when_everything_filtered.feature +4 -0
- data/rspec-core/upstream/features/core_standalone.feature +2 -0
- data/rspec-core/upstream/features/example_groups/basic_structure.feature +1 -0
- data/rspec-core/upstream/features/example_groups/shared_context.feature +55 -5
- data/rspec-core/upstream/features/example_groups/shared_examples.feature +59 -15
- data/rspec-core/upstream/features/expectation_framework_integration/aggregating_failures.feature +602 -0
- data/rspec-core/upstream/features/expectation_framework_integration/configure_expectation_framework.feature +13 -5
- data/rspec-core/upstream/features/filtering/filter_run_when_matching.feature +75 -0
- data/rspec-core/upstream/features/formatters/configurable_colors.feature +23 -4
- data/rspec-core/upstream/features/helper_methods/let.feature +3 -0
- data/rspec-core/upstream/features/helper_methods/modules.feature +6 -0
- data/rspec-core/upstream/features/hooks/around_hooks.feature +36 -6
- data/rspec-core/upstream/features/hooks/before_and_after_hooks.feature +47 -5
- data/rspec-core/upstream/features/hooks/filtering.feature +199 -4
- data/rspec-core/upstream/features/hooks/when_first_matching_example_defined.feature +70 -0
- data/rspec-core/upstream/features/metadata/current_scope.feature +87 -0
- data/rspec-core/upstream/features/metadata/described_class.feature +12 -5
- data/rspec-core/upstream/features/metadata/user_defined.feature +3 -3
- data/rspec-core/upstream/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/rspec-core/upstream/features/mock_framework_integration/use_flexmock.feature +5 -5
- data/rspec-core/upstream/features/mock_framework_integration/use_mocha.feature +5 -5
- data/rspec-core/upstream/features/mock_framework_integration/use_rr.feature +5 -5
- data/rspec-core/upstream/features/mock_framework_integration/use_rspec.feature +6 -6
- data/rspec-core/upstream/features/pending_and_skipped_examples/pending_examples.feature +8 -7
- data/rspec-core/upstream/features/pending_and_skipped_examples/skipped_examples.feature +49 -22
- data/rspec-core/upstream/features/step_definitions/additional_cli_steps.rb +142 -12
- data/rspec-core/upstream/features/step_definitions/core_standalone_steps.rb +6 -2
- data/rspec-core/upstream/features/subject/implicit_subject.feature +3 -2
- data/rspec-core/upstream/features/subject/one_liner_syntax.feature +9 -5
- data/rspec-core/upstream/features/support/diff_lcs_versions.rb +17 -0
- data/rspec-core/upstream/features/support/env.rb +20 -7
- data/rspec-core/upstream/features/support/jruby.rb +8 -0
- data/rspec-core/upstream/features/support/require_expect_syntax_in_aruba_specs.rb +6 -3
- data/rspec-core/upstream/features/support/rubinius.rb +5 -1
- data/rspec-core/upstream/features/support/ruby_27_support.rb +7 -0
- data/rspec-core/upstream/features/support/send_sigint_during_bisect.rb +21 -0
- data/rspec-core/upstream/lib/rspec/autorun.rb +1 -0
- data/rspec-core/upstream/lib/rspec/core/backtrace_formatter.rb +3 -4
- data/rspec-core/upstream/lib/rspec/core/bisect/coordinator.rb +62 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/example_minimizer.rb +173 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/fork_runner.rb +138 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/server.rb +61 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/shell_command.rb +126 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/shell_runner.rb +73 -0
- data/rspec-core/upstream/lib/rspec/core/bisect/utilities.rb +69 -0
- data/rspec-core/upstream/lib/rspec/core/configuration.rb +1157 -212
- data/rspec-core/upstream/lib/rspec/core/configuration_options.rb +82 -22
- data/rspec-core/upstream/lib/rspec/core/did_you_mean.rb +46 -0
- data/rspec-core/upstream/lib/rspec/core/drb.rb +10 -1
- data/rspec-core/upstream/lib/rspec/core/dsl.rb +10 -5
- data/rspec-core/upstream/lib/rspec/core/example.rb +271 -107
- data/rspec-core/upstream/lib/rspec/core/example_group.rb +426 -127
- data/rspec-core/upstream/lib/rspec/core/example_status_persister.rb +235 -0
- data/rspec-core/upstream/lib/rspec/core/filter_manager.rb +76 -104
- data/rspec-core/upstream/lib/rspec/core/flat_map.rb +6 -4
- data/rspec-core/upstream/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/base_formatter.rb +7 -4
- data/rspec-core/upstream/lib/rspec/core/formatters/base_text_formatter.rb +15 -16
- data/rspec-core/upstream/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/bisect_progress_formatter.rb +157 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/console_codes.rb +28 -16
- data/rspec-core/upstream/lib/rspec/core/formatters/deprecation_formatter.rb +14 -13
- data/rspec-core/upstream/lib/rspec/core/formatters/documentation_formatter.rb +47 -13
- data/rspec-core/upstream/lib/rspec/core/formatters/exception_presenter.rb +525 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/helpers.rb +40 -9
- data/rspec-core/upstream/lib/rspec/core/formatters/html_formatter.rb +20 -16
- data/rspec-core/upstream/lib/rspec/core/formatters/html_printer.rb +27 -18
- data/rspec-core/upstream/lib/rspec/core/formatters/html_snippet_extractor.rb +120 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/json_formatter.rb +15 -7
- data/rspec-core/upstream/lib/rspec/core/formatters/profile_formatter.rb +10 -7
- data/rspec-core/upstream/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/rspec-core/upstream/lib/rspec/core/formatters/protocol.rb +62 -43
- data/rspec-core/upstream/lib/rspec/core/formatters/snippet_extractor.rb +115 -85
- data/rspec-core/upstream/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
- data/rspec-core/upstream/lib/rspec/core/formatters.rb +71 -32
- data/rspec-core/upstream/lib/rspec/core/hooks.rb +303 -248
- data/rspec-core/upstream/lib/rspec/core/invocations.rb +87 -0
- data/rspec-core/upstream/lib/rspec/core/memoized_helpers.rb +155 -47
- data/rspec-core/upstream/lib/rspec/core/metadata.rb +102 -41
- data/rspec-core/upstream/lib/rspec/core/metadata_filter.rb +209 -49
- data/rspec-core/upstream/lib/rspec/core/minitest_assertions_adapter.rb +5 -2
- data/rspec-core/upstream/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/rspec-core/upstream/lib/rspec/core/mocking_adapters/mocha.rb +8 -8
- data/rspec-core/upstream/lib/rspec/core/notifications.rb +180 -201
- data/rspec-core/upstream/lib/rspec/core/option_parser.rb +159 -58
- data/rspec-core/upstream/lib/rspec/core/ordering.rb +40 -26
- data/rspec-core/upstream/lib/rspec/core/output_wrapper.rb +29 -0
- data/rspec-core/upstream/lib/rspec/core/pending.rb +19 -25
- data/rspec-core/upstream/lib/rspec/core/profiler.rb +34 -0
- data/rspec-core/upstream/lib/rspec/core/project_initializer/.rspec +0 -1
- data/rspec-core/upstream/lib/rspec/core/project_initializer/spec/spec_helper.rb +31 -22
- data/rspec-core/upstream/lib/rspec/core/project_initializer.rb +1 -1
- data/rspec-core/upstream/lib/rspec/core/rake_task.rb +73 -72
- data/rspec-core/upstream/lib/rspec/core/reporter.rb +134 -18
- data/rspec-core/upstream/lib/rspec/core/ruby_project.rb +13 -5
- data/rspec-core/upstream/lib/rspec/core/runner.rb +99 -45
- data/rspec-core/upstream/lib/rspec/core/sandbox.rb +37 -0
- data/rspec-core/upstream/lib/rspec/core/set.rb +54 -0
- data/rspec-core/upstream/lib/rspec/core/shared_example_group.rb +126 -37
- data/rspec-core/upstream/lib/rspec/core/shell_escape.rb +49 -0
- data/rspec-core/upstream/lib/rspec/core/test_unit_assertions_adapter.rb +3 -3
- data/rspec-core/upstream/lib/rspec/core/version.rb +1 -1
- data/rspec-core/upstream/lib/rspec/core/warnings.rb +2 -2
- data/rspec-core/upstream/lib/rspec/core/world.rb +164 -60
- data/rspec-core/upstream/lib/rspec/core.rb +64 -21
- data/rspec-core/upstream/maintenance-branch +1 -1
- data/rspec-core/upstream/rspec-core.gemspec +16 -11
- data/rspec-core/upstream/script/ci_functions.sh +73 -0
- data/rspec-core/upstream/script/clone_all_rspec_repos +2 -2
- data/rspec-core/upstream/script/cucumber.sh +8 -0
- data/rspec-core/upstream/script/custom_build_functions.sh +22 -0
- data/rspec-core/upstream/script/functions.sh +125 -89
- data/rspec-core/upstream/script/legacy_setup.sh +20 -0
- data/rspec-core/upstream/script/predicate_functions.sh +162 -0
- data/rspec-core/upstream/script/rspec_with_simplecov +6 -6
- data/rspec-core/upstream/script/run_build +14 -9
- data/rspec-core/upstream/script/run_rubocop +14 -0
- data/rspec-core/upstream/script/update_rubygems_and_install_bundler +20 -0
- data/rspec-expectations/upstream/.document +1 -1
- data/rspec-expectations/upstream/.github/FUNDING.yml +5 -0
- data/rspec-expectations/upstream/.github/workflows/ci.yml +150 -0
- data/rspec-expectations/upstream/.gitignore +2 -0
- data/rspec-expectations/upstream/.rubocop.yml +126 -2
- data/rspec-expectations/upstream/.rubocop_rspec_base.yml +224 -38
- data/rspec-expectations/upstream/.rubocop_todo.yml +335 -0
- data/rspec-expectations/upstream/.yardopts +1 -1
- data/rspec-expectations/upstream/BUILD_DETAIL.md +149 -0
- data/rspec-expectations/upstream/CODE_OF_CONDUCT.md +59 -0
- data/rspec-expectations/upstream/CONTRIBUTING.md +86 -0
- data/rspec-expectations/upstream/Changelog.md +454 -4
- data/rspec-expectations/upstream/DEV-README.md +3 -3
- data/rspec-expectations/upstream/DEVELOPMENT.md +131 -0
- data/rspec-expectations/upstream/Gemfile +77 -9
- data/rspec-expectations/upstream/ISSUE_TEMPLATE.md +24 -0
- data/{rspec-mocks/upstream/License.txt → rspec-expectations/upstream/LICENSE.md} +5 -4
- data/rspec-expectations/upstream/README.md +73 -31
- data/rspec-expectations/upstream/REPORT_TEMPLATE.md +43 -0
- data/rspec-expectations/upstream/Rakefile +13 -10
- data/rspec-expectations/upstream/Should.md +13 -5
- data/rspec-expectations/upstream/benchmarks/2.x_vs_3.x_matcher_dsl_implementation.rb +1 -2
- data/rspec-expectations/upstream/benchmarks/caller_vs_raise_for_backtrace.rb +77 -0
- data/rspec-expectations/upstream/benchmarks/count_vs_select_size.rb +68 -0
- data/rspec-expectations/upstream/benchmarks/default_messages_as_methods_v_blocks.rb +1 -1
- data/rspec-expectations/upstream/benchmarks/gsub_vs_tr_single_character.rb +28 -0
- data/rspec-expectations/upstream/benchmarks/include_matcher.rb +249 -0
- data/rspec-expectations/upstream/benchmarks/include_v_superclass.rb +0 -1
- data/rspec-expectations/upstream/benchmarks/match_array/failing_with_duplicate_items.rb +1 -1
- data/rspec-expectations/upstream/benchmarks/output_stringio_vs_tempfile.rb +31 -0
- data/rspec-expectations/upstream/benchmarks/set_vs_array_include.rb +1 -3
- data/rspec-expectations/upstream/cucumber.yml +9 -4
- data/rspec-expectations/upstream/features/.nav +1 -0
- data/rspec-expectations/upstream/features/aggregating_failures.feature +56 -0
- data/rspec-expectations/upstream/features/built_in_matchers/README.md +3 -3
- data/rspec-expectations/upstream/features/built_in_matchers/all.feature +3 -2
- data/rspec-expectations/upstream/features/built_in_matchers/be_within.feature +1 -1
- data/rspec-expectations/upstream/features/built_in_matchers/change.feature +8 -6
- data/rspec-expectations/upstream/features/built_in_matchers/comparisons.feature +33 -1
- data/rspec-expectations/upstream/features/built_in_matchers/contain_exactly.feature +1 -0
- data/rspec-expectations/upstream/features/built_in_matchers/cover.feature +3 -3
- data/rspec-expectations/upstream/features/built_in_matchers/exist.feature +1 -1
- data/rspec-expectations/upstream/features/built_in_matchers/have_attributes.feature +1 -2
- data/rspec-expectations/upstream/features/built_in_matchers/include.feature +74 -17
- data/rspec-expectations/upstream/features/built_in_matchers/match.feature +2 -2
- data/rspec-expectations/upstream/features/built_in_matchers/output.feature +67 -4
- data/rspec-expectations/upstream/features/built_in_matchers/predicates.feature +56 -19
- data/rspec-expectations/upstream/features/built_in_matchers/raise_error.feature +16 -2
- data/rspec-expectations/upstream/features/built_in_matchers/respond_to.feature +191 -3
- data/rspec-expectations/upstream/features/built_in_matchers/satisfy.feature +17 -8
- data/rspec-expectations/upstream/features/built_in_matchers/throw_symbol.feature +1 -1
- data/rspec-expectations/upstream/features/built_in_matchers/types.feature +34 -34
- data/rspec-expectations/upstream/features/built_in_matchers/yield.feature +2 -2
- data/rspec-expectations/upstream/features/composing_matchers.feature +4 -4
- data/rspec-expectations/upstream/features/custom_matchers/define_block_matcher.feature +78 -0
- data/rspec-expectations/upstream/features/custom_matchers/define_diffable_matcher.feature +115 -3
- data/rspec-expectations/upstream/features/custom_matchers/define_matcher.feature +173 -21
- data/rspec-expectations/upstream/features/custom_matchers/define_matcher_with_fluent_interface.feature +21 -2
- data/rspec-expectations/upstream/features/define_negated_matcher.feature +2 -1
- data/rspec-expectations/upstream/features/diffing.feature +29 -1
- data/rspec-expectations/upstream/features/implicit_docstrings.feature +8 -8
- data/rspec-expectations/upstream/features/step_definitions/additional_cli_steps.rb +11 -7
- data/rspec-expectations/upstream/features/support/diff_lcs_versions.rb +25 -0
- data/rspec-expectations/upstream/features/support/disallow_certain_apis.rb +3 -3
- data/rspec-expectations/upstream/features/support/env.rb +11 -11
- data/rspec-expectations/upstream/features/support/rubinius.rb +1 -1
- data/rspec-expectations/upstream/features/support/ruby_features.rb +39 -0
- data/rspec-expectations/upstream/features/syntax_configuration.feature +9 -9
- data/rspec-expectations/upstream/features/test_frameworks/minitest.feature +69 -2
- data/rspec-expectations/upstream/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
- data/rspec-expectations/upstream/lib/rspec/expectations/configuration.rb +84 -1
- data/rspec-expectations/upstream/lib/rspec/expectations/expectation_target.rb +82 -38
- data/rspec-expectations/upstream/lib/rspec/expectations/fail_with.rb +11 -6
- data/rspec-expectations/upstream/lib/rspec/expectations/failure_aggregator.rb +212 -0
- data/rspec-expectations/upstream/lib/rspec/expectations/handler.rb +27 -12
- data/rspec-expectations/upstream/lib/rspec/expectations/minitest_integration.rb +43 -2
- data/rspec-expectations/upstream/lib/rspec/expectations/syntax.rb +5 -5
- data/rspec-expectations/upstream/lib/rspec/expectations/version.rb +1 -1
- data/rspec-expectations/upstream/lib/rspec/expectations.rb +15 -1
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/all.rb +1 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/base_matcher.rb +77 -11
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/be.rb +28 -114
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/be_between.rb +1 -1
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/be_instance_of.rb +5 -1
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/be_kind_of.rb +5 -1
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/be_within.rb +4 -4
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/change.rb +168 -55
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/compound.rb +61 -29
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/contain_exactly.rb +73 -12
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/count_expectation.rb +169 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/eq.rb +3 -38
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/eql.rb +2 -2
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/equal.rb +3 -3
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/exist.rb +7 -3
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/has.rb +90 -24
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/have_attributes.rb +37 -7
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/include.rb +124 -23
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/match.rb +79 -2
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/operators.rb +14 -5
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/output.rb +56 -1
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/raise_error.rb +126 -29
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/respond_to.rb +118 -9
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/satisfy.rb +28 -7
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/{start_and_end_with.rb → start_or_end_with.rb} +20 -8
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/throw_symbol.rb +11 -5
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in/yield.rb +110 -155
- data/rspec-expectations/upstream/lib/rspec/matchers/built_in.rb +4 -3
- data/rspec-expectations/upstream/lib/rspec/matchers/composable.rb +23 -35
- data/rspec-expectations/upstream/lib/rspec/matchers/dsl.rb +179 -26
- data/rspec-expectations/upstream/lib/rspec/matchers/english_phrasing.rb +58 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +82 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/fail_matchers.rb +42 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/generated_descriptions.rb +1 -2
- data/rspec-expectations/upstream/lib/rspec/matchers/matcher_delegator.rb +2 -0
- data/rspec-expectations/upstream/lib/rspec/matchers/matcher_protocol.rb +72 -66
- data/rspec-expectations/upstream/lib/rspec/matchers.rb +227 -150
- data/rspec-expectations/upstream/maintenance-branch +1 -1
- data/rspec-expectations/upstream/rspec-expectations.gemspec +13 -8
- data/rspec-expectations/upstream/script/ci_functions.sh +73 -0
- data/rspec-expectations/upstream/script/clone_all_rspec_repos +2 -2
- data/rspec-expectations/upstream/script/cucumber.sh +8 -0
- data/rspec-expectations/upstream/script/functions.sh +125 -89
- data/rspec-expectations/upstream/script/legacy_setup.sh +20 -0
- data/rspec-expectations/upstream/script/predicate_functions.sh +162 -0
- data/rspec-expectations/upstream/script/run_build +14 -9
- data/rspec-expectations/upstream/script/run_rubocop +14 -0
- data/rspec-expectations/upstream/script/update_rubygems_and_install_bundler +20 -0
- data/rspec-mocks/upstream/.document +1 -1
- data/rspec-mocks/upstream/.github/FUNDING.yml +5 -0
- data/rspec-mocks/upstream/.github/workflows/ci.yml +150 -0
- data/rspec-mocks/upstream/.gitignore +2 -0
- data/rspec-mocks/upstream/.rubocop.yml +28 -9
- data/rspec-mocks/upstream/.rubocop_rspec_base.yml +224 -38
- data/rspec-mocks/upstream/.rubocop_todo.yml +573 -0
- data/rspec-mocks/upstream/.yardopts +1 -1
- data/rspec-mocks/upstream/BUILD_DETAIL.md +149 -0
- data/rspec-mocks/upstream/CODE_OF_CONDUCT.md +59 -0
- data/rspec-mocks/upstream/CONTRIBUTING.md +86 -0
- data/rspec-mocks/upstream/Changelog.md +398 -3
- data/rspec-mocks/upstream/DEV-README.md +3 -3
- data/rspec-mocks/upstream/DEVELOPMENT.md +131 -0
- data/rspec-mocks/upstream/Gemfile +77 -10
- data/rspec-mocks/upstream/ISSUE_TEMPLATE.md +24 -0
- data/{rspec-expectations/upstream/License.txt → rspec-mocks/upstream/LICENSE.md} +5 -4
- data/rspec-mocks/upstream/README.md +83 -17
- data/rspec-mocks/upstream/REPORT_TEMPLATE.md +43 -0
- data/rspec-mocks/upstream/Rakefile +3 -3
- data/rspec-mocks/upstream/benchmarks/accessing_configuration_via_method_vs_cache.rb +52 -0
- data/rspec-mocks/upstream/benchmarks/allocations/1_object_1000_mocks.rb +76 -0
- data/rspec-mocks/upstream/benchmarks/allocations/helper.rb +17 -0
- data/rspec-mocks/upstream/benchmarks/each_value_v_values_each.rb +4 -5
- data/rspec-mocks/upstream/benchmarks/find_original_method_early.rb +1 -1
- data/rspec-mocks/upstream/benchmarks/method_defined_at_any_visibility.rb +3 -3
- data/rspec-mocks/upstream/benchmarks/thread_safety.rb +1 -1
- data/rspec-mocks/upstream/benchmarks/transfer_nested_constants.rb +1 -1
- data/rspec-mocks/upstream/cucumber.yml +8 -1
- data/rspec-mocks/upstream/features/.nav +2 -0
- data/rspec-mocks/upstream/features/basics/allowing_messages.feature +1 -1
- data/rspec-mocks/upstream/features/basics/expecting_messages.feature +40 -1
- data/rspec-mocks/upstream/features/basics/null_object_doubles.feature +1 -1
- data/rspec-mocks/upstream/features/basics/partial_test_doubles.feature +1 -1
- data/rspec-mocks/upstream/features/basics/scope.feature +5 -5
- data/rspec-mocks/upstream/features/basics/spies.feature +17 -30
- data/rspec-mocks/upstream/features/basics/test_doubles.feature +4 -4
- data/rspec-mocks/upstream/features/configuring_responses/README.md +2 -0
- data/rspec-mocks/upstream/features/configuring_responses/calling_the_original_implementation.feature +2 -2
- data/rspec-mocks/upstream/features/configuring_responses/mixed_responses.feature +25 -0
- data/rspec-mocks/upstream/features/configuring_responses/raising_an_error.feature +1 -0
- data/rspec-mocks/upstream/features/configuring_responses/wrapping_the_original_implementation.feature +3 -3
- data/rspec-mocks/upstream/features/configuring_responses/yielding.feature +2 -2
- data/rspec-mocks/upstream/features/mutating_constants/README.md +1 -1
- data/rspec-mocks/upstream/features/old_syntax/any_instance.feature +3 -3
- data/rspec-mocks/upstream/features/old_syntax/should_receive.feature +3 -1
- data/rspec-mocks/upstream/features/outside_rspec/any_test_framework.feature +116 -0
- data/rspec-mocks/upstream/features/outside_rspec/minitest.feature +202 -46
- data/rspec-mocks/upstream/features/outside_rspec/standalone.feature +5 -5
- data/rspec-mocks/upstream/features/setting_constraints/matching_arguments.feature +54 -27
- data/rspec-mocks/upstream/features/setting_constraints/message_order.feature +2 -2
- data/rspec-mocks/upstream/features/setting_constraints/receive_counts.feature +18 -0
- data/rspec-mocks/upstream/features/step_definitions/additional_cli_steps.rb +4 -4
- data/rspec-mocks/upstream/features/support/disallow_certain_apis.rb +3 -2
- data/rspec-mocks/upstream/features/support/env.rb +12 -12
- data/rspec-mocks/upstream/features/support/rubinius.rb +1 -1
- data/rspec-mocks/upstream/features/verifying_doubles/README.md +2 -2
- data/rspec-mocks/upstream/features/verifying_doubles/class_doubles.feature +1 -1
- data/rspec-mocks/upstream/features/verifying_doubles/dynamic_classes.feature +41 -5
- data/rspec-mocks/upstream/features/verifying_doubles/instance_doubles.feature +5 -3
- data/rspec-mocks/upstream/features/working_with_legacy_code/any_instance.feature +8 -6
- data/rspec-mocks/upstream/features/working_with_legacy_code/message_chains.feature +16 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/chain.rb +3 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/expect_chain_chain.rb +1 -5
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/expectation_chain.rb +7 -5
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/message_chains.rb +1 -3
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/recorder.rb +42 -14
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/stub_chain.rb +13 -7
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance/stub_chain_chain.rb +1 -5
- data/rspec-mocks/upstream/lib/rspec/mocks/any_instance.rb +1 -0
- data/rspec-mocks/upstream/lib/rspec/mocks/argument_list_matcher.rb +53 -10
- data/rspec-mocks/upstream/lib/rspec/mocks/argument_matchers.rb +66 -26
- data/rspec-mocks/upstream/lib/rspec/mocks/configuration.rb +59 -4
- data/rspec-mocks/upstream/lib/rspec/mocks/error_generator.rb +235 -108
- data/rspec-mocks/upstream/lib/rspec/mocks/example_methods.rb +82 -27
- data/rspec-mocks/upstream/lib/rspec/mocks/instance_method_stasher.rb +12 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/matchers/have_received.rb +30 -17
- data/rspec-mocks/upstream/lib/rspec/mocks/matchers/receive.rb +28 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/matchers/receive_message_chain.rb +17 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/matchers/receive_messages.rb +6 -0
- data/rspec-mocks/upstream/lib/rspec/mocks/message_chain.rb +0 -4
- data/rspec-mocks/upstream/lib/rspec/mocks/message_expectation.rb +430 -304
- data/rspec-mocks/upstream/lib/rspec/mocks/method_double.rb +46 -15
- data/rspec-mocks/upstream/lib/rspec/mocks/method_reference.rb +78 -19
- data/rspec-mocks/upstream/lib/rspec/mocks/minitest_integration.rb +68 -0
- data/rspec-mocks/upstream/lib/rspec/mocks/mutate_const.rb +23 -8
- data/rspec-mocks/upstream/lib/rspec/mocks/object_reference.rb +81 -23
- data/rspec-mocks/upstream/lib/rspec/mocks/proxy.rb +135 -41
- data/rspec-mocks/upstream/lib/rspec/mocks/space.rb +33 -16
- data/rspec-mocks/upstream/lib/rspec/mocks/standalone.rb +1 -1
- data/rspec-mocks/upstream/lib/rspec/mocks/syntax.rb +18 -22
- data/rspec-mocks/upstream/lib/rspec/mocks/targets.rb +51 -24
- data/rspec-mocks/upstream/lib/rspec/mocks/test_double.rb +42 -6
- data/rspec-mocks/upstream/lib/rspec/mocks/verifying_double.rb +15 -21
- data/rspec-mocks/upstream/lib/rspec/mocks/{verifying_message_expecation.rb → verifying_message_expectation.rb} +11 -18
- data/rspec-mocks/upstream/lib/rspec/mocks/verifying_proxy.rb +60 -11
- data/rspec-mocks/upstream/lib/rspec/mocks/version.rb +1 -1
- data/rspec-mocks/upstream/lib/rspec/mocks.rb +8 -1
- data/rspec-mocks/upstream/maintenance-branch +1 -1
- data/rspec-mocks/upstream/rspec-mocks.gemspec +14 -6
- data/rspec-mocks/upstream/script/ci_functions.sh +73 -0
- data/rspec-mocks/upstream/script/clone_all_rspec_repos +2 -2
- data/rspec-mocks/upstream/script/cucumber.sh +8 -0
- data/rspec-mocks/upstream/script/functions.sh +125 -89
- data/rspec-mocks/upstream/script/legacy_setup.sh +20 -0
- data/rspec-mocks/upstream/script/predicate_functions.sh +162 -0
- data/rspec-mocks/upstream/script/run_build +14 -9
- data/rspec-mocks/upstream/script/run_rubocop +14 -0
- data/rspec-mocks/upstream/script/update_rubygems_and_install_bundler +20 -0
- data/{stubs/diff/lcs/assertions.rb → rspec-mocks/upstream/tmp/.gitkeep} +0 -0
- data/rspec-support/upstream/.github/FUNDING.yml +5 -0
- data/rspec-support/upstream/.github/workflows/ci.yml +150 -0
- data/rspec-support/upstream/.gitignore +4 -0
- data/rspec-support/upstream/.rubocop.yml +33 -1
- data/rspec-support/upstream/.rubocop_rspec_base.yml +224 -38
- data/rspec-support/upstream/.rubocop_todo.yml +424 -0
- data/rspec-support/upstream/BUILD_DETAIL.md +149 -0
- data/rspec-support/upstream/CODE_OF_CONDUCT.md +59 -0
- data/rspec-support/upstream/CONTRIBUTING.md +86 -0
- data/rspec-support/upstream/Changelog.md +287 -0
- data/rspec-support/upstream/DEVELOPMENT.md +131 -0
- data/rspec-support/upstream/Gemfile +52 -4
- data/rspec-support/upstream/ISSUE_TEMPLATE.md +24 -0
- data/rspec-support/upstream/{LICENSE.txt → LICENSE.md} +3 -2
- data/rspec-support/upstream/README.md +29 -6
- data/rspec-support/upstream/REPORT_TEMPLATE.md +43 -0
- data/rspec-support/upstream/Rakefile +9 -5
- data/rspec-support/upstream/benchmarks/caller_vs_caller_locations.rb +19 -0
- data/rspec-support/upstream/benchmarks/caller_vs_caller_locations_vs_raise.rb +153 -0
- data/rspec-support/upstream/benchmarks/class_exec_vs_klass_exec.rb +43 -0
- data/rspec-support/upstream/benchmarks/map_hash.rb +70 -0
- data/rspec-support/upstream/benchmarks/ripper.rb +44 -0
- data/rspec-support/upstream/benchmarks/skip_frames_for_caller_filter.rb +27 -0
- data/rspec-support/upstream/lib/rspec/support/caller_filter.rb +35 -15
- data/rspec-support/upstream/lib/rspec/support/comparable_version.rb +46 -0
- data/rspec-support/upstream/lib/rspec/support/differ.rb +35 -34
- data/rspec-support/upstream/lib/rspec/support/directory_maker.rb +3 -1
- data/rspec-support/upstream/lib/rspec/support/encoded_string.rb +103 -11
- data/rspec-support/upstream/lib/rspec/support/fuzzy_matcher.rb +5 -5
- data/rspec-support/upstream/lib/rspec/support/matcher_definition.rb +11 -0
- data/rspec-support/upstream/lib/rspec/support/method_signature_verifier.rb +192 -26
- data/rspec-support/upstream/lib/rspec/support/mutex.rb +73 -0
- data/rspec-support/upstream/lib/rspec/support/object_formatter.rb +275 -0
- data/rspec-support/upstream/lib/rspec/support/recursive_const_methods.rb +1 -1
- data/rspec-support/upstream/lib/rspec/support/reentrant_mutex.rb +78 -0
- data/rspec-support/upstream/lib/rspec/support/ruby_features.rb +168 -15
- data/rspec-support/upstream/lib/rspec/support/source/location.rb +21 -0
- data/rspec-support/upstream/lib/rspec/support/source/node.rb +110 -0
- data/rspec-support/upstream/lib/rspec/support/source/token.rb +94 -0
- data/rspec-support/upstream/lib/rspec/support/source.rb +85 -0
- data/rspec-support/upstream/lib/rspec/support/spec/deprecation_helpers.rb +17 -29
- data/rspec-support/upstream/lib/rspec/support/spec/diff_helpers.rb +31 -0
- data/rspec-support/upstream/lib/rspec/support/spec/in_sub_process.rb +41 -17
- data/rspec-support/upstream/lib/rspec/support/spec/library_wide_checks.rb +150 -0
- data/rspec-support/upstream/lib/rspec/support/spec/shell_out.rb +39 -3
- data/rspec-support/upstream/lib/rspec/support/spec/stderr_splitter.rb +27 -4
- data/rspec-support/upstream/lib/rspec/support/spec/string_matcher.rb +45 -0
- data/rspec-support/upstream/lib/rspec/support/spec/with_isolated_directory.rb +5 -1
- data/rspec-support/upstream/lib/rspec/support/spec.rb +17 -7
- data/rspec-support/upstream/lib/rspec/support/version.rb +1 -1
- data/rspec-support/upstream/lib/rspec/support/warnings.rb +3 -3
- data/rspec-support/upstream/lib/rspec/support/with_keywords_when_needed.rb +33 -0
- data/rspec-support/upstream/lib/rspec/support.rb +81 -3
- data/rspec-support/upstream/maintenance-branch +1 -1
- data/rspec-support/upstream/rspec-support.gemspec +10 -4
- data/rspec-support/upstream/script/ci_functions.sh +73 -0
- data/rspec-support/upstream/script/clone_all_rspec_repos +2 -2
- data/rspec-support/upstream/script/cucumber.sh +8 -0
- data/rspec-support/upstream/script/functions.sh +125 -89
- data/rspec-support/upstream/script/legacy_setup.sh +20 -0
- data/rspec-support/upstream/script/predicate_functions.sh +162 -0
- data/rspec-support/upstream/script/run_build +14 -9
- data/rspec-support/upstream/script/run_rubocop +14 -0
- data/rspec-support/upstream/script/update_rubygems_and_install_bundler +20 -0
- data/stubs/{diff/lcs/block.rb → coderay.rb} +0 -0
- data/stubs/{diff/lcs/callbacks.rb → drb/acl.rb} +0 -0
- data/stubs/{diff/lcs/change.rb → erb/version.rb} +0 -0
- data/stubs/{diff/lcs/hunk.rb → open3.rb} +0 -0
- data/stubs/{diff/lcs/internals.rb → psych.rb} +0 -0
- data/stubs/{optparse.rb → ripper.rb} +0 -0
- data/stubs/{prettyprint.rb → thread_order.rb} +0 -0
- data/tasks/testing.rake +7 -3
- metadata +272 -63
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/opal_0.11.gemfile +0 -14
- data/gemfiles/opal_master.gemfile +0 -14
- data/lib-opal/opal/rspec/async/core_ext.rb +0 -23
- data/lib-opal/opal/rspec/async/legacy.rb +0 -49
- data/lib-opal/opal/rspec/fixes/rspec/caller_filter.rb +0 -6
- data/lib-opal/opal/rspec/fixes/rspec/core/example.rb +0 -20
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/backtrace_formatter.rb +0 -20
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/console_codes.rb +0 -11
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/generated_deprecation_message.rb +0 -15
- data/lib-opal/opal/rspec/fixes/rspec/core/formatters/json_formatter.rb +0 -15
- data/lib-opal/opal/rspec/fixes/rspec/core/notifications/failed_example_notification.rb +0 -20
- data/lib-opal/opal/rspec/fixes/rspec/core/notifications/summary_notification.rb +0 -21
- data/lib-opal/opal/rspec/fixes/rspec/core/warnings.rb +0 -27
- data/lib-opal/opal/rspec/fixes/rspec/expectations/fail_with.rb +0 -21
- data/lib-opal/opal/rspec/fixes/rspec/matchers/built_in/all.rb +0 -10
- data/lib-opal/opal/rspec/fixes/rspec/matchers/built_in/compound.rb +0 -15
- data/lib-opal/opal/rspec/fixes/rspec/matchers/built_in/yield.rb +0 -21
- data/lib-opal/opal/rspec/fixes/rspec/matchers/pretty.rb +0 -15
- data/lib-opal/opal/rspec/fixes/rspec/mocks/space.rb +0 -41
- data/lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb +0 -39
- data/lib-opal/opal/rspec/fixes/rspec/mocks/verifying_double.rb +0 -29
- data/lib-opal/opal/rspec/fixes/rspec/support/recursive_const_methods.rb +0 -7
- data/lib-opal/opal/rspec/fixes/rspec/support/spec/stderr_splitter.rb +0 -13
- data/lib-opal/opal/rspec/fixes/rspec/support/spec.rb +0 -1
- data/lib-opal/opal/rspec/fixes/rspec/support/warnings.rb +0 -16
- data/rspec/upstream/License.txt +0 -24
- data/rspec-core/upstream/.travis.yml +0 -35
- data/rspec-core/upstream/benchmarks/sort_by_v_shuffle.rb +0 -83
- data/rspec-core/upstream/features/Upgrade.md +0 -352
- data/rspec-core/upstream/lib/rspec/core/backport_random.rb +0 -336
- data/rspec-expectations/upstream/.travis.yml +0 -35
- data/rspec-expectations/upstream/lib/rspec/matchers/pretty.rb +0 -77
- data/rspec-mocks/upstream/.travis.yml +0 -35
- data/rspec-support/upstream/.travis.yml +0 -35
- data/rspec-support/upstream/lib/rspec/support/os.rb +0 -18
- data/rspec-support/upstream/lib/rspec/support/spec/prevent_load_time_warnings.rb +0 -44
- data/rspec-support/upstream/lib/rspec/support/version_checker.rb +0 -53
- data/stubs/shellwords.rb +0 -0
- data/stubs/uri.rb +0 -0
- data/vendor/spec_runner.js +0 -64
@@ -1,17 +1,32 @@
|
|
1
1
|
RSpec::Support.require_rspec_core "backtrace_formatter"
|
2
2
|
RSpec::Support.require_rspec_core "ruby_project"
|
3
3
|
RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
|
4
|
+
RSpec::Support.require_rspec_core "output_wrapper"
|
4
5
|
|
5
6
|
module RSpec
|
6
7
|
module Core
|
7
|
-
# rubocop:disable
|
8
|
+
# rubocop:disable Metrics/ClassLength
|
8
9
|
|
9
10
|
# Stores runtime configuration information.
|
10
11
|
#
|
11
|
-
# Configuration options are loaded from
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
12
|
+
# Configuration options are loaded from multiple files and joined together
|
13
|
+
# with command-line switches and the `SPEC_OPTS` environment variable.
|
14
|
+
#
|
15
|
+
# Precedence order (where later entries overwrite earlier entries on
|
16
|
+
# conflicts):
|
17
|
+
#
|
18
|
+
# * Global (`$XDG_CONFIG_HOME/rspec/options`, or `~/.rspec` if it does
|
19
|
+
# not exist)
|
20
|
+
# * Project-specific (`./.rspec`)
|
21
|
+
# * Local (`./.rspec-local`)
|
22
|
+
# * Command-line options
|
23
|
+
# * `SPEC_OPTS`
|
24
|
+
#
|
25
|
+
# For example, an option set in the local file will override an option set
|
26
|
+
# in your global file.
|
27
|
+
#
|
28
|
+
# The global, project-specific and local files can all be overridden with a
|
29
|
+
# separate custom file using the --options command-line parameter.
|
15
30
|
#
|
16
31
|
# @example Standard settings
|
17
32
|
# RSpec.configure do |c|
|
@@ -32,27 +47,37 @@ module RSpec
|
|
32
47
|
class Configuration
|
33
48
|
include RSpec::Core::Hooks
|
34
49
|
|
50
|
+
# Module that holds `attr_reader` declarations. It's in a separate
|
51
|
+
# module to allow us to override those methods and use `super`.
|
52
|
+
# @private
|
53
|
+
Readers = Module.new
|
54
|
+
include Readers
|
55
|
+
|
35
56
|
# @private
|
36
57
|
class MustBeConfiguredBeforeExampleGroupsError < StandardError; end
|
37
58
|
|
38
59
|
# @private
|
39
60
|
def self.define_reader(name)
|
40
|
-
|
41
|
-
|
42
|
-
|
61
|
+
Readers.class_eval do
|
62
|
+
remove_method name if method_defined?(name)
|
63
|
+
attr_reader name
|
43
64
|
end
|
65
|
+
|
66
|
+
define_method(name) { value_for(name) { super() } }
|
44
67
|
end
|
45
68
|
|
46
69
|
# @private
|
47
|
-
def self.
|
70
|
+
def self.define_alias(name, alias_name)
|
48
71
|
alias_method alias_name, name
|
49
72
|
alias_method "#{alias_name}=", "#{name}="
|
50
|
-
|
73
|
+
define_predicate alias_name
|
51
74
|
end
|
52
75
|
|
53
76
|
# @private
|
54
|
-
def self.
|
55
|
-
|
77
|
+
def self.define_predicate(name)
|
78
|
+
define_method "#{name}?" do
|
79
|
+
!!send(name)
|
80
|
+
end
|
56
81
|
end
|
57
82
|
|
58
83
|
# @private
|
@@ -65,22 +90,21 @@ module RSpec
|
|
65
90
|
add_read_only_setting name
|
66
91
|
|
67
92
|
Array(opts[:alias_with]).each do |alias_name|
|
68
|
-
|
93
|
+
define_alias(name, alias_name)
|
69
94
|
end
|
70
95
|
end
|
71
96
|
|
72
97
|
# @private
|
73
98
|
#
|
74
|
-
# As `add_setting` but only add the reader
|
99
|
+
# As `add_setting` but only add the reader.
|
75
100
|
def self.add_read_only_setting(name, opts={})
|
76
101
|
raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
|
77
102
|
define_reader name
|
78
|
-
|
103
|
+
define_predicate name
|
79
104
|
end
|
80
105
|
|
81
106
|
# @macro [attach] add_setting
|
82
107
|
# @!attribute [rw] $1
|
83
|
-
# @!method $1=(value)
|
84
108
|
#
|
85
109
|
# @macro [attach] define_reader
|
86
110
|
# @!attribute [r] $1
|
@@ -90,13 +114,19 @@ module RSpec
|
|
90
114
|
# `"spec"`). Allows you to just type `rspec` instead of `rspec spec` to
|
91
115
|
# run all the examples in the `spec` directory.
|
92
116
|
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
117
|
+
# @note Other scripts invoking `rspec` indirectly will ignore this
|
118
|
+
# setting.
|
119
|
+
# @return [String]
|
120
|
+
add_read_only_setting :default_path
|
121
|
+
def default_path=(path)
|
122
|
+
project_source_dirs << path
|
123
|
+
@default_path = path
|
124
|
+
end
|
96
125
|
|
97
126
|
# @macro add_setting
|
98
127
|
# Run examples over DRb (default: `false`). RSpec doesn't supply the DRb
|
99
128
|
# server, but you can use tools like spork.
|
129
|
+
# @return [Boolean]
|
100
130
|
add_setting :drb
|
101
131
|
|
102
132
|
# @macro add_setting
|
@@ -109,6 +139,7 @@ module RSpec
|
|
109
139
|
|
110
140
|
# Indicates if the DSL has been exposed off of modules and `main`.
|
111
141
|
# Default: true
|
142
|
+
# @return [Boolean]
|
112
143
|
def expose_dsl_globally?
|
113
144
|
Core::DSL.exposed_globally?
|
114
145
|
end
|
@@ -129,7 +160,7 @@ module RSpec
|
|
129
160
|
|
130
161
|
# Determines where deprecation warnings are printed.
|
131
162
|
# Defaults to `$stderr`.
|
132
|
-
# @return [IO, String] IO
|
163
|
+
# @return [IO, String] IO or filename to write to
|
133
164
|
define_reader :deprecation_stream
|
134
165
|
|
135
166
|
# Determines where deprecation warnings are printed.
|
@@ -146,9 +177,60 @@ module RSpec
|
|
146
177
|
end
|
147
178
|
end
|
148
179
|
|
149
|
-
# @macro
|
150
|
-
#
|
151
|
-
|
180
|
+
# @macro define_reader
|
181
|
+
# The file path to use for persisting example statuses. Necessary for the
|
182
|
+
# `--only-failures` and `--next-failure` CLI options.
|
183
|
+
#
|
184
|
+
# @overload example_status_persistence_file_path
|
185
|
+
# @return [String] the file path
|
186
|
+
# @overload example_status_persistence_file_path=(value)
|
187
|
+
# @param value [String] the file path
|
188
|
+
define_reader :example_status_persistence_file_path
|
189
|
+
|
190
|
+
# Sets the file path to use for persisting example statuses. Necessary for the
|
191
|
+
# `--only-failures` and `--next-failure` CLI options.
|
192
|
+
def example_status_persistence_file_path=(value)
|
193
|
+
@example_status_persistence_file_path = value
|
194
|
+
clear_values_derived_from_example_status_persistence_file_path
|
195
|
+
end
|
196
|
+
|
197
|
+
# @macro define_reader
|
198
|
+
# Indicates if the `--only-failures` (or `--next-failure`) flag is being used.
|
199
|
+
define_reader :only_failures
|
200
|
+
alias_method :only_failures?, :only_failures
|
201
|
+
|
202
|
+
# @private
|
203
|
+
def only_failures_but_not_configured?
|
204
|
+
only_failures? && !example_status_persistence_file_path
|
205
|
+
end
|
206
|
+
|
207
|
+
# @macro define_reader
|
208
|
+
# If specified, indicates the number of failures required before cleaning
|
209
|
+
# up and exit (default: `nil`). Can also be `true` to fail and exit on first
|
210
|
+
# failure
|
211
|
+
define_reader :fail_fast
|
212
|
+
|
213
|
+
# @see fail_fast
|
214
|
+
def fail_fast=(value)
|
215
|
+
case value
|
216
|
+
when true, 'true'
|
217
|
+
@fail_fast = true
|
218
|
+
when false, 'false', 0
|
219
|
+
@fail_fast = false
|
220
|
+
when nil
|
221
|
+
@fail_fast = nil
|
222
|
+
else
|
223
|
+
@fail_fast = value.to_i
|
224
|
+
|
225
|
+
if value.to_i == 0
|
226
|
+
# TODO: in RSpec 4, consider raising an error here.
|
227
|
+
RSpec.warning "Cannot set `RSpec.configuration.fail_fast`" \
|
228
|
+
" to `#{value.inspect}`. Only `true`, `false`, `nil` and integers" \
|
229
|
+
" are valid values."
|
230
|
+
@fail_fast = true
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
152
234
|
|
153
235
|
# @macro add_setting
|
154
236
|
# Prints the formatter output of your suite without running any
|
@@ -157,23 +239,38 @@ module RSpec
|
|
157
239
|
|
158
240
|
# @macro add_setting
|
159
241
|
# The exit code to return if there are any failures (default: 1).
|
242
|
+
# @return [Integer]
|
160
243
|
add_setting :failure_exit_code
|
161
244
|
|
245
|
+
# @macro add_setting
|
246
|
+
# The exit code to return if there are any errors outside examples (default: failure_exit_code)
|
247
|
+
# @return [Integer]
|
248
|
+
add_setting :error_exit_code
|
249
|
+
|
250
|
+
# @macro add_setting
|
251
|
+
# Whether or not to fail when there are no RSpec examples (default: false).
|
252
|
+
# @return [Boolean]
|
253
|
+
add_setting :fail_if_no_examples
|
254
|
+
|
162
255
|
# @macro define_reader
|
163
|
-
# Indicates files configured to be required
|
256
|
+
# Indicates files configured to be required.
|
257
|
+
# @return [Array<String>]
|
164
258
|
define_reader :requires
|
165
259
|
|
166
260
|
# @macro define_reader
|
167
|
-
# Returns dirs that have been prepended to the load path by the `-I`
|
261
|
+
# Returns dirs that have been prepended to the load path by the `-I`
|
262
|
+
# command line option.
|
263
|
+
# @return [Array<String>]
|
168
264
|
define_reader :libs
|
169
265
|
|
170
266
|
# @macro add_setting
|
171
267
|
# Determines where RSpec will send its output.
|
172
268
|
# Default: `$stdout`.
|
269
|
+
# @return [IO, String]
|
173
270
|
define_reader :output_stream
|
174
271
|
|
175
|
-
# Set the output stream for reporter
|
176
|
-
# @attr value [IO]
|
272
|
+
# Set the output stream for reporter.
|
273
|
+
# @attr value [IO, String] IO to write to or filename to write to, defaults to $stdout
|
177
274
|
def output_stream=(value)
|
178
275
|
if @reporter && !value.equal?(@output_stream)
|
179
276
|
warn "RSpec's reporter has already been initialized with " \
|
@@ -182,127 +279,270 @@ module RSpec
|
|
182
279
|
"it to take effect. (Called from #{CallerFilter.first_non_rspec_line})"
|
183
280
|
else
|
184
281
|
@output_stream = value
|
282
|
+
output_wrapper.output = @output_stream
|
185
283
|
end
|
186
284
|
end
|
187
285
|
|
188
286
|
# @macro define_reader
|
189
|
-
# Load files matching this pattern (default: `'**{,/*/**}/*_spec.rb'`)
|
287
|
+
# Load files matching this pattern (default: `'**{,/*/**}/*_spec.rb'`).
|
288
|
+
# @return [String]
|
190
289
|
define_reader :pattern
|
191
290
|
|
192
|
-
# Set pattern to match files to load
|
291
|
+
# Set pattern to match files to load.
|
193
292
|
# @attr value [String] the filename pattern to filter spec files by
|
194
293
|
def pattern=(value)
|
195
294
|
update_pattern_attr :pattern, value
|
196
295
|
end
|
197
296
|
|
198
297
|
# @macro define_reader
|
199
|
-
# Exclude files matching this pattern
|
298
|
+
# Exclude files matching this pattern.
|
299
|
+
# @return [String]
|
200
300
|
define_reader :exclude_pattern
|
201
301
|
|
202
|
-
# Set pattern to match files to exclude
|
302
|
+
# Set pattern to match files to exclude.
|
203
303
|
# @attr value [String] the filename pattern to exclude spec files by
|
204
304
|
def exclude_pattern=(value)
|
205
305
|
update_pattern_attr :exclude_pattern, value
|
206
306
|
end
|
207
307
|
|
308
|
+
# @macro add_setting
|
309
|
+
# Specifies which directories contain the source code for your project.
|
310
|
+
# When a failure occurs, RSpec looks through the backtrace to find a
|
311
|
+
# a line of source to print. It first looks for a line coming from
|
312
|
+
# one of the project source directories so that, for example, it prints
|
313
|
+
# the expectation or assertion call rather than the source code from
|
314
|
+
# the expectation or assertion framework.
|
315
|
+
# @return [Array<String>]
|
316
|
+
add_setting :project_source_dirs
|
317
|
+
|
208
318
|
# @macro add_setting
|
209
319
|
# Report the times for the slowest examples (default: `false`).
|
210
320
|
# Use this to specify the number of examples to include in the profile.
|
211
|
-
|
321
|
+
# @return [Boolean]
|
322
|
+
attr_writer :profile_examples
|
323
|
+
define_predicate :profile_examples
|
212
324
|
|
213
325
|
# @macro add_setting
|
214
|
-
# Run all examples if none match the configured filters
|
326
|
+
# Run all examples if none match the configured filters
|
327
|
+
# (default: `false`).
|
328
|
+
# @deprecated Use {#filter_run_when_matching} instead for the specific
|
329
|
+
# filters that you want to be ignored if none match.
|
215
330
|
add_setting :run_all_when_everything_filtered
|
216
331
|
|
217
332
|
# @macro add_setting
|
218
|
-
# Color to use to indicate success.
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
333
|
+
# Color to use to indicate success. Defaults to `:green` but can be set
|
334
|
+
# to one of the following: `[:black, :white, :red, :green, :yellow,
|
335
|
+
# :blue, :magenta, :cyan]`
|
336
|
+
# @return [Symbol]
|
222
337
|
add_setting :success_color
|
223
338
|
|
224
339
|
# @macro add_setting
|
225
|
-
# Color to use to print pending examples.
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
340
|
+
# Color to use to print pending examples. Defaults to `:yellow` but can
|
341
|
+
# be set to one of the following: `[:black, :white, :red, :green,
|
342
|
+
# :yellow, :blue, :magenta, :cyan]`
|
343
|
+
# @return [Symbol]
|
229
344
|
add_setting :pending_color
|
230
345
|
|
231
346
|
# @macro add_setting
|
232
|
-
# Color to use to indicate failure.
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
347
|
+
# Color to use to indicate failure. Defaults to `:red` but can be set to
|
348
|
+
# one of the following: `[:black, :white, :red, :green, :yellow, :blue,
|
349
|
+
# :magenta, :cyan]`
|
350
|
+
# @return [Symbol]
|
236
351
|
add_setting :failure_color
|
237
352
|
|
238
353
|
# @macro add_setting
|
239
|
-
# The default output color.
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
354
|
+
# The default output color. Defaults to `:white` but can be set to one of
|
355
|
+
# the following: `[:black, :white, :red, :green, :yellow, :blue,
|
356
|
+
# :magenta, :cyan]`
|
357
|
+
# @return [Symbol]
|
243
358
|
add_setting :default_color
|
244
359
|
|
245
360
|
# @macro add_setting
|
246
|
-
# Color used when a pending example is fixed.
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
361
|
+
# Color used when a pending example is fixed. Defaults to `:blue` but can
|
362
|
+
# be set to one of the following: `[:black, :white, :red, :green,
|
363
|
+
# :yellow, :blue, :magenta, :cyan]`
|
364
|
+
# @return [Symbol]
|
250
365
|
add_setting :fixed_color
|
251
366
|
|
252
367
|
# @macro add_setting
|
253
|
-
# Color used to print details.
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
368
|
+
# Color used to print details. Defaults to `:cyan` but can be set to one
|
369
|
+
# of the following: `[:black, :white, :red, :green, :yellow, :blue,
|
370
|
+
# :magenta, :cyan]`
|
371
|
+
# @return [Symbol]
|
257
372
|
add_setting :detail_color
|
258
373
|
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
374
|
+
# @macro add_setting
|
375
|
+
# Don't print filter info i.e. "Run options: include {:focus=>true}"
|
376
|
+
# (default `false`).
|
377
|
+
# return [Boolean]
|
378
|
+
add_setting :silence_filter_announcements
|
379
|
+
|
380
|
+
# @deprecated This config option was added in RSpec 2 to pave the way
|
381
|
+
# for this being the default behavior in RSpec 3. Now this option is
|
382
|
+
# a no-op.
|
262
383
|
def treat_symbols_as_metadata_keys_with_true_values=(_value)
|
263
|
-
RSpec.deprecate(
|
264
|
-
|
265
|
-
|
384
|
+
RSpec.deprecate(
|
385
|
+
"RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
|
386
|
+
:message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \
|
387
|
+
"is deprecated, it is now set to true as default and " \
|
388
|
+
"setting it to false has no effect."
|
389
|
+
)
|
390
|
+
end
|
391
|
+
|
392
|
+
# @macro define_reader
|
393
|
+
# Configures how RSpec treats metadata passed as part of a shared example
|
394
|
+
# group definition. For example, given this shared example group definition:
|
395
|
+
#
|
396
|
+
# RSpec.shared_context "uses DB", :db => true do
|
397
|
+
# around(:example) do |ex|
|
398
|
+
# MyORM.transaction(:rollback => true, &ex)
|
399
|
+
# end
|
400
|
+
# end
|
401
|
+
#
|
402
|
+
# ...there are two ways RSpec can treat the `:db => true` metadata, each
|
403
|
+
# of which has a corresponding config option:
|
404
|
+
#
|
405
|
+
# 1. `:trigger_inclusion`: this shared context will be implicitly included
|
406
|
+
# in any groups (or examples) that have `:db => true` metadata.
|
407
|
+
# 2. `:apply_to_host_groups`: the metadata will be inherited by the metadata
|
408
|
+
# hash of all host groups and examples.
|
409
|
+
#
|
410
|
+
# `:trigger_inclusion` is the legacy behavior from before RSpec 3.5 but should
|
411
|
+
# be considered deprecated. Instead, you can explicitly include a group with
|
412
|
+
# `include_context`:
|
413
|
+
#
|
414
|
+
# RSpec.describe "My model" do
|
415
|
+
# include_context "uses DB"
|
416
|
+
# end
|
417
|
+
#
|
418
|
+
# ...or you can configure RSpec to include the context based on matching metadata
|
419
|
+
# using an API that mirrors configured module inclusion:
|
420
|
+
#
|
421
|
+
# RSpec.configure do |rspec|
|
422
|
+
# rspec.include_context "uses DB", :db => true
|
423
|
+
# end
|
424
|
+
#
|
425
|
+
# `:apply_to_host_groups` is a new feature of RSpec 3.5 and will be the only
|
426
|
+
# supported behavior in RSpec 4.
|
427
|
+
#
|
428
|
+
# @overload shared_context_metadata_behavior
|
429
|
+
# @return [:trigger_inclusion, :apply_to_host_groups] the configured behavior
|
430
|
+
# @overload shared_context_metadata_behavior=(value)
|
431
|
+
# @param value [:trigger_inclusion, :apply_to_host_groups] sets the configured behavior
|
432
|
+
define_reader :shared_context_metadata_behavior
|
433
|
+
# @see shared_context_metadata_behavior
|
434
|
+
def shared_context_metadata_behavior=(value)
|
435
|
+
case value
|
436
|
+
when :trigger_inclusion, :apply_to_host_groups
|
437
|
+
@shared_context_metadata_behavior = value
|
438
|
+
else
|
439
|
+
raise ArgumentError, "Cannot set `RSpec.configuration." \
|
440
|
+
"shared_context_metadata_behavior` to `#{value.inspect}`. Only " \
|
441
|
+
"`:trigger_inclusion` and `:apply_to_host_groups` are valid values."
|
442
|
+
end
|
266
443
|
end
|
267
444
|
|
268
|
-
# Record the start time of the spec suite to measure load time
|
445
|
+
# Record the start time of the spec suite to measure load time.
|
446
|
+
# return [Time]
|
269
447
|
add_setting :start_time
|
270
448
|
|
449
|
+
# @macro add_setting
|
450
|
+
# Use threadsafe options where available.
|
451
|
+
# Currently this will place a mutex around memoized values such as let blocks.
|
452
|
+
# return [Boolean]
|
453
|
+
add_setting :threadsafe
|
454
|
+
|
455
|
+
# @macro add_setting
|
456
|
+
# Maximum count of failed source lines to display in the failure reports.
|
457
|
+
# (default `10`).
|
458
|
+
# return [Integer]
|
459
|
+
add_setting :max_displayed_failure_line_count
|
460
|
+
|
461
|
+
# Determines which bisect runner implementation gets used to run subsets
|
462
|
+
# of the suite during a bisection. Your choices are:
|
463
|
+
#
|
464
|
+
# - `:shell`: Performs a spec run by shelling out, booting RSpec and your
|
465
|
+
# application environment each time. This runner is the most widely
|
466
|
+
# compatible runner, but is not as fast. On platforms that do not
|
467
|
+
# support forking, this is the default.
|
468
|
+
# - `:fork`: Pre-boots RSpec and your application environment in a parent
|
469
|
+
# process, and then forks a child process for each spec run. This runner
|
470
|
+
# tends to be significantly faster than the `:shell` runner but cannot
|
471
|
+
# be used in some situations. On platforms that support forking, this
|
472
|
+
# is the default. If you use this runner, you should ensure that all
|
473
|
+
# of your one-time setup logic goes in a `before(:suite)` hook instead
|
474
|
+
# of getting run at the top-level of a file loaded by `--require`.
|
475
|
+
#
|
476
|
+
# @note This option will only be used by `--bisect` if you set it in a file
|
477
|
+
# loaded via `--require`.
|
478
|
+
#
|
479
|
+
# @return [Symbol]
|
480
|
+
attr_reader :bisect_runner
|
481
|
+
def bisect_runner=(value)
|
482
|
+
if @bisect_runner_class && value != @bisect_runner
|
483
|
+
raise "`config.bisect_runner = #{value.inspect}` can no longer take " \
|
484
|
+
"effect as the #{@bisect_runner.inspect} bisect runnner is already " \
|
485
|
+
"in use. This config setting must be set in a file loaded by a " \
|
486
|
+
"`--require` option (passed at the CLI or in a `.rspec` file) for " \
|
487
|
+
"it to have any effect."
|
488
|
+
end
|
489
|
+
|
490
|
+
@bisect_runner = value
|
491
|
+
end
|
492
|
+
|
271
493
|
# @private
|
494
|
+
# @deprecated Use {#color_mode} = :on, instead of {#color} with {#tty}
|
272
495
|
add_setting :tty
|
273
496
|
# @private
|
274
|
-
add_setting :include_or_extend_modules
|
275
|
-
# @private
|
276
497
|
attr_writer :files_to_run
|
277
498
|
# @private
|
278
|
-
|
499
|
+
attr_accessor :filter_manager, :world
|
279
500
|
# @private
|
280
|
-
attr_accessor :
|
501
|
+
attr_accessor :static_config_filter_manager
|
281
502
|
# @private
|
282
|
-
attr_reader :backtrace_formatter, :ordering_manager
|
503
|
+
attr_reader :backtrace_formatter, :ordering_manager, :loaded_spec_files
|
283
504
|
|
505
|
+
# rubocop:disable Metrics/AbcSize
|
506
|
+
# rubocop:disable Metrics/MethodLength
|
507
|
+
|
508
|
+
# Build an object to store runtime configuration options and set defaults
|
284
509
|
def initialize
|
285
510
|
# rubocop:disable Style/GlobalVars
|
286
511
|
@start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
|
287
512
|
# rubocop:enable Style/GlobalVars
|
288
513
|
@expectation_frameworks = []
|
289
|
-
@
|
514
|
+
@include_modules = FilterableItemRepository::QueryOptimized.new(:any?)
|
515
|
+
@extend_modules = FilterableItemRepository::QueryOptimized.new(:any?)
|
516
|
+
@prepend_modules = FilterableItemRepository::QueryOptimized.new(:any?)
|
517
|
+
|
518
|
+
@bisect_runner = RSpec::Support::RubyFeatures.fork_supported? ? :fork : :shell
|
519
|
+
@bisect_runner_class = nil
|
520
|
+
|
521
|
+
@before_suite_hooks = []
|
522
|
+
@after_suite_hooks = []
|
523
|
+
|
290
524
|
@mock_framework = nil
|
291
525
|
@files_or_directories_to_run = []
|
526
|
+
@loaded_spec_files = Set.new
|
292
527
|
@color = false
|
528
|
+
@color_mode = :automatic
|
293
529
|
@pattern = '**{,/*/**}/*_spec.rb'
|
294
530
|
@exclude_pattern = ''
|
295
531
|
@failure_exit_code = 1
|
532
|
+
@error_exit_code = nil # so it can be overridden by failure exit code
|
533
|
+
@fail_if_no_examples = false
|
296
534
|
@spec_files_loaded = false
|
297
535
|
|
298
536
|
@backtrace_formatter = BacktraceFormatter.new
|
299
537
|
|
300
538
|
@default_path = 'spec'
|
539
|
+
@project_source_dirs = %w[ spec lib app ]
|
301
540
|
@deprecation_stream = $stderr
|
302
541
|
@output_stream = $stdout
|
303
542
|
@reporter = nil
|
304
543
|
@reporter_buffer = nil
|
305
544
|
@filter_manager = FilterManager.new
|
545
|
+
@static_config_filter_manager = FilterManager.new
|
306
546
|
@ordering_manager = Ordering::ConfigurationManager.new
|
307
547
|
@preferred_options = {}
|
308
548
|
@failure_color = :red
|
@@ -314,8 +554,16 @@ module RSpec
|
|
314
554
|
@profile_examples = false
|
315
555
|
@requires = []
|
316
556
|
@libs = []
|
317
|
-
@derived_metadata_blocks =
|
557
|
+
@derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
|
558
|
+
@threadsafe = true
|
559
|
+
@max_displayed_failure_line_count = 10
|
560
|
+
@world = World::Null
|
561
|
+
@shared_context_metadata_behavior = :trigger_inclusion
|
562
|
+
|
563
|
+
define_built_in_hooks
|
318
564
|
end
|
565
|
+
# rubocop:enable Metrics/AbcSize
|
566
|
+
# rubocop:enable Metrics/MethodLength
|
319
567
|
|
320
568
|
# @private
|
321
569
|
#
|
@@ -323,27 +571,47 @@ module RSpec
|
|
323
571
|
def force(hash)
|
324
572
|
ordering_manager.force(hash)
|
325
573
|
@preferred_options.merge!(hash)
|
574
|
+
|
575
|
+
return unless hash.key?(:example_status_persistence_file_path)
|
576
|
+
clear_values_derived_from_example_status_persistence_file_path
|
326
577
|
end
|
327
578
|
|
328
579
|
# @private
|
329
580
|
def reset
|
330
581
|
@spec_files_loaded = false
|
582
|
+
reset_reporter
|
583
|
+
end
|
584
|
+
|
585
|
+
# @private
|
586
|
+
def reset_reporter
|
331
587
|
@reporter = nil
|
332
588
|
@formatter_loader = nil
|
589
|
+
@output_wrapper = nil
|
590
|
+
end
|
591
|
+
|
592
|
+
# @private
|
593
|
+
def reset_filters
|
594
|
+
self.filter_manager = FilterManager.new
|
595
|
+
filter_manager.include_only(
|
596
|
+
Metadata.deep_hash_dup(static_config_filter_manager.inclusions.rules)
|
597
|
+
)
|
598
|
+
filter_manager.exclude_only(
|
599
|
+
Metadata.deep_hash_dup(static_config_filter_manager.exclusions.rules)
|
600
|
+
)
|
333
601
|
end
|
334
602
|
|
335
603
|
# @overload add_setting(name)
|
336
604
|
# @overload add_setting(name, opts)
|
337
605
|
# @option opts [Symbol] :default
|
338
606
|
#
|
339
|
-
#
|
607
|
+
# Set a default value for the generated getter and predicate methods:
|
340
608
|
#
|
341
609
|
# add_setting(:foo, :default => "default value")
|
342
610
|
#
|
343
611
|
# @option opts [Symbol] :alias_with
|
344
612
|
#
|
345
|
-
# Use `:alias_with` to alias the setter, getter, and predicate to
|
346
|
-
# name, or names:
|
613
|
+
# Use `:alias_with` to alias the setter, getter, and predicate to
|
614
|
+
# another name, or names:
|
347
615
|
#
|
348
616
|
# add_setting(:foo, :alias_with => :bar)
|
349
617
|
# add_setting(:foo, :alias_with => [:bar, :baz])
|
@@ -366,7 +634,7 @@ module RSpec
|
|
366
634
|
#
|
367
635
|
# RSpec.configuration.foo=(value)
|
368
636
|
# RSpec.configuration.foo
|
369
|
-
# RSpec.configuration.foo? #
|
637
|
+
# RSpec.configuration.foo? # Returns true if foo returns anything but nil or false.
|
370
638
|
def add_setting(name, opts={})
|
371
639
|
default = opts.delete(:default)
|
372
640
|
(class << self; self; end).class_exec do
|
@@ -375,7 +643,8 @@ module RSpec
|
|
375
643
|
__send__("#{name}=", default) if default
|
376
644
|
end
|
377
645
|
|
378
|
-
# Returns the configured mock framework adapter module
|
646
|
+
# Returns the configured mock framework adapter module.
|
647
|
+
# @return [Symbol]
|
379
648
|
def mock_framework
|
380
649
|
if @mock_framework.nil?
|
381
650
|
begin
|
@@ -387,7 +656,7 @@ module RSpec
|
|
387
656
|
@mock_framework
|
388
657
|
end
|
389
658
|
|
390
|
-
# Delegates to mock_framework=(framework)
|
659
|
+
# Delegates to mock_framework=(framework).
|
391
660
|
def mock_framework=(framework)
|
392
661
|
mock_with framework
|
393
662
|
end
|
@@ -395,20 +664,21 @@ module RSpec
|
|
395
664
|
# Regexps used to exclude lines from backtraces.
|
396
665
|
#
|
397
666
|
# Excludes lines from ruby (and jruby) source, installed gems, anything
|
398
|
-
# in any "bin" directory, and any of the
|
667
|
+
# in any "bin" directory, and any of the RSpec libs (outside gem
|
399
668
|
# installs) by default.
|
400
669
|
#
|
401
670
|
# You can modify the list via the getter, or replace it with the setter.
|
402
671
|
#
|
403
672
|
# To override this behaviour and display a full backtrace, use
|
404
|
-
# `--backtrace`on the command line, in a `.rspec` file, or in the
|
673
|
+
# `--backtrace` on the command line, in a `.rspec` file, or in the
|
405
674
|
# `rspec_options` attribute of RSpec's rake task.
|
675
|
+
# @return [Array<Regexp>]
|
406
676
|
def backtrace_exclusion_patterns
|
407
677
|
@backtrace_formatter.exclusion_patterns
|
408
678
|
end
|
409
679
|
|
410
|
-
# Set regular expressions used to exclude lines in backtrace
|
411
|
-
# @param patterns [Regexp] set
|
680
|
+
# Set regular expressions used to exclude lines in backtrace.
|
681
|
+
# @param patterns [Array<Regexp>] set backtrace_formatter exlusion_patterns
|
412
682
|
def backtrace_exclusion_patterns=(patterns)
|
413
683
|
@backtrace_formatter.exclusion_patterns = patterns
|
414
684
|
end
|
@@ -421,12 +691,13 @@ module RSpec
|
|
421
691
|
# will be included.
|
422
692
|
#
|
423
693
|
# You can modify the list via the getter, or replace it with the setter.
|
694
|
+
# @return [Array<Regexp>]
|
424
695
|
def backtrace_inclusion_patterns
|
425
696
|
@backtrace_formatter.inclusion_patterns
|
426
697
|
end
|
427
698
|
|
428
|
-
# Set regular expressions used to include lines in backtrace
|
429
|
-
# @attr patterns [Regexp] set backtrace_formatter inclusion_patterns
|
699
|
+
# Set regular expressions used to include lines in backtrace.
|
700
|
+
# @attr patterns [Array<Regexp>] set backtrace_formatter inclusion_patterns
|
430
701
|
def backtrace_inclusion_patterns=(patterns)
|
431
702
|
@backtrace_formatter.inclusion_patterns = patterns
|
432
703
|
end
|
@@ -485,8 +756,8 @@ module RSpec
|
|
485
756
|
# teardown_mocks_for_rspec
|
486
757
|
# - called after verify_mocks_for_rspec (even if there are errors)
|
487
758
|
#
|
488
|
-
# If the module responds to `configuration` and `mock_with` receives a
|
489
|
-
# it will yield the configuration object to the block e.g.
|
759
|
+
# If the module responds to `configuration` and `mock_with` receives a
|
760
|
+
# block, it will yield the configuration object to the block e.g.
|
490
761
|
#
|
491
762
|
# config.mock_with OtherMockFrameworkAdapter do |mod_config|
|
492
763
|
# mod_config.custom_setting = true
|
@@ -507,7 +778,7 @@ module RSpec
|
|
507
778
|
end
|
508
779
|
|
509
780
|
new_name, old_name = [framework_module, @mock_framework].map do |mod|
|
510
|
-
mod.respond_to?(:framework_name) ?
|
781
|
+
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
|
511
782
|
end
|
512
783
|
|
513
784
|
unless new_name == old_name
|
@@ -515,7 +786,8 @@ module RSpec
|
|
515
786
|
end
|
516
787
|
|
517
788
|
if block_given?
|
518
|
-
raise "#{framework_module} must respond to `configuration` so that
|
789
|
+
raise "#{framework_module} must respond to `configuration` so that " \
|
790
|
+
"mock_with can yield it." unless framework_module.respond_to?(:configuration)
|
519
791
|
yield framework_module.configuration
|
520
792
|
end
|
521
793
|
|
@@ -534,7 +806,7 @@ module RSpec
|
|
534
806
|
@expectation_frameworks
|
535
807
|
end
|
536
808
|
|
537
|
-
# Delegates to expect_with(framework)
|
809
|
+
# Delegates to expect_with(framework).
|
538
810
|
def expectation_framework=(framework)
|
539
811
|
expect_with(framework)
|
540
812
|
end
|
@@ -569,7 +841,13 @@ module RSpec
|
|
569
841
|
framework
|
570
842
|
when :rspec
|
571
843
|
require 'rspec/expectations'
|
572
|
-
|
844
|
+
|
845
|
+
# Tag this exception class so our exception formatting logic knows
|
846
|
+
# that it satisfies the `MultipleExceptionError` interface.
|
847
|
+
::RSpec::Expectations::MultipleExpectationsNotMetError.__send__(
|
848
|
+
:include, MultipleExceptionError::InterfaceTag
|
849
|
+
)
|
850
|
+
|
573
851
|
::RSpec::Matchers
|
574
852
|
when :test_unit
|
575
853
|
require 'rspec/core/test_unit_assertions_adapter'
|
@@ -587,55 +865,78 @@ module RSpec
|
|
587
865
|
end
|
588
866
|
|
589
867
|
if block_given?
|
590
|
-
raise "expect_with only accepts a block with a single argument.
|
591
|
-
|
868
|
+
raise "expect_with only accepts a block with a single argument. " \
|
869
|
+
"Call expect_with #{modules.length} times, " \
|
870
|
+
"once with each argument, instead." if modules.length > 1
|
871
|
+
raise "#{modules.first} must respond to `configuration` so that " \
|
872
|
+
"expect_with can yield it." unless modules.first.respond_to?(:configuration)
|
592
873
|
yield modules.first.configuration
|
593
874
|
end
|
594
875
|
|
595
876
|
@expectation_frameworks.push(*modules)
|
596
877
|
end
|
597
878
|
|
598
|
-
# Check if full backtrace is enabled
|
879
|
+
# Check if full backtrace is enabled.
|
599
880
|
# @return [Boolean] is full backtrace enabled
|
600
881
|
def full_backtrace?
|
601
882
|
@backtrace_formatter.full_backtrace?
|
602
883
|
end
|
603
884
|
|
604
|
-
# Toggle full backtrace
|
885
|
+
# Toggle full backtrace.
|
605
886
|
# @attr true_or_false [Boolean] toggle full backtrace display
|
606
887
|
def full_backtrace=(true_or_false)
|
607
888
|
@backtrace_formatter.full_backtrace = true_or_false
|
608
889
|
end
|
609
890
|
|
610
|
-
#
|
611
|
-
#
|
891
|
+
# Enables color output if the output is a TTY. As of RSpec 3.6, this is
|
892
|
+
# the default behavior and this option is retained only for backwards
|
893
|
+
# compatibility.
|
612
894
|
#
|
895
|
+
# @deprecated No longer recommended because of complex behavior. Instead,
|
896
|
+
# rely on the fact that TTYs will display color by default, or set
|
897
|
+
# {#color_mode} to :on to display color on a non-TTY output.
|
898
|
+
# @see color_mode
|
613
899
|
# @see color_enabled?
|
614
900
|
# @return [Boolean]
|
615
901
|
def color
|
616
|
-
value_for(:color
|
902
|
+
value_for(:color) { @color }
|
903
|
+
end
|
904
|
+
|
905
|
+
# The mode for determining whether to display output in color. One of:
|
906
|
+
#
|
907
|
+
# - :automatic - the output will be in color if the output is a TTY (the
|
908
|
+
# default)
|
909
|
+
# - :on - the output will be in color, whether or not the output is a TTY
|
910
|
+
# - :off - the output will not be in color
|
911
|
+
#
|
912
|
+
# @see color_enabled?
|
913
|
+
# @return [Boolean]
|
914
|
+
def color_mode
|
915
|
+
value_for(:color_mode) { @color_mode }
|
617
916
|
end
|
618
917
|
|
619
|
-
# Check if color is enabled for a particular output
|
918
|
+
# Check if color is enabled for a particular output.
|
620
919
|
# @param output [IO] an output stream to use, defaults to the current
|
621
920
|
# `output_stream`
|
622
921
|
# @return [Boolean]
|
623
922
|
def color_enabled?(output=output_stream)
|
624
|
-
|
923
|
+
case color_mode
|
924
|
+
when :on then true
|
925
|
+
when :off then false
|
926
|
+
else # automatic
|
927
|
+
output_to_tty?(output) || (color && tty?)
|
928
|
+
end
|
625
929
|
end
|
626
930
|
|
627
|
-
#
|
628
|
-
|
629
|
-
def color=(true_or_false)
|
630
|
-
return unless true_or_false
|
931
|
+
# Set the color mode.
|
932
|
+
attr_writer :color_mode
|
631
933
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
end
|
934
|
+
# Toggle output color.
|
935
|
+
#
|
936
|
+
# @deprecated No longer recommended because of complex behavior. Instead,
|
937
|
+
# rely on the fact that TTYs will display color by default, or set
|
938
|
+
# {:color_mode} to :on to display color on a non-TTY output.
|
939
|
+
attr_writer :color
|
639
940
|
|
640
941
|
# @private
|
641
942
|
def libs=(libs)
|
@@ -657,19 +958,22 @@ module RSpec
|
|
657
958
|
end
|
658
959
|
|
659
960
|
# @overload add_formatter(formatter)
|
961
|
+
# @overload add_formatter(formatter, output)
|
660
962
|
#
|
661
|
-
#
|
662
|
-
#
|
663
|
-
# `
|
963
|
+
# @param formatter [Class, String, Object] formatter to use. Can be any of the
|
964
|
+
# string values supported from the CLI (`p`/`progress`,
|
965
|
+
# `d`/`doc`/`documentation`, `h`/`html`, or `j`/`json`), any
|
966
|
+
# class that implements the formatter protocol and has registered
|
967
|
+
# itself with RSpec as a formatter, or a formatter instance.
|
968
|
+
# @param output [String, IO] where the formatter will write its output.
|
969
|
+
# Can be an IO object or a string path to a file. If not provided,
|
970
|
+
# the configured `output_stream` (`$stdout`, by default) will be used.
|
664
971
|
#
|
665
|
-
#
|
972
|
+
# Adds a formatter to the set RSpec will use for this run.
|
666
973
|
#
|
667
|
-
#
|
668
|
-
|
669
|
-
|
670
|
-
def add_formatter(formatter_to_use, *paths)
|
671
|
-
paths << output_stream if paths.empty?
|
672
|
-
formatter_loader.add formatter_to_use, *paths
|
974
|
+
# @see RSpec::Core::Formatters::Protocol
|
975
|
+
def add_formatter(formatter, output=output_wrapper)
|
976
|
+
formatter_loader.add(formatter, output)
|
673
977
|
end
|
674
978
|
alias_method :formatter=, :add_formatter
|
675
979
|
|
@@ -727,14 +1031,14 @@ module RSpec
|
|
727
1031
|
end
|
728
1032
|
end
|
729
1033
|
|
730
|
-
# @
|
1034
|
+
# @return [RSpec::Core::Reporter] the currently configured reporter
|
731
1035
|
def reporter
|
732
1036
|
# @reporter_buffer should only ever be set in this method to cover
|
733
1037
|
# initialization of @reporter.
|
734
1038
|
@reporter_buffer || @reporter ||=
|
735
1039
|
begin
|
736
1040
|
@reporter_buffer = DeprecationReporterBuffer.new
|
737
|
-
formatter_loader.
|
1041
|
+
formatter_loader.prepare_default output_wrapper, deprecation_stream
|
738
1042
|
@reporter_buffer.play_onto(formatter_loader.reporter)
|
739
1043
|
@reporter_buffer = nil
|
740
1044
|
formatter_loader.reporter
|
@@ -743,10 +1047,10 @@ module RSpec
|
|
743
1047
|
|
744
1048
|
# @api private
|
745
1049
|
#
|
746
|
-
# Defaults `profile_examples` to 10 examples when `@profile_examples` is
|
747
|
-
#
|
1050
|
+
# Defaults `profile_examples` to 10 examples when `@profile_examples` is
|
1051
|
+
# `true`.
|
748
1052
|
def profile_examples
|
749
|
-
profile = value_for(:profile_examples
|
1053
|
+
profile = value_for(:profile_examples) { @profile_examples }
|
750
1054
|
if profile && !profile.is_a?(Integer)
|
751
1055
|
10
|
752
1056
|
else
|
@@ -757,17 +1061,66 @@ module RSpec
|
|
757
1061
|
# @private
|
758
1062
|
def files_or_directories_to_run=(*files)
|
759
1063
|
files = files.flatten
|
760
|
-
|
1064
|
+
|
1065
|
+
if (command == 'rspec' || Runner.running_in_drb?) && default_path && files.empty?
|
1066
|
+
files << default_path
|
1067
|
+
end
|
1068
|
+
|
761
1069
|
@files_or_directories_to_run = files
|
762
1070
|
@files_to_run = nil
|
763
1071
|
end
|
764
1072
|
|
765
|
-
# The spec files RSpec will run
|
1073
|
+
# The spec files RSpec will run.
|
766
1074
|
# @return [Array] specified files about to run
|
767
1075
|
def files_to_run
|
768
1076
|
@files_to_run ||= get_files_to_run(@files_or_directories_to_run)
|
769
1077
|
end
|
770
1078
|
|
1079
|
+
# @private
|
1080
|
+
def last_run_statuses
|
1081
|
+
@last_run_statuses ||= Hash.new(UNKNOWN_STATUS).tap do |statuses|
|
1082
|
+
if (path = example_status_persistence_file_path)
|
1083
|
+
begin
|
1084
|
+
ExampleStatusPersister.load_from(path).inject(statuses) do |hash, example|
|
1085
|
+
status = example[:status]
|
1086
|
+
status = UNKNOWN_STATUS unless VALID_STATUSES.include?(status)
|
1087
|
+
hash[example.fetch(:example_id)] = status
|
1088
|
+
hash
|
1089
|
+
end
|
1090
|
+
rescue SystemCallError => e
|
1091
|
+
RSpec.warning "Could not read from #{path.inspect} (configured as " \
|
1092
|
+
"`config.example_status_persistence_file_path`) due " \
|
1093
|
+
"to a system error: #{e.inspect}. Please check that " \
|
1094
|
+
"the config option is set to an accessible, valid " \
|
1095
|
+
"file path", :call_site => nil
|
1096
|
+
end
|
1097
|
+
end
|
1098
|
+
end
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
# @private
|
1102
|
+
UNKNOWN_STATUS = "unknown".freeze
|
1103
|
+
|
1104
|
+
# @private
|
1105
|
+
FAILED_STATUS = "failed".freeze
|
1106
|
+
|
1107
|
+
# @private
|
1108
|
+
PASSED_STATUS = "passed".freeze
|
1109
|
+
|
1110
|
+
# @private
|
1111
|
+
PENDING_STATUS = "pending".freeze
|
1112
|
+
|
1113
|
+
# @private
|
1114
|
+
VALID_STATUSES = [UNKNOWN_STATUS, FAILED_STATUS, PASSED_STATUS, PENDING_STATUS]
|
1115
|
+
|
1116
|
+
# @private
|
1117
|
+
def spec_files_with_failures
|
1118
|
+
@spec_files_with_failures ||= last_run_statuses.inject(Set.new) do |files, (id, status)|
|
1119
|
+
files << Example.parse_id(id).first if status == FAILED_STATUS
|
1120
|
+
files
|
1121
|
+
end.to_a
|
1122
|
+
end
|
1123
|
+
|
771
1124
|
# Creates a method that delegates to `example` including the submitted
|
772
1125
|
# `args`. Used internally to add variants of `example` like `pending`:
|
773
1126
|
# @param name [String] example name alias
|
@@ -776,8 +1129,8 @@ module RSpec
|
|
776
1129
|
# @note The specific example alias below (`pending`) is already
|
777
1130
|
# defined for you.
|
778
1131
|
# @note Use with caution. This extends the language used in your
|
779
|
-
# specs, but does not add any additional documentation.
|
780
|
-
# in
|
1132
|
+
# specs, but does not add any additional documentation. We use this
|
1133
|
+
# in RSpec to define methods like `focus` and `xit`, but we also add
|
781
1134
|
# docs for those methods.
|
782
1135
|
#
|
783
1136
|
# @example
|
@@ -787,7 +1140,7 @@ module RSpec
|
|
787
1140
|
#
|
788
1141
|
# # This lets you do this:
|
789
1142
|
#
|
790
|
-
# describe Thing do
|
1143
|
+
# RSpec.describe Thing do
|
791
1144
|
# pending "does something" do
|
792
1145
|
# thing = Thing.new
|
793
1146
|
# end
|
@@ -795,7 +1148,7 @@ module RSpec
|
|
795
1148
|
#
|
796
1149
|
# # ... which is the equivalent of
|
797
1150
|
#
|
798
|
-
# describe Thing do
|
1151
|
+
# RSpec.describe Thing do
|
799
1152
|
# it "does something", :pending => true do
|
800
1153
|
# thing = Thing.new
|
801
1154
|
# end
|
@@ -848,7 +1201,7 @@ module RSpec
|
|
848
1201
|
#
|
849
1202
|
# # allows the user to include a shared example group like:
|
850
1203
|
#
|
851
|
-
# describe Entity do
|
1204
|
+
# RSpec.describe Entity do
|
852
1205
|
# it_has_behavior 'sortability' do
|
853
1206
|
# let(:sortable) { Entity.new }
|
854
1207
|
# end
|
@@ -860,8 +1213,8 @@ module RSpec
|
|
860
1213
|
# # ...sortability examples here
|
861
1214
|
#
|
862
1215
|
# @note Use with caution. This extends the language used in your
|
863
|
-
# specs, but does not add any additional documentation.
|
864
|
-
# in
|
1216
|
+
# specs, but does not add any additional documentation. We use this
|
1217
|
+
# in RSpec to define `it_should_behave_like` (for backward
|
865
1218
|
# compatibility), but we also add docs for that method.
|
866
1219
|
def alias_it_behaves_like_to(new_name, report_label='')
|
867
1220
|
RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
|
@@ -878,32 +1231,48 @@ module RSpec
|
|
878
1231
|
# or config files (e.g. `.rspec`).
|
879
1232
|
#
|
880
1233
|
# @example
|
881
|
-
# #
|
1234
|
+
# # Given this declaration.
|
882
1235
|
# describe "something", :foo => 'bar' do
|
883
1236
|
# # ...
|
884
1237
|
# end
|
885
1238
|
#
|
886
|
-
# #
|
1239
|
+
# # Any of the following will include that group.
|
887
1240
|
# config.filter_run_including :foo => 'bar'
|
888
1241
|
# config.filter_run_including :foo => /^ba/
|
889
1242
|
# config.filter_run_including :foo => lambda {|v| v == 'bar'}
|
890
1243
|
# config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
|
891
1244
|
#
|
892
|
-
# #
|
1245
|
+
# # Given a proc with an arity of 1, the lambda is passed the value
|
1246
|
+
# # related to the key, e.g.
|
893
1247
|
# config.filter_run_including :foo => lambda {|v| v == 'bar'}
|
894
1248
|
#
|
895
|
-
# #
|
896
|
-
# # and the metadata itself e.g.
|
1249
|
+
# # Given a proc with an arity of 2, the lambda is passed the value
|
1250
|
+
# # related to the key, and the metadata itself e.g.
|
897
1251
|
# config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
|
898
1252
|
#
|
899
1253
|
# filter_run_including :foo # same as filter_run_including :foo => true
|
900
1254
|
def filter_run_including(*args)
|
901
1255
|
meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
|
902
1256
|
filter_manager.include_with_low_priority meta
|
1257
|
+
static_config_filter_manager.include_with_low_priority Metadata.deep_hash_dup(meta)
|
903
1258
|
end
|
904
|
-
|
905
1259
|
alias_method :filter_run, :filter_run_including
|
906
1260
|
|
1261
|
+
# Applies the provided filter only if any of examples match, in constrast
|
1262
|
+
# to {#filter_run}, which always applies even if no examples match, in
|
1263
|
+
# which case no examples will be run. This allows you to leave configured
|
1264
|
+
# filters in place that are intended only for temporary use. The most common
|
1265
|
+
# example is focus filtering: `config.filter_run_when_matching :focus`.
|
1266
|
+
# With that configured, you can temporarily focus an example or group
|
1267
|
+
# by tagging it with `:focus` metadata, or prefixing it with an `f`
|
1268
|
+
# (as in `fdescribe`, `fcontext` and `fit`) since those are aliases for
|
1269
|
+
# `describe`/`context`/`it` with `:focus` metadata.
|
1270
|
+
def filter_run_when_matching(*args)
|
1271
|
+
when_first_matching_example_defined(*args) do
|
1272
|
+
filter_run(*args)
|
1273
|
+
end
|
1274
|
+
end
|
1275
|
+
|
907
1276
|
# Clears and reassigns the `inclusion_filter`. Set to `nil` if you don't
|
908
1277
|
# want any inclusion filter at all.
|
909
1278
|
#
|
@@ -936,28 +1305,30 @@ module RSpec
|
|
936
1305
|
# or config files (e.g. `.rspec`).
|
937
1306
|
#
|
938
1307
|
# @example
|
939
|
-
# #
|
1308
|
+
# # Given this declaration.
|
940
1309
|
# describe "something", :foo => 'bar' do
|
941
1310
|
# # ...
|
942
1311
|
# end
|
943
1312
|
#
|
944
|
-
# #
|
1313
|
+
# # Any of the following will exclude that group.
|
945
1314
|
# config.filter_run_excluding :foo => 'bar'
|
946
1315
|
# config.filter_run_excluding :foo => /^ba/
|
947
1316
|
# config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
|
948
1317
|
# config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
|
949
1318
|
#
|
950
|
-
# #
|
1319
|
+
# # Given a proc with an arity of 1, the lambda is passed the value
|
1320
|
+
# # related to the key, e.g.
|
951
1321
|
# config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
|
952
1322
|
#
|
953
|
-
# #
|
954
|
-
# # and the metadata itself e.g.
|
1323
|
+
# # Given a proc with an arity of 2, the lambda is passed the value
|
1324
|
+
# # related to the key, and the metadata itself e.g.
|
955
1325
|
# config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
|
956
1326
|
#
|
957
1327
|
# filter_run_excluding :foo # same as filter_run_excluding :foo => true
|
958
1328
|
def filter_run_excluding(*args)
|
959
1329
|
meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
|
960
1330
|
filter_manager.exclude_with_low_priority meta
|
1331
|
+
static_config_filter_manager.exclude_with_low_priority Metadata.deep_hash_dup(meta)
|
961
1332
|
end
|
962
1333
|
|
963
1334
|
# Clears and reassigns the `exclusion_filter`. Set to `nil` if you don't
|
@@ -979,8 +1350,8 @@ module RSpec
|
|
979
1350
|
end
|
980
1351
|
|
981
1352
|
# Tells RSpec to include `mod` in example groups. Methods defined in
|
982
|
-
# `mod` are exposed to examples (not example groups).
|
983
|
-
# constrain the groups in which to include the module.
|
1353
|
+
# `mod` are exposed to examples (not example groups). Use `filters` to
|
1354
|
+
# constrain the groups or examples in which to include the module.
|
984
1355
|
#
|
985
1356
|
# @example
|
986
1357
|
#
|
@@ -990,6 +1361,12 @@ module RSpec
|
|
990
1361
|
# end
|
991
1362
|
# end
|
992
1363
|
#
|
1364
|
+
# module PreferencesHelpers
|
1365
|
+
# def preferences(user, preferences = {})
|
1366
|
+
# # ...
|
1367
|
+
# end
|
1368
|
+
# end
|
1369
|
+
#
|
993
1370
|
# module UserHelpers
|
994
1371
|
# def users(username)
|
995
1372
|
# # ...
|
@@ -997,26 +1374,87 @@ module RSpec
|
|
997
1374
|
# end
|
998
1375
|
#
|
999
1376
|
# RSpec.configure do |config|
|
1000
|
-
# config.include(UserHelpers) # included in all
|
1377
|
+
# config.include(UserHelpers) # included in all groups
|
1378
|
+
#
|
1379
|
+
# # included in examples with `:preferences` metadata
|
1380
|
+
# config.include(PreferenceHelpers, :preferences)
|
1381
|
+
#
|
1382
|
+
# # included in examples with `:type => :request` metadata
|
1001
1383
|
# config.include(AuthenticationHelpers, :type => :request)
|
1002
1384
|
# end
|
1003
1385
|
#
|
1004
|
-
# describe "edit profile", :type => :request do
|
1386
|
+
# describe "edit profile", :preferences, :type => :request do
|
1005
1387
|
# it "can be viewed by owning user" do
|
1006
|
-
# login_as users(:jdoe)
|
1388
|
+
# login_as preferences(users(:jdoe), :lang => 'es')
|
1007
1389
|
# get "/profiles/jdoe"
|
1008
1390
|
# assert_select ".username", :text => 'jdoe'
|
1009
1391
|
# end
|
1010
1392
|
# end
|
1011
1393
|
#
|
1394
|
+
# @note Filtered module inclusions can also be applied to
|
1395
|
+
# individual examples that have matching metadata. Just like
|
1396
|
+
# Ruby's object model is that every object has a singleton class
|
1397
|
+
# which has only a single instance, RSpec's model is that every
|
1398
|
+
# example has a singleton example group containing just the one
|
1399
|
+
# example.
|
1400
|
+
#
|
1401
|
+
# @see #include_context
|
1012
1402
|
# @see #extend
|
1403
|
+
# @see #prepend
|
1013
1404
|
def include(mod, *filters)
|
1014
|
-
|
1015
|
-
|
1405
|
+
define_mixed_in_module(mod, filters, @include_modules, :include) do |group|
|
1406
|
+
safe_include(mod, group)
|
1407
|
+
end
|
1408
|
+
end
|
1409
|
+
|
1410
|
+
# Tells RSpec to include the named shared example group in example groups.
|
1411
|
+
# Use `filters` to constrain the groups or examples in which to include
|
1412
|
+
# the example group.
|
1413
|
+
#
|
1414
|
+
# @example
|
1415
|
+
#
|
1416
|
+
# RSpec.shared_context "example admin user" do
|
1417
|
+
# let(:admin_user) { create_user(:admin) }
|
1418
|
+
# end
|
1419
|
+
#
|
1420
|
+
# RSpec.shared_context "example guest user" do
|
1421
|
+
# let(:guest_user) { create_user(:guest) }
|
1422
|
+
# end
|
1423
|
+
#
|
1424
|
+
# RSpec.configure do |config|
|
1425
|
+
# config.include_context "example guest user", :type => :request
|
1426
|
+
# config.include_context "example admin user", :admin, :type => :request
|
1427
|
+
# end
|
1428
|
+
#
|
1429
|
+
# RSpec.describe "The admin page", :type => :request do
|
1430
|
+
# it "can be viewed by admins", :admin do
|
1431
|
+
# login_with admin_user
|
1432
|
+
# get "/admin"
|
1433
|
+
# expect(response).to be_ok
|
1434
|
+
# end
|
1435
|
+
#
|
1436
|
+
# it "cannot be viewed by guests" do
|
1437
|
+
# login_with guest_user
|
1438
|
+
# get "/admin"
|
1439
|
+
# expect(response).to be_forbidden
|
1440
|
+
# end
|
1441
|
+
# end
|
1442
|
+
#
|
1443
|
+
# @note Filtered context inclusions can also be applied to
|
1444
|
+
# individual examples that have matching metadata. Just like
|
1445
|
+
# Ruby's object model is that every object has a singleton class
|
1446
|
+
# which has only a single instance, RSpec's model is that every
|
1447
|
+
# example has a singleton example group containing just the one
|
1448
|
+
# example.
|
1449
|
+
#
|
1450
|
+
# @see #include
|
1451
|
+
def include_context(shared_group_name, *filters)
|
1452
|
+
shared_module = world.shared_example_group_registry.find([:main], shared_group_name)
|
1453
|
+
include shared_module, *filters
|
1016
1454
|
end
|
1017
1455
|
|
1018
|
-
# Tells RSpec to extend example groups with `mod`.
|
1019
|
-
# `mod` are exposed to example groups (not examples).
|
1456
|
+
# Tells RSpec to extend example groups with `mod`. Methods defined in
|
1457
|
+
# `mod` are exposed to example groups (not examples). Use `filters` to
|
1020
1458
|
# constrain the groups to extend.
|
1021
1459
|
#
|
1022
1460
|
# Similar to `include`, but behavior is added to example groups, which
|
@@ -1031,12 +1469,20 @@ module RSpec
|
|
1031
1469
|
# end
|
1032
1470
|
# end
|
1033
1471
|
#
|
1472
|
+
# module PermissionHelpers
|
1473
|
+
# def define_permissions
|
1474
|
+
# # ...
|
1475
|
+
# end
|
1476
|
+
# end
|
1477
|
+
#
|
1034
1478
|
# RSpec.configure do |config|
|
1035
1479
|
# config.extend(UiHelpers, :type => :request)
|
1480
|
+
# config.extend(PermissionHelpers, :with_permissions, :type => :request)
|
1036
1481
|
# end
|
1037
1482
|
#
|
1038
|
-
# describe "edit profile", :type => :request do
|
1483
|
+
# describe "edit profile", :with_permissions, :type => :request do
|
1039
1484
|
# run_in_browser
|
1485
|
+
# define_permissions
|
1040
1486
|
#
|
1041
1487
|
# it "does stuff in the client" do
|
1042
1488
|
# # ...
|
@@ -1044,46 +1490,100 @@ module RSpec
|
|
1044
1490
|
# end
|
1045
1491
|
#
|
1046
1492
|
# @see #include
|
1493
|
+
# @see #prepend
|
1047
1494
|
def extend(mod, *filters)
|
1048
|
-
|
1049
|
-
|
1495
|
+
define_mixed_in_module(mod, filters, @extend_modules, :extend) do |group|
|
1496
|
+
safe_extend(mod, group)
|
1497
|
+
end
|
1498
|
+
end
|
1499
|
+
|
1500
|
+
if RSpec::Support::RubyFeatures.module_prepends_supported?
|
1501
|
+
# Tells RSpec to prepend example groups with `mod`. Methods defined in
|
1502
|
+
# `mod` are exposed to examples (not example groups). Use `filters` to
|
1503
|
+
# constrain the groups in which to prepend the module.
|
1504
|
+
#
|
1505
|
+
# Similar to `include`, but module is included before the example group's class
|
1506
|
+
# in the ancestor chain.
|
1507
|
+
#
|
1508
|
+
# @example
|
1509
|
+
#
|
1510
|
+
# module OverrideMod
|
1511
|
+
# def override_me
|
1512
|
+
# "overridden"
|
1513
|
+
# end
|
1514
|
+
# end
|
1515
|
+
#
|
1516
|
+
# RSpec.configure do |config|
|
1517
|
+
# config.prepend(OverrideMod, :method => :prepend)
|
1518
|
+
# end
|
1519
|
+
#
|
1520
|
+
# describe "overriding example's class", :method => :prepend do
|
1521
|
+
# it "finds the user" do
|
1522
|
+
# self.class.class_eval do
|
1523
|
+
# def override_me
|
1524
|
+
# end
|
1525
|
+
# end
|
1526
|
+
# override_me # => "overridden"
|
1527
|
+
# # ...
|
1528
|
+
# end
|
1529
|
+
# end
|
1530
|
+
#
|
1531
|
+
# @see #include
|
1532
|
+
# @see #extend
|
1533
|
+
def prepend(mod, *filters)
|
1534
|
+
define_mixed_in_module(mod, filters, @prepend_modules, :prepend) do |group|
|
1535
|
+
safe_prepend(mod, group)
|
1536
|
+
end
|
1537
|
+
end
|
1050
1538
|
end
|
1051
1539
|
|
1052
1540
|
# @private
|
1053
1541
|
#
|
1054
|
-
# Used internally to extend a group with modules using `include` and/or
|
1542
|
+
# Used internally to extend a group with modules using `include`, `prepend` and/or
|
1055
1543
|
# `extend`.
|
1056
1544
|
def configure_group(group)
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1545
|
+
group.hooks.register_globals(group, hooks)
|
1546
|
+
|
1547
|
+
configure_group_with group, @include_modules, :safe_include
|
1548
|
+
configure_group_with group, @extend_modules, :safe_extend
|
1549
|
+
configure_group_with group, @prepend_modules, :safe_prepend
|
1061
1550
|
end
|
1062
1551
|
|
1063
1552
|
# @private
|
1064
|
-
|
1065
|
-
|
1553
|
+
#
|
1554
|
+
# Used internally to extend the singleton class of a single example's
|
1555
|
+
# example group instance with modules using `include` and/or `extend`.
|
1556
|
+
def configure_example(example, example_hooks)
|
1557
|
+
example_hooks.register_global_singleton_context_hooks(example, hooks)
|
1558
|
+
singleton_group = example.example_group_instance.singleton_class
|
1559
|
+
|
1560
|
+
# We replace the metadata so that SharedExampleGroupModule#included
|
1561
|
+
# has access to the example's metadata[:location].
|
1562
|
+
singleton_group.with_replaced_metadata(example.metadata) do
|
1563
|
+
modules = @include_modules.items_for(example.metadata)
|
1564
|
+
modules.each do |mod|
|
1565
|
+
safe_include(mod, example.example_group_instance.singleton_class)
|
1566
|
+
end
|
1567
|
+
|
1568
|
+
MemoizedHelpers.define_helpers_on(singleton_group) unless modules.empty?
|
1569
|
+
end
|
1066
1570
|
end
|
1067
1571
|
|
1068
1572
|
# @private
|
1069
1573
|
def requires=(paths)
|
1070
1574
|
directories = ['lib', default_path].select { |p| File.directory? p }
|
1071
1575
|
RSpec::Core::RubyProject.add_to_load_path(*directories)
|
1072
|
-
paths.each { |path| require path }
|
1576
|
+
paths.each { |path| load_file_handling_errors(:require, path) }
|
1073
1577
|
@requires += paths
|
1074
1578
|
end
|
1075
1579
|
|
1076
1580
|
# @private
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
host.extend(mod) unless host.singleton_class < mod
|
1081
|
-
end
|
1082
|
-
else
|
1083
|
-
# @private
|
1084
|
-
def safe_extend(mod, host)
|
1085
|
-
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
|
1581
|
+
def in_project_source_dir_regex
|
1582
|
+
regexes = project_source_dirs.map do |dir|
|
1583
|
+
/\A#{Regexp.escape(File.expand_path(dir))}\//
|
1086
1584
|
end
|
1585
|
+
|
1586
|
+
Regexp.union(regexes)
|
1087
1587
|
end
|
1088
1588
|
|
1089
1589
|
# @private
|
@@ -1102,7 +1602,22 @@ module RSpec
|
|
1102
1602
|
|
1103
1603
|
# @private
|
1104
1604
|
def load_spec_files
|
1105
|
-
|
1605
|
+
# Note which spec files world is already aware of.
|
1606
|
+
# This is generally only needed for when the user runs
|
1607
|
+
# `ruby path/to/spec.rb` (and loads `rspec/autorun`) --
|
1608
|
+
# in that case, the spec file was loaded by `ruby` and
|
1609
|
+
# isn't loaded by us here so we only know about it because
|
1610
|
+
# of an example group being registered in it.
|
1611
|
+
world.registered_example_group_files.each do |f|
|
1612
|
+
loaded_spec_files << f # the registered files are already expended absolute paths
|
1613
|
+
end
|
1614
|
+
|
1615
|
+
files_to_run.uniq.each do |f|
|
1616
|
+
file = File.expand_path(f)
|
1617
|
+
load_file_handling_errors(:load, file)
|
1618
|
+
loaded_spec_files << file
|
1619
|
+
end
|
1620
|
+
|
1106
1621
|
@spec_files_loaded = true
|
1107
1622
|
end
|
1108
1623
|
|
@@ -1112,7 +1627,8 @@ module RSpec
|
|
1112
1627
|
# Formats the docstring output using the block provided.
|
1113
1628
|
#
|
1114
1629
|
# @example
|
1115
|
-
# # This will strip the descriptions of both examples and example
|
1630
|
+
# # This will strip the descriptions of both examples and example
|
1631
|
+
# # groups.
|
1116
1632
|
# RSpec.configure do |config|
|
1117
1633
|
# config.format_docstrings { |s| s.strip }
|
1118
1634
|
# end
|
@@ -1126,8 +1642,6 @@ module RSpec
|
|
1126
1642
|
end
|
1127
1643
|
|
1128
1644
|
# @private
|
1129
|
-
# @macro [attach] delegate_to_ordering_manager
|
1130
|
-
# @!method $1
|
1131
1645
|
def self.delegate_to_ordering_manager(*methods)
|
1132
1646
|
methods.each do |method|
|
1133
1647
|
define_method method do |*args, &block|
|
@@ -1136,12 +1650,12 @@ module RSpec
|
|
1136
1650
|
end
|
1137
1651
|
end
|
1138
1652
|
|
1139
|
-
#
|
1653
|
+
# @!method seed=(value)
|
1140
1654
|
#
|
1141
1655
|
# Sets the seed value and sets the default global ordering to random.
|
1142
1656
|
delegate_to_ordering_manager :seed=
|
1143
1657
|
|
1144
|
-
#
|
1658
|
+
# @!method seed
|
1145
1659
|
# Seed for random ordering (default: generated randomly each run).
|
1146
1660
|
#
|
1147
1661
|
# When you run specs with `--order random`, RSpec generates a random seed
|
@@ -1155,20 +1669,28 @@ module RSpec
|
|
1155
1669
|
# don't accidentally leave the seed encoded.
|
1156
1670
|
delegate_to_ordering_manager :seed
|
1157
1671
|
|
1158
|
-
#
|
1672
|
+
# @!method order=(value)
|
1159
1673
|
#
|
1160
|
-
# Sets the default global
|
1674
|
+
# Sets the default global ordering strategy. By default this can be one
|
1675
|
+
# of `:defined`, `:random`, but is customizable through the
|
1676
|
+
# `register_ordering` API. If order is set to `'rand:<seed>'`,
|
1677
|
+
# the seed will also be set.
|
1678
|
+
#
|
1679
|
+
# @see #register_ordering
|
1161
1680
|
delegate_to_ordering_manager :order=
|
1162
1681
|
|
1163
|
-
#
|
1682
|
+
# @!method register_ordering(name)
|
1683
|
+
#
|
1164
1684
|
# Registers a named ordering strategy that can later be
|
1165
1685
|
# used to order an example group's subgroups by adding
|
1166
1686
|
# `:order => <name>` metadata to the example group.
|
1167
1687
|
#
|
1168
1688
|
# @param name [Symbol] The name of the ordering.
|
1169
1689
|
# @yield Block that will order the given examples or example groups
|
1170
|
-
# @yieldparam list [Array<RSpec::Core::Example>,
|
1171
|
-
#
|
1690
|
+
# @yieldparam list [Array<RSpec::Core::Example>,
|
1691
|
+
# Array<RSpec::Core::ExampleGroup>] The examples or groups to order
|
1692
|
+
# @yieldreturn [Array<RSpec::Core::Example>,
|
1693
|
+
# Array<RSpec::Core::ExampleGroup>] The re-ordered examples or groups
|
1172
1694
|
#
|
1173
1695
|
# @example
|
1174
1696
|
# RSpec.configure do |rspec|
|
@@ -1177,19 +1699,38 @@ module RSpec
|
|
1177
1699
|
# end
|
1178
1700
|
# end
|
1179
1701
|
#
|
1180
|
-
# describe MyClass, :order => :reverse do
|
1702
|
+
# RSpec.describe 'MyClass', :order => :reverse do
|
1181
1703
|
# # ...
|
1182
1704
|
# end
|
1183
1705
|
#
|
1184
1706
|
# @note Pass the symbol `:global` to set the ordering strategy that
|
1185
1707
|
# will be used to order the top-level example groups and any example
|
1186
1708
|
# groups that do not have declared `:order` metadata.
|
1709
|
+
#
|
1710
|
+
# @example
|
1711
|
+
# RSpec.configure do |rspec|
|
1712
|
+
# rspec.register_ordering :global do |examples|
|
1713
|
+
# acceptance, other = examples.partition do |example|
|
1714
|
+
# example.metadata[:type] == :acceptance
|
1715
|
+
# end
|
1716
|
+
# other + acceptance
|
1717
|
+
# end
|
1718
|
+
# end
|
1719
|
+
#
|
1720
|
+
# RSpec.describe 'MyClass', :type => :acceptance do
|
1721
|
+
# # will run last
|
1722
|
+
# end
|
1723
|
+
#
|
1724
|
+
# RSpec.describe 'MyClass' do
|
1725
|
+
# # will run first
|
1726
|
+
# end
|
1727
|
+
#
|
1187
1728
|
delegate_to_ordering_manager :register_ordering
|
1188
1729
|
|
1189
1730
|
# @private
|
1190
1731
|
delegate_to_ordering_manager :seed_used?, :ordering_registry
|
1191
1732
|
|
1192
|
-
# Set Ruby warnings on or off
|
1733
|
+
# Set Ruby warnings on or off.
|
1193
1734
|
def warnings=(value)
|
1194
1735
|
$VERBOSE = !!value
|
1195
1736
|
end
|
@@ -1199,6 +1740,25 @@ module RSpec
|
|
1199
1740
|
$VERBOSE
|
1200
1741
|
end
|
1201
1742
|
|
1743
|
+
# @private
|
1744
|
+
RAISE_ERROR_WARNING_NOTIFIER = lambda { |message| raise message }
|
1745
|
+
|
1746
|
+
# Turns warnings into errors. This can be useful when
|
1747
|
+
# you want RSpec to run in a 'strict' no warning situation.
|
1748
|
+
#
|
1749
|
+
# @example
|
1750
|
+
#
|
1751
|
+
# RSpec.configure do |rspec|
|
1752
|
+
# rspec.raise_on_warning = true
|
1753
|
+
# end
|
1754
|
+
def raise_on_warning=(value)
|
1755
|
+
if value
|
1756
|
+
RSpec::Support.warning_notifier = RAISE_ERROR_WARNING_NOTIFIER
|
1757
|
+
else
|
1758
|
+
RSpec::Support.warning_notifier = RSpec::Support::DEFAULT_WARNING_NOTIFIER
|
1759
|
+
end
|
1760
|
+
end
|
1761
|
+
|
1202
1762
|
# Exposes the current running example via the named
|
1203
1763
|
# helper method. RSpec 2.x exposed this via `example`,
|
1204
1764
|
# but in RSpec 3.0, the example is instead exposed via
|
@@ -1215,7 +1775,7 @@ module RSpec
|
|
1215
1775
|
# rspec.expose_current_running_example_as :example
|
1216
1776
|
# end
|
1217
1777
|
#
|
1218
|
-
# describe MyClass do
|
1778
|
+
# RSpec.describe MyClass do
|
1219
1779
|
# before do
|
1220
1780
|
# # `example` can be used here because of the above config.
|
1221
1781
|
# do_something if example.metadata[:type] == "foo"
|
@@ -1252,7 +1812,7 @@ module RSpec
|
|
1252
1812
|
# `shared_examples_for`, etc) onto `main` and `Module`, instead
|
1253
1813
|
# requiring you to prefix these methods with `RSpec.`. It enables
|
1254
1814
|
# expect-only syntax for rspec-mocks and rspec-expectations. It
|
1255
|
-
# simply disables monkey patching on whatever pieces of
|
1815
|
+
# simply disables monkey patching on whatever pieces of RSpec
|
1256
1816
|
# the user is using.
|
1257
1817
|
#
|
1258
1818
|
# @note It configures rspec-mocks and rspec-expectations only
|
@@ -1265,7 +1825,7 @@ module RSpec
|
|
1265
1825
|
#
|
1266
1826
|
# @example
|
1267
1827
|
#
|
1268
|
-
# # It disables all monkey patching
|
1828
|
+
# # It disables all monkey patching.
|
1269
1829
|
# RSpec.configure do |config|
|
1270
1830
|
# config.disable_monkey_patching!
|
1271
1831
|
# end
|
@@ -1279,7 +1839,7 @@ module RSpec
|
|
1279
1839
|
# mocks.patch_marshal_to_support_partial_doubles = false
|
1280
1840
|
# end
|
1281
1841
|
#
|
1282
|
-
# config.
|
1842
|
+
# config.expect_with :rspec do |expectations|
|
1283
1843
|
# expectations.syntax = :expect
|
1284
1844
|
# end
|
1285
1845
|
# end
|
@@ -1295,43 +1855,333 @@ module RSpec
|
|
1295
1855
|
|
1296
1856
|
# Defines a callback that can assign derived metadata values.
|
1297
1857
|
#
|
1298
|
-
# @param filters [Array<Symbol>, Hash] metadata filters that determine
|
1299
|
-
# or group metadata hashes the callback will be triggered
|
1300
|
-
# the callback will be run against the metadata
|
1301
|
-
#
|
1302
|
-
#
|
1858
|
+
# @param filters [Array<Symbol>, Hash] metadata filters that determine
|
1859
|
+
# which example or group metadata hashes the callback will be triggered
|
1860
|
+
# for. If none are given, the callback will be run against the metadata
|
1861
|
+
# hashes of all groups and examples.
|
1862
|
+
# @yieldparam metadata [Hash] original metadata hash from an example or
|
1863
|
+
# group. Mutate this in your block as needed.
|
1303
1864
|
#
|
1304
1865
|
# @example
|
1305
1866
|
# RSpec.configure do |config|
|
1306
|
-
# # Tag all groups and examples in the spec/unit directory with
|
1867
|
+
# # Tag all groups and examples in the spec/unit directory with
|
1868
|
+
# # :type => :unit
|
1307
1869
|
# config.define_derived_metadata(:file_path => %r{/spec/unit/}) do |metadata|
|
1308
1870
|
# metadata[:type] = :unit
|
1309
1871
|
# end
|
1310
1872
|
# end
|
1311
1873
|
def define_derived_metadata(*filters, &block)
|
1312
1874
|
meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
|
1313
|
-
@derived_metadata_blocks
|
1875
|
+
@derived_metadata_blocks.append(block, meta)
|
1876
|
+
end
|
1877
|
+
|
1878
|
+
# Defines a callback that runs after the first example with matching
|
1879
|
+
# metadata is defined. If no examples are defined with matching metadata,
|
1880
|
+
# it will not get called at all.
|
1881
|
+
#
|
1882
|
+
# This can be used to ensure some setup is performed (such as bootstrapping
|
1883
|
+
# a DB or loading a specific file that adds significantly to the boot time)
|
1884
|
+
# if needed (as indicated by the presence of an example with matching metadata)
|
1885
|
+
# but avoided otherwise.
|
1886
|
+
#
|
1887
|
+
# @example
|
1888
|
+
# RSpec.configure do |config|
|
1889
|
+
# config.when_first_matching_example_defined(:db) do
|
1890
|
+
# # Load a support file that does some heavyweight setup,
|
1891
|
+
# # including bootstrapping the DB, but only if we have loaded
|
1892
|
+
# # any examples tagged with `:db`.
|
1893
|
+
# require 'support/db'
|
1894
|
+
# end
|
1895
|
+
# end
|
1896
|
+
def when_first_matching_example_defined(*filters)
|
1897
|
+
specified_meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
|
1898
|
+
|
1899
|
+
callback = lambda do |example_or_group_meta|
|
1900
|
+
# Example groups do not have `:example_group` metadata
|
1901
|
+
# (instead they have `:parent_example_group` metadata).
|
1902
|
+
return unless example_or_group_meta.key?(:example_group)
|
1903
|
+
|
1904
|
+
# Ensure the callback only fires once.
|
1905
|
+
@derived_metadata_blocks.delete(callback, specified_meta)
|
1906
|
+
|
1907
|
+
yield
|
1908
|
+
end
|
1909
|
+
|
1910
|
+
@derived_metadata_blocks.append(callback, specified_meta)
|
1314
1911
|
end
|
1315
1912
|
|
1316
1913
|
# @private
|
1317
1914
|
def apply_derived_metadata_to(metadata)
|
1318
|
-
|
1319
|
-
|
1915
|
+
already_run_blocks = Set.new
|
1916
|
+
|
1917
|
+
# We loop and attempt to re-apply metadata blocks to support cascades
|
1918
|
+
# (e.g. where a derived bit of metadata triggers the application of
|
1919
|
+
# another piece of derived metadata, etc)
|
1920
|
+
#
|
1921
|
+
# We limit our looping to 200 times as a way to detect infinitely recursing derived metadata blocks.
|
1922
|
+
# It's hard to imagine a valid use case for a derived metadata cascade greater than 200 iterations.
|
1923
|
+
200.times do
|
1924
|
+
return if @derived_metadata_blocks.items_for(metadata).all? do |block|
|
1925
|
+
already_run_blocks.include?(block).tap do |skip_block|
|
1926
|
+
block.call(metadata) unless skip_block
|
1927
|
+
already_run_blocks << block
|
1928
|
+
end
|
1929
|
+
end
|
1930
|
+
end
|
1931
|
+
|
1932
|
+
# If we got here, then `@derived_metadata_blocks.items_for(metadata).all?` never returned
|
1933
|
+
# `true` above and we treat this as an attempt to recurse infinitely. It's better to fail
|
1934
|
+
# with a clear # error than hang indefinitely, which is what would happen if we didn't limit
|
1935
|
+
# the looping above.
|
1936
|
+
raise SystemStackError, "Attempted to recursively derive metadata indefinitely."
|
1937
|
+
end
|
1938
|
+
|
1939
|
+
# Defines a `before` hook. See {Hooks#before} for full docs.
|
1940
|
+
#
|
1941
|
+
# This method differs from {Hooks#before} in only one way: it supports
|
1942
|
+
# the `:suite` scope. Hooks with the `:suite` scope will be run once before
|
1943
|
+
# the first example of the entire suite is executed. Conditions passed along
|
1944
|
+
# with `:suite` are effectively ignored.
|
1945
|
+
#
|
1946
|
+
# @see #prepend_before
|
1947
|
+
# @see #after
|
1948
|
+
# @see #append_after
|
1949
|
+
def before(scope=nil, *meta, &block)
|
1950
|
+
handle_suite_hook(scope, meta) do
|
1951
|
+
@before_suite_hooks << Hooks::BeforeHook.new(block, {})
|
1952
|
+
end || begin
|
1953
|
+
# defeat Ruby 2.5 lazy proc allocation to ensure
|
1954
|
+
# the methods below are passed the same proc instances
|
1955
|
+
# so `Hook` equality is preserved. For more info, see:
|
1956
|
+
# https://bugs.ruby-lang.org/issues/14045#note-5
|
1957
|
+
block.__id__
|
1958
|
+
|
1959
|
+
add_hook_to_existing_matching_groups(meta, scope) { |g| g.before(scope, *meta, &block) }
|
1960
|
+
super(scope, *meta, &block)
|
1961
|
+
end
|
1962
|
+
end
|
1963
|
+
alias_method :append_before, :before
|
1964
|
+
|
1965
|
+
# Adds `block` to the start of the list of `before` blocks in the same
|
1966
|
+
# scope (`:example`, `:context`, or `:suite`), in contrast to {#before},
|
1967
|
+
# which adds the hook to the end of the list.
|
1968
|
+
#
|
1969
|
+
# See {Hooks#before} for full `before` hook docs.
|
1970
|
+
#
|
1971
|
+
# This method differs from {Hooks#prepend_before} in only one way: it supports
|
1972
|
+
# the `:suite` scope. Hooks with the `:suite` scope will be run once before
|
1973
|
+
# the first example of the entire suite is executed. Conditions passed along
|
1974
|
+
# with `:suite` are effectively ignored.
|
1975
|
+
#
|
1976
|
+
# @see #before
|
1977
|
+
# @see #after
|
1978
|
+
# @see #append_after
|
1979
|
+
def prepend_before(scope=nil, *meta, &block)
|
1980
|
+
handle_suite_hook(scope, meta) do
|
1981
|
+
@before_suite_hooks.unshift Hooks::BeforeHook.new(block, {})
|
1982
|
+
end || begin
|
1983
|
+
# defeat Ruby 2.5 lazy proc allocation to ensure
|
1984
|
+
# the methods below are passed the same proc instances
|
1985
|
+
# so `Hook` equality is preserved. For more info, see:
|
1986
|
+
# https://bugs.ruby-lang.org/issues/14045#note-5
|
1987
|
+
block.__id__
|
1988
|
+
|
1989
|
+
add_hook_to_existing_matching_groups(meta, scope) { |g| g.prepend_before(scope, *meta, &block) }
|
1990
|
+
super(scope, *meta, &block)
|
1991
|
+
end
|
1992
|
+
end
|
1993
|
+
|
1994
|
+
# Defines a `after` hook. See {Hooks#after} for full docs.
|
1995
|
+
#
|
1996
|
+
# This method differs from {Hooks#after} in only one way: it supports
|
1997
|
+
# the `:suite` scope. Hooks with the `:suite` scope will be run once after
|
1998
|
+
# the last example of the entire suite is executed. Conditions passed along
|
1999
|
+
# with `:suite` are effectively ignored.
|
2000
|
+
#
|
2001
|
+
# @see #append_after
|
2002
|
+
# @see #before
|
2003
|
+
# @see #prepend_before
|
2004
|
+
def after(scope=nil, *meta, &block)
|
2005
|
+
handle_suite_hook(scope, meta) do
|
2006
|
+
@after_suite_hooks.unshift Hooks::AfterHook.new(block, {})
|
2007
|
+
end || begin
|
2008
|
+
# defeat Ruby 2.5 lazy proc allocation to ensure
|
2009
|
+
# the methods below are passed the same proc instances
|
2010
|
+
# so `Hook` equality is preserved. For more info, see:
|
2011
|
+
# https://bugs.ruby-lang.org/issues/14045#note-5
|
2012
|
+
block.__id__
|
2013
|
+
|
2014
|
+
add_hook_to_existing_matching_groups(meta, scope) { |g| g.after(scope, *meta, &block) }
|
2015
|
+
super(scope, *meta, &block)
|
2016
|
+
end
|
2017
|
+
end
|
2018
|
+
alias_method :prepend_after, :after
|
2019
|
+
|
2020
|
+
# Adds `block` to the end of the list of `after` blocks in the same
|
2021
|
+
# scope (`:example`, `:context`, or `:suite`), in contrast to {#after},
|
2022
|
+
# which adds the hook to the start of the list.
|
2023
|
+
#
|
2024
|
+
# See {Hooks#after} for full `after` hook docs.
|
2025
|
+
#
|
2026
|
+
# This method differs from {Hooks#append_after} in only one way: it supports
|
2027
|
+
# the `:suite` scope. Hooks with the `:suite` scope will be run once after
|
2028
|
+
# the last example of the entire suite is executed. Conditions passed along
|
2029
|
+
# with `:suite` are effectively ignored.
|
2030
|
+
#
|
2031
|
+
# @see #append_after
|
2032
|
+
# @see #before
|
2033
|
+
# @see #prepend_before
|
2034
|
+
def append_after(scope=nil, *meta, &block)
|
2035
|
+
handle_suite_hook(scope, meta) do
|
2036
|
+
@after_suite_hooks << Hooks::AfterHook.new(block, {})
|
2037
|
+
end || begin
|
2038
|
+
# defeat Ruby 2.5 lazy proc allocation to ensure
|
2039
|
+
# the methods below are passed the same proc instances
|
2040
|
+
# so `Hook` equality is preserved. For more info, see:
|
2041
|
+
# https://bugs.ruby-lang.org/issues/14045#note-5
|
2042
|
+
block.__id__
|
2043
|
+
|
2044
|
+
add_hook_to_existing_matching_groups(meta, scope) { |g| g.append_after(scope, *meta, &block) }
|
2045
|
+
super(scope, *meta, &block)
|
2046
|
+
end
|
2047
|
+
end
|
2048
|
+
|
2049
|
+
# Registers `block` as an `around` hook.
|
2050
|
+
#
|
2051
|
+
# See {Hooks#around} for full `around` hook docs.
|
2052
|
+
def around(scope=nil, *meta, &block)
|
2053
|
+
# defeat Ruby 2.5 lazy proc allocation to ensure
|
2054
|
+
# the methods below are passed the same proc instances
|
2055
|
+
# so `Hook` equality is preserved. For more info, see:
|
2056
|
+
# https://bugs.ruby-lang.org/issues/14045#note-5
|
2057
|
+
block.__id__
|
2058
|
+
|
2059
|
+
add_hook_to_existing_matching_groups(meta, scope) { |g| g.around(scope, *meta, &block) }
|
2060
|
+
super(scope, *meta, &block)
|
2061
|
+
end
|
2062
|
+
|
2063
|
+
# @private
|
2064
|
+
def with_suite_hooks
|
2065
|
+
return yield if dry_run?
|
2066
|
+
|
2067
|
+
begin
|
2068
|
+
RSpec.current_scope = :before_suite_hook
|
2069
|
+
run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
|
2070
|
+
yield
|
2071
|
+
ensure
|
2072
|
+
RSpec.current_scope = :after_suite_hook
|
2073
|
+
run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
|
2074
|
+
RSpec.current_scope = :suite
|
2075
|
+
end
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
# @private
|
2079
|
+
# Holds the various registered hooks. Here we use a FilterableItemRepository
|
2080
|
+
# implementation that is specifically optimized for the read/write patterns
|
2081
|
+
# of the config object.
|
2082
|
+
def hooks
|
2083
|
+
@hooks ||= HookCollections.new(self, FilterableItemRepository::QueryOptimized)
|
2084
|
+
end
|
2085
|
+
|
2086
|
+
# Invokes block before defining an example group
|
2087
|
+
def on_example_group_definition(&block)
|
2088
|
+
on_example_group_definition_callbacks << block
|
2089
|
+
end
|
2090
|
+
|
2091
|
+
# @api private
|
2092
|
+
# Returns an array of blocks to call before defining an example group
|
2093
|
+
def on_example_group_definition_callbacks
|
2094
|
+
@on_example_group_definition_callbacks ||= []
|
2095
|
+
end
|
2096
|
+
|
2097
|
+
# @private
|
2098
|
+
def bisect_runner_class
|
2099
|
+
@bisect_runner_class ||= begin
|
2100
|
+
case bisect_runner
|
2101
|
+
when :fork
|
2102
|
+
RSpec::Support.require_rspec_core 'bisect/fork_runner'
|
2103
|
+
Bisect::ForkRunner
|
2104
|
+
when :shell
|
2105
|
+
RSpec::Support.require_rspec_core 'bisect/shell_runner'
|
2106
|
+
Bisect::ShellRunner
|
2107
|
+
else
|
2108
|
+
raise "Unsupported value for `bisect_runner` (#{bisect_runner.inspect}). " \
|
2109
|
+
"Only `:fork` and `:shell` are supported."
|
2110
|
+
end
|
1320
2111
|
end
|
1321
2112
|
end
|
1322
2113
|
|
1323
2114
|
private
|
1324
2115
|
|
2116
|
+
def load_file_handling_errors(method, file)
|
2117
|
+
__send__(method, file)
|
2118
|
+
rescue LoadError => ex
|
2119
|
+
relative_file = Metadata.relative_path(file)
|
2120
|
+
suggestions = DidYouMean.new(relative_file).call
|
2121
|
+
reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{suggestions}")
|
2122
|
+
RSpec.world.wants_to_quit = true
|
2123
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
|
2124
|
+
relative_file = Metadata.relative_path(file)
|
2125
|
+
reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
|
2126
|
+
RSpec.world.wants_to_quit = true
|
2127
|
+
rescue SystemExit => ex
|
2128
|
+
relative_file = Metadata.relative_path(file)
|
2129
|
+
reporter.notify_non_example_exception(
|
2130
|
+
ex,
|
2131
|
+
"While loading #{relative_file} an `exit` / `raise SystemExit` occurred, RSpec will now quit."
|
2132
|
+
)
|
2133
|
+
RSpec.world.rspec_is_quitting = true
|
2134
|
+
raise ex
|
2135
|
+
end
|
2136
|
+
|
2137
|
+
def handle_suite_hook(scope, meta)
|
2138
|
+
return nil unless scope == :suite
|
2139
|
+
|
2140
|
+
unless meta.empty?
|
2141
|
+
# TODO: in RSpec 4, consider raising an error here.
|
2142
|
+
# We warn only for backwards compatibility.
|
2143
|
+
RSpec.warn_with "WARNING: `:suite` hooks do not support metadata since " \
|
2144
|
+
"they apply to the suite as a whole rather than " \
|
2145
|
+
"any individual example or example group that has metadata. " \
|
2146
|
+
"The metadata you have provided (#{meta.inspect}) will be ignored."
|
2147
|
+
end
|
2148
|
+
|
2149
|
+
yield
|
2150
|
+
end
|
2151
|
+
|
2152
|
+
def run_suite_hooks(hook_description, hooks)
|
2153
|
+
context = SuiteHookContext.new(hook_description, reporter)
|
2154
|
+
|
2155
|
+
hooks.each do |hook|
|
2156
|
+
begin
|
2157
|
+
hook.run(context)
|
2158
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
|
2159
|
+
context.set_exception(ex)
|
2160
|
+
|
2161
|
+
# Do not run subsequent `before` hooks if one fails.
|
2162
|
+
# But for `after` hooks, we run them all so that all
|
2163
|
+
# cleanup bits get a chance to complete, minimizing the
|
2164
|
+
# chance that resources get left behind.
|
2165
|
+
break if hooks.equal?(@before_suite_hooks)
|
2166
|
+
end
|
2167
|
+
end
|
2168
|
+
end
|
2169
|
+
|
1325
2170
|
def get_files_to_run(paths)
|
1326
|
-
FlatMap.flat_map(paths_to_check(paths)) do |path|
|
2171
|
+
files = FlatMap.flat_map(paths_to_check(paths)) do |path|
|
1327
2172
|
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
1328
2173
|
File.directory?(path) ? gather_directories(path) : extract_location(path)
|
1329
|
-
end.
|
2174
|
+
end.uniq
|
2175
|
+
|
2176
|
+
return files unless only_failures?
|
2177
|
+
relative_files = files.map { |f| Metadata.relative_path(File.expand_path f) }
|
2178
|
+
intersection = (relative_files & spec_files_with_failures.to_a)
|
2179
|
+
intersection.empty? ? files : intersection
|
1330
2180
|
end
|
1331
2181
|
|
1332
2182
|
def paths_to_check(paths)
|
1333
2183
|
return paths if pattern_might_load_specs_from_vendored_dirs?
|
1334
|
-
paths + [
|
2184
|
+
paths + [Dir.getwd]
|
1335
2185
|
end
|
1336
2186
|
|
1337
2187
|
def pattern_might_load_specs_from_vendored_dirs?
|
@@ -1341,11 +2191,12 @@ module RSpec
|
|
1341
2191
|
def gather_directories(path)
|
1342
2192
|
include_files = get_matching_files(path, pattern)
|
1343
2193
|
exclude_files = get_matching_files(path, exclude_pattern)
|
1344
|
-
(include_files - exclude_files).
|
2194
|
+
(include_files - exclude_files).uniq
|
1345
2195
|
end
|
1346
2196
|
|
1347
2197
|
def get_matching_files(path, pattern)
|
1348
|
-
Dir[file_glob_from(path, pattern)]
|
2198
|
+
raw_files = Dir[file_glob_from(path, pattern)]
|
2199
|
+
raw_files.map { |file| File.expand_path(file) }.sort
|
1349
2200
|
end
|
1350
2201
|
|
1351
2202
|
def file_glob_from(path, pattern)
|
@@ -1355,6 +2206,7 @@ module RSpec
|
|
1355
2206
|
end
|
1356
2207
|
|
1357
2208
|
if RSpec::Support::OS.windows?
|
2209
|
+
# :nocov:
|
1358
2210
|
def absolute_pattern?(pattern)
|
1359
2211
|
pattern =~ /\A[A-Z]:\\/ || windows_absolute_network_path?(pattern)
|
1360
2212
|
end
|
@@ -1363,6 +2215,7 @@ module RSpec
|
|
1363
2215
|
return false unless ::File::ALT_SEPARATOR
|
1364
2216
|
pattern.start_with?(::File::ALT_SEPARATOR + ::File::ALT_SEPARATOR)
|
1365
2217
|
end
|
2218
|
+
# :nocov:
|
1366
2219
|
else
|
1367
2220
|
def absolute_pattern?(pattern)
|
1368
2221
|
pattern.start_with?(File::Separator)
|
@@ -1374,24 +2227,38 @@ module RSpec
|
|
1374
2227
|
|
1375
2228
|
if match
|
1376
2229
|
captures = match.captures
|
1377
|
-
path
|
2230
|
+
path = captures[0]
|
2231
|
+
lines = captures[1][1..-1].split(":").map(&:to_i)
|
1378
2232
|
filter_manager.add_location path, lines
|
2233
|
+
else
|
2234
|
+
path, scoped_ids = Example.parse_id(path)
|
2235
|
+
filter_manager.add_ids(path, scoped_ids.split(/\s*,\s*/)) if scoped_ids
|
1379
2236
|
end
|
1380
2237
|
|
1381
2238
|
return [] if path == default_path
|
1382
|
-
path
|
2239
|
+
File.expand_path(path)
|
1383
2240
|
end
|
1384
2241
|
|
1385
2242
|
def command
|
1386
2243
|
$0.split(File::SEPARATOR).last
|
1387
2244
|
end
|
1388
2245
|
|
1389
|
-
def value_for(key
|
1390
|
-
@preferred_options.
|
2246
|
+
def value_for(key)
|
2247
|
+
@preferred_options.fetch(key) { yield }
|
2248
|
+
end
|
2249
|
+
|
2250
|
+
def define_built_in_hooks
|
2251
|
+
around(:example, :aggregate_failures => true) do |procsy|
|
2252
|
+
begin
|
2253
|
+
aggregate_failures(nil, :hide_backtrace => true, &procsy)
|
2254
|
+
rescue Support::AllExceptionsExceptOnesWeMustNotRescue => exception
|
2255
|
+
procsy.example.set_aggregate_failures_exception(exception)
|
2256
|
+
end
|
2257
|
+
end
|
1391
2258
|
end
|
1392
2259
|
|
1393
2260
|
def assert_no_example_groups_defined(config_option)
|
1394
|
-
return unless
|
2261
|
+
return unless world.example_groups.any?
|
1395
2262
|
|
1396
2263
|
raise MustBeConfiguredBeforeExampleGroupsError.new(
|
1397
2264
|
"RSpec's #{config_option} configuration option must be configured before " \
|
@@ -1399,8 +2266,12 @@ module RSpec
|
|
1399
2266
|
)
|
1400
2267
|
end
|
1401
2268
|
|
2269
|
+
def output_wrapper
|
2270
|
+
@output_wrapper ||= OutputWrapper.new(output_stream)
|
2271
|
+
end
|
2272
|
+
|
1402
2273
|
def output_to_tty?(output=output_stream)
|
1403
|
-
|
2274
|
+
output.respond_to?(:tty?) && output.tty?
|
1404
2275
|
end
|
1405
2276
|
|
1406
2277
|
def conditionally_disable_mocks_monkey_patching
|
@@ -1428,13 +2299,87 @@ module RSpec
|
|
1428
2299
|
|
1429
2300
|
def update_pattern_attr(name, value)
|
1430
2301
|
if @spec_files_loaded
|
1431
|
-
RSpec.warning "Configuring `#{name}` to #{value} has no effect since
|
2302
|
+
RSpec.warning "Configuring `#{name}` to #{value} has no effect since " \
|
2303
|
+
"RSpec has already loaded the spec files."
|
1432
2304
|
end
|
1433
2305
|
|
1434
2306
|
instance_variable_set(:"@#{name}", value)
|
1435
2307
|
@files_to_run = nil
|
1436
2308
|
end
|
2309
|
+
|
2310
|
+
def clear_values_derived_from_example_status_persistence_file_path
|
2311
|
+
@last_run_statuses = nil
|
2312
|
+
@spec_files_with_failures = nil
|
2313
|
+
end
|
2314
|
+
|
2315
|
+
def configure_group_with(group, module_list, application_method)
|
2316
|
+
module_list.items_for(group.metadata).each do |mod|
|
2317
|
+
__send__(application_method, mod, group)
|
2318
|
+
end
|
2319
|
+
end
|
2320
|
+
|
2321
|
+
def add_hook_to_existing_matching_groups(meta, scope, &block)
|
2322
|
+
# For example hooks, we have to apply it to each of the top level
|
2323
|
+
# groups, even if the groups do not match. When we apply it, we
|
2324
|
+
# apply it with the metadata, so it will only apply to examples
|
2325
|
+
# in the group that match the metadata.
|
2326
|
+
# #2280 for background and discussion.
|
2327
|
+
if scope == :example || scope == :each || scope.nil?
|
2328
|
+
world.example_groups.each(&block)
|
2329
|
+
else
|
2330
|
+
meta = Metadata.build_hash_from(meta.dup)
|
2331
|
+
on_existing_matching_groups(meta, &block)
|
2332
|
+
end
|
2333
|
+
end
|
2334
|
+
|
2335
|
+
def on_existing_matching_groups(meta)
|
2336
|
+
world.traverse_example_group_trees_until do |group|
|
2337
|
+
metadata_applies_to_group?(meta, group).tap do |applies|
|
2338
|
+
yield group if applies
|
2339
|
+
end
|
2340
|
+
end
|
2341
|
+
end
|
2342
|
+
|
2343
|
+
def metadata_applies_to_group?(meta, group)
|
2344
|
+
meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata)
|
2345
|
+
end
|
2346
|
+
|
2347
|
+
if RSpec::Support::RubyFeatures.module_prepends_supported?
|
2348
|
+
def safe_prepend(mod, host)
|
2349
|
+
host.__send__(:prepend, mod) unless host < mod
|
2350
|
+
end
|
2351
|
+
end
|
2352
|
+
|
2353
|
+
if RUBY_VERSION.to_f >= 1.9
|
2354
|
+
def safe_include(mod, host)
|
2355
|
+
host.__send__(:include, mod) unless host < mod
|
2356
|
+
end
|
2357
|
+
|
2358
|
+
def safe_extend(mod, host)
|
2359
|
+
host.extend(mod) unless host.singleton_class < mod
|
2360
|
+
end
|
2361
|
+
else # for 1.8.7
|
2362
|
+
# :nocov:
|
2363
|
+
def safe_include(mod, host)
|
2364
|
+
host.__send__(:include, mod) unless host.included_modules.include?(mod)
|
2365
|
+
end
|
2366
|
+
|
2367
|
+
def safe_extend(mod, host)
|
2368
|
+
host.extend(mod) unless (class << host; self; end).included_modules.include?(mod)
|
2369
|
+
end
|
2370
|
+
# :nocov:
|
2371
|
+
end
|
2372
|
+
|
2373
|
+
def define_mixed_in_module(mod, filters, mod_list, config_method, &block)
|
2374
|
+
unless Module === mod
|
2375
|
+
raise TypeError, "`RSpec.configuration.#{config_method}` expects a module but got: #{mod.inspect}"
|
2376
|
+
end
|
2377
|
+
|
2378
|
+
meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
|
2379
|
+
mod_list.append(mod, meta)
|
2380
|
+
on_existing_matching_groups(meta, &block)
|
2381
|
+
end
|
1437
2382
|
end
|
1438
|
-
# rubocop:enable
|
2383
|
+
# rubocop:enable Metrics/ClassLength
|
1439
2384
|
end
|
1440
2385
|
end
|