opal-rspec 0.4.3 → 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -3
- data/Gemfile +6 -5
- data/README.md +73 -13
- data/Rakefile +108 -12
- data/lib/opal/rspec/version.rb +1 -1
- data/lib/opal/rspec.rb +35 -12
- data/opal/opal/rspec/async/async_example.rb +87 -0
- data/opal/opal/rspec/async/example_group.rb +94 -0
- data/opal/opal/rspec/async/hooks.rb +46 -0
- data/opal/opal/rspec/async/legacy.rb +50 -0
- data/opal/opal/rspec/async.rb +4 -289
- data/opal/opal/rspec/browser_formatter.rb +55 -18
- data/opal/opal/rspec/fixes/caller_filter.rb +6 -0
- data/opal/opal/rspec/fixes/example.rb +20 -0
- data/opal/opal/rspec/fixes/example_groups.rb +32 -0
- data/opal/opal/rspec/fixes/expectations.rb +21 -0
- data/opal/opal/rspec/fixes/formatter.rb +62 -0
- data/opal/opal/rspec/fixes/kernel.rb +35 -0
- data/opal/opal/rspec/fixes/matchers.rb +15 -0
- data/opal/opal/rspec/fixes/mocks.rb +13 -0
- data/opal/opal/rspec/fixes/reporter.rb +12 -0
- data/opal/opal/rspec/fixes.rb +11 -115
- data/opal/opal/rspec/pre_require_fixes.rb +4 -0
- data/opal/opal/rspec/requires.rb +103 -35
- data/opal/opal/rspec/runner.rb +19 -15
- data/opal/opal/rspec/text_formatter.rb +24 -10
- data/opal/opal/rspec.rb +4 -9
- data/opal-rspec.gemspec +5 -2
- data/{vendor_lib → rspec/lib}/rspec/version.rb +1 -1
- data/{vendor_lib → rspec/lib}/rspec.rb +0 -0
- data/rspec-core/benchmarks/call_v_yield.rb +81 -0
- data/rspec-core/benchmarks/check_inclusion.rb +125 -0
- data/rspec-core/benchmarks/define_method_v_attr_reader_v_def.rb +81 -0
- data/rspec-core/benchmarks/eager_vs_lazy_metadata/define_examples.rb +22 -0
- data/rspec-core/benchmarks/eager_vs_lazy_metadata.rb +126 -0
- data/rspec-core/benchmarks/filter_object.rb +35 -0
- data/rspec-core/benchmarks/index_v_take_while.rb +47 -0
- data/rspec-core/benchmarks/map_then_flatten_vs_flat_map_benchmarks.rb +94 -0
- data/rspec-core/benchmarks/require_relative_v_require.rb +75 -0
- data/rspec-core/benchmarks/respond_to_v_defined.rb +72 -0
- data/rspec-core/benchmarks/several_regexps_v_one_big_one.rb +86 -0
- data/rspec-core/benchmarks/sort_by_v_shuffle.rb +83 -0
- data/rspec-core/benchmarks/to_proc_v_not_to_proc.rb +539 -0
- data/rspec-core/features/step_definitions/additional_cli_steps.rb +126 -0
- data/rspec-core/features/step_definitions/core_standalone_steps.rb +12 -0
- data/rspec-core/features/support/env.rb +21 -0
- data/rspec-core/features/support/require_expect_syntax_in_aruba_specs.rb +29 -0
- data/rspec-core/features/support/rubinius.rb +6 -0
- data/{vendor_lib → rspec-core/lib}/rspec/autorun.rb +0 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/backport_random.rb +40 -6
- data/rspec-core/lib/rspec/core/backtrace_formatter.rb +66 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/configuration.rb +561 -250
- data/rspec-core/lib/rspec/core/configuration_options.rb +173 -0
- data/rspec-core/lib/rspec/core/drb.rb +111 -0
- data/rspec-core/lib/rspec/core/dsl.rb +93 -0
- data/rspec-core/lib/rspec/core/example.rb +502 -0
- data/rspec-core/lib/rspec/core/example_group.rb +606 -0
- data/rspec-core/lib/rspec/core/filter_manager.rb +259 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/flat_map.rb +1 -0
- data/rspec-core/lib/rspec/core/formatters/base_formatter.rb +67 -0
- data/rspec-core/lib/rspec/core/formatters/base_text_formatter.rb +76 -0
- data/rspec-core/lib/rspec/core/formatters/console_codes.rb +64 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/deprecation_formatter.rb +65 -36
- data/rspec-core/lib/rspec/core/formatters/documentation_formatter.rb +68 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/helpers.rb +18 -13
- data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/html_formatter.rb +69 -75
- data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/html_printer.rb +17 -22
- data/rspec-core/lib/rspec/core/formatters/json_formatter.rb +94 -0
- data/rspec-core/lib/rspec/core/formatters/profile_formatter.rb +65 -0
- data/rspec-core/lib/rspec/core/formatters/progress_formatter.rb +28 -0
- data/rspec-core/lib/rspec/core/formatters/protocol.rb +163 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/formatters/snippet_extractor.rb +15 -12
- data/rspec-core/lib/rspec/core/formatters.rb +240 -0
- data/rspec-core/lib/rspec/core/hooks.rb +591 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/memoized_helpers.rb +82 -41
- data/rspec-core/lib/rspec/core/metadata.rb +437 -0
- data/rspec-core/lib/rspec/core/metadata_filter.rb +95 -0
- data/rspec-core/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/rspec-core/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/{vendor_lib/rspec/core/mocking/with_mocha.rb → rspec-core/lib/rspec/core/mocking_adapters/mocha.rb} +21 -16
- data/rspec-core/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/rspec-core/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/rspec-core/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/rspec-core/lib/rspec/core/notifications.rb +542 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/option_parser.rb +53 -65
- data/{vendor_lib → rspec-core/lib}/rspec/core/ordering.rb +11 -10
- data/rspec-core/lib/rspec/core/pending.rb +163 -0
- data/rspec-core/lib/rspec/core/project_initializer/spec/spec_helper.rb +89 -0
- data/rspec-core/lib/rspec/core/project_initializer.rb +48 -0
- data/rspec-core/lib/rspec/core/rake_task.rb +187 -0
- data/rspec-core/lib/rspec/core/reporter.rb +149 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/ruby_project.rb +3 -2
- data/rspec-core/lib/rspec/core/runner.rb +158 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/shared_context.rb +7 -5
- data/rspec-core/lib/rspec/core/shared_example_group.rb +182 -0
- data/rspec-core/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/rspec-core/lib/rspec/core/version.rb +9 -0
- data/rspec-core/lib/rspec/core/warnings.rb +40 -0
- data/{vendor_lib → rspec-core/lib}/rspec/core/world.rb +78 -26
- data/{vendor_lib → rspec-core/lib}/rspec/core.rb +64 -98
- data/rspec-core/spec/command_line/order_spec.rb +213 -0
- data/rspec-core/spec/rspec/core/backtrace_formatter_spec.rb +306 -0
- data/rspec-core/spec/rspec/core/configuration_options_spec.rb +425 -0
- data/rspec-core/spec/rspec/core/configuration_spec.rb +1963 -0
- data/rspec-core/spec/rspec/core/drb_spec.rb +278 -0
- data/rspec-core/spec/rspec/core/dsl_spec.rb +85 -0
- data/rspec-core/spec/rspec/core/example_execution_result_spec.rb +142 -0
- data/rspec-core/spec/rspec/core/example_group_constants_spec.rb +16 -0
- data/rspec-core/spec/rspec/core/example_group_spec.rb +1621 -0
- data/rspec-core/spec/rspec/core/example_spec.rb +662 -0
- data/rspec-core/spec/rspec/core/failed_example_notification_spec.rb +25 -0
- data/rspec-core/spec/rspec/core/filter_manager_spec.rb +299 -0
- data/rspec-core/spec/rspec/core/formatters/base_text_formatter_spec.rb +182 -0
- data/rspec-core/spec/rspec/core/formatters/console_codes_spec.rb +65 -0
- data/rspec-core/spec/rspec/core/formatters/deprecation_formatter_spec.rb +225 -0
- data/rspec-core/spec/rspec/core/formatters/documentation_formatter_spec.rb +111 -0
- data/rspec-core/spec/rspec/core/formatters/helpers_spec.rb +104 -0
- data/rspec-core/spec/rspec/core/formatters/html_formatter_spec.rb +111 -0
- data/rspec-core/spec/rspec/core/formatters/json_formatter_spec.rb +183 -0
- data/rspec-core/spec/rspec/core/formatters/profile_formatter_spec.rb +99 -0
- data/rspec-core/spec/rspec/core/formatters/progress_formatter_spec.rb +55 -0
- data/rspec-core/spec/rspec/core/formatters/snippet_extractor_spec.rb +26 -0
- data/rspec-core/spec/rspec/core/formatters_spec.rb +160 -0
- data/rspec-core/spec/rspec/core/hooks_filtering_spec.rb +227 -0
- data/rspec-core/spec/rspec/core/hooks_spec.rb +447 -0
- data/rspec-core/spec/rspec/core/memoized_helpers_spec.rb +537 -0
- data/rspec-core/spec/rspec/core/metadata_filter_spec.rb +181 -0
- data/rspec-core/spec/rspec/core/metadata_spec.rb +642 -0
- data/rspec-core/spec/rspec/core/notifications_spec.rb +92 -0
- data/rspec-core/spec/rspec/core/option_parser_spec.rb +270 -0
- data/rspec-core/spec/rspec/core/ordering_spec.rb +102 -0
- data/rspec-core/spec/rspec/core/pending_example_spec.rb +221 -0
- data/rspec-core/spec/rspec/core/pending_spec.rb +8 -0
- data/rspec-core/spec/rspec/core/project_initializer_spec.rb +123 -0
- data/rspec-core/spec/rspec/core/rake_task_spec.rb +351 -0
- data/rspec-core/spec/rspec/core/random_spec.rb +47 -0
- data/rspec-core/spec/rspec/core/reporter_spec.rb +198 -0
- data/rspec-core/spec/rspec/core/resources/a_bar.rb +0 -0
- data/rspec-core/spec/rspec/core/resources/a_foo.rb +0 -0
- data/rspec-core/spec/rspec/core/resources/a_spec.rb +1 -0
- data/rspec-core/spec/rspec/core/resources/acceptance/bar.rb +0 -0
- data/rspec-core/spec/rspec/core/resources/acceptance/foo_spec.rb +0 -0
- data/rspec-core/spec/rspec/core/resources/custom_example_group_runner.rb +14 -0
- data/rspec-core/spec/rspec/core/resources/formatter_specs.rb +58 -0
- data/rspec-core/spec/rspec/core/resources/utf8_encoded.rb +9 -0
- data/rspec-core/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/rspec-core/spec/rspec/core/ruby_project_spec.rb +26 -0
- data/rspec-core/spec/rspec/core/runner_spec.rb +309 -0
- data/rspec-core/spec/rspec/core/shared_context_spec.rb +102 -0
- data/rspec-core/spec/rspec/core/shared_example_group_spec.rb +268 -0
- data/rspec-core/spec/rspec/core/warnings_spec.rb +72 -0
- data/rspec-core/spec/rspec/core/world_spec.rb +142 -0
- data/rspec-core/spec/rspec/core_spec.rb +103 -0
- data/rspec-core/spec/spec_helper.rb +89 -0
- data/rspec-core/spec/support/config_options_helper.rb +13 -0
- data/rspec-core/spec/support/fake_minitest/minitest/minitest_assertions.rb +4 -0
- data/rspec-core/spec/support/fake_minitest/minitest.rb +0 -0
- data/rspec-core/spec/support/fake_minitest/test/unit/assertions.rb +6 -0
- data/rspec-core/spec/support/formatter_support.rb +263 -0
- data/rspec-core/spec/support/helper_methods.rb +26 -0
- data/rspec-core/spec/support/isolated_home_directory.rb +16 -0
- data/rspec-core/spec/support/matchers.rb +103 -0
- data/rspec-core/spec/support/mathn_integration_support.rb +12 -0
- data/rspec-core/spec/support/sandboxing.rb +50 -0
- data/rspec-core/spec/support/shared_example_groups.rb +43 -0
- data/rspec-core/spec/support/spec_files.rb +44 -0
- data/rspec-expectations/benchmarks/2.x_vs_3.x_matcher_dsl_implementation.rb +253 -0
- data/rspec-expectations/benchmarks/autoload_v_require.rb +25 -0
- data/rspec-expectations/benchmarks/cloning_matchers.rb +19 -0
- data/rspec-expectations/benchmarks/default_messages_as_methods_v_blocks.rb +27 -0
- data/rspec-expectations/benchmarks/example_spec.rb +9 -0
- data/rspec-expectations/benchmarks/include_v_superclass.rb +39 -0
- data/rspec-expectations/benchmarks/match_array/failing_with_distinct_items.rb +147 -0
- data/rspec-expectations/benchmarks/match_array/failing_with_duplicate_items.rb +122 -0
- data/rspec-expectations/benchmarks/match_array/passing_with_distinct_items.rb +154 -0
- data/rspec-expectations/benchmarks/match_array/passing_with_duplicate_items.rb +132 -0
- data/rspec-expectations/benchmarks/match_array/rubyprof/passing_with_distinct_items.rb +9 -0
- data/rspec-expectations/benchmarks/matcher_dsl_vs_classes.rb +180 -0
- data/rspec-expectations/benchmarks/method_to_proc.rb +72 -0
- data/rspec-expectations/benchmarks/set_vs_array_include.rb +68 -0
- data/rspec-expectations/features/step_definitions/additional_cli_steps.rb +22 -0
- data/rspec-expectations/features/support/disallow_certain_apis.rb +34 -0
- data/rspec-expectations/features/support/env.rb +21 -0
- data/rspec-expectations/features/support/rubinius.rb +6 -0
- data/{vendor_lib/rspec/matchers → rspec-expectations/lib/rspec/expectations}/configuration.rb +50 -16
- data/rspec-expectations/lib/rspec/expectations/expectation_target.rb +119 -0
- data/rspec-expectations/lib/rspec/expectations/fail_with.rb +34 -0
- data/rspec-expectations/lib/rspec/expectations/handler.rb +167 -0
- data/rspec-expectations/lib/rspec/expectations/minitest_integration.rb +17 -0
- data/rspec-expectations/lib/rspec/expectations/syntax.rb +132 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/expectations/version.rb +1 -1
- data/rspec-expectations/lib/rspec/expectations.rb +68 -0
- data/rspec-expectations/lib/rspec/matchers/aliased_matcher.rb +116 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/all.rb +85 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/base_matcher.rb +132 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/be.rb +277 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/be_between.rb +77 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/be_instance_of.rb +11 -4
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/be_kind_of.rb +5 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/be_within.rb +72 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/change.rb +337 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/compound.rb +258 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/contain_exactly.rb +249 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/cover.rb +3 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/eq.rb +75 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/eql.rb +17 -6
- data/rspec-expectations/lib/rspec/matchers/built_in/equal.rb +81 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/exist.rb +86 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/has.rb +101 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/have_attributes.rb +84 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/include.rb +105 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/match.rb +29 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/operators.rb +119 -0
- data/rspec-expectations/lib/rspec/matchers/built_in/output.rb +152 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/raise_error.rb +66 -46
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/respond_to.rb +43 -26
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/satisfy.rb +13 -4
- data/rspec-expectations/lib/rspec/matchers/built_in/start_and_end_with.rb +82 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/built_in/throw_symbol.rb +51 -13
- data/rspec-expectations/lib/rspec/matchers/built_in/yield.rb +420 -0
- data/rspec-expectations/lib/rspec/matchers/built_in.rb +52 -0
- data/rspec-expectations/lib/rspec/matchers/composable.rb +183 -0
- data/{vendor_lib/rspec/matchers/matcher.rb → rspec-expectations/lib/rspec/matchers/dsl.rb} +120 -30
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers/generated_descriptions.rb +13 -6
- data/rspec-expectations/lib/rspec/matchers/matcher_delegator.rb +33 -0
- data/rspec-expectations/lib/rspec/matchers/matcher_protocol.rb +99 -0
- data/rspec-expectations/lib/rspec/matchers/pretty.rb +77 -0
- data/{vendor_lib → rspec-expectations/lib}/rspec/matchers.rb +408 -74
- data/rspec-expectations/spec/rspec/expectations/configuration_spec.rb +226 -0
- data/rspec-expectations/spec/rspec/expectations/expectation_target_spec.rb +147 -0
- data/rspec-expectations/spec/rspec/expectations/extensions/kernel_spec.rb +69 -0
- data/rspec-expectations/spec/rspec/expectations/fail_with_spec.rb +73 -0
- data/rspec-expectations/spec/rspec/expectations/handler_spec.rb +200 -0
- data/rspec-expectations/spec/rspec/expectations/minitest_integration_spec.rb +25 -0
- data/rspec-expectations/spec/rspec/expectations/syntax_spec.rb +93 -0
- data/rspec-expectations/spec/rspec/expectations_spec.rb +15 -0
- data/rspec-expectations/spec/rspec/matchers/aliased_matcher_spec.rb +113 -0
- data/rspec-expectations/spec/rspec/matchers/aliases_spec.rb +455 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/all_spec.rb +212 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/base_matcher_spec.rb +140 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/be_between_spec.rb +157 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/be_instance_of_spec.rb +61 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/be_kind_of_spec.rb +39 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/be_spec.rb +685 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/be_within_spec.rb +139 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/change_spec.rb +829 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/compound_spec.rb +537 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/contain_exactly_spec.rb +556 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/cover_spec.rb +67 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/eq_spec.rb +176 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/eql_spec.rb +39 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/equal_spec.rb +130 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/exist_spec.rb +139 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/has_spec.rb +179 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/have_attributes_spec.rb +177 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/include_spec.rb +587 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/match_spec.rb +100 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/operators_spec.rb +250 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/output_spec.rb +168 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/raise_error_spec.rb +446 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/respond_to_spec.rb +290 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/satisfy_spec.rb +42 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/start_and_end_with_spec.rb +347 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/throw_symbol_spec.rb +133 -0
- data/rspec-expectations/spec/rspec/matchers/built_in/yield_spec.rb +643 -0
- data/rspec-expectations/spec/rspec/matchers/composable_spec.rb +77 -0
- data/rspec-expectations/spec/rspec/matchers/define_negated_matcher_spec.rb +199 -0
- data/rspec-expectations/spec/rspec/matchers/description_generation_spec.rb +189 -0
- data/rspec-expectations/spec/rspec/matchers/dsl_spec.rb +1036 -0
- data/rspec-expectations/spec/rspec/matchers/legacy_spec.rb +104 -0
- data/rspec-expectations/spec/rspec/matchers_spec.rb +108 -0
- data/rspec-expectations/spec/spec_helper.rb +94 -0
- data/rspec-expectations/spec/support/matchers.rb +54 -0
- data/rspec-expectations/spec/support/shared_examples.rb +101 -0
- data/rspec-mocks/benchmarks/double_creation.rb +66 -0
- data/rspec-mocks/benchmarks/each_value_v_values_each.rb +58 -0
- data/rspec-mocks/benchmarks/find_original_method_early.rb +64 -0
- data/rspec-mocks/benchmarks/method_defined_at_any_visibility.rb +101 -0
- data/rspec-mocks/benchmarks/thread_safety.rb +24 -0
- data/rspec-mocks/benchmarks/transfer_nested_constants.rb +77 -0
- data/rspec-mocks/features/step_definitions/additional_cli_steps.rb +21 -0
- data/rspec-mocks/features/support/disallow_certain_apis.rb +24 -0
- data/rspec-mocks/features/support/env.rb +22 -0
- data/rspec-mocks/features/support/rubinius.rb +6 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/chain.rb +19 -2
- data/rspec-mocks/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/expectation_chain.rb +12 -11
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/message_chains.rb +15 -5
- data/rspec-mocks/lib/rspec/mocks/any_instance/proxy.rb +116 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/recorder.rb +105 -38
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/stub_chain.rb +9 -9
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/any_instance/stub_chain_chain.rb +5 -1
- data/rspec-mocks/lib/rspec/mocks/any_instance.rb +10 -0
- data/rspec-mocks/lib/rspec/mocks/argument_list_matcher.rb +72 -0
- data/rspec-mocks/lib/rspec/mocks/argument_matchers.rb +282 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/configuration.rb +60 -14
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/error_generator.rb +93 -43
- data/rspec-mocks/lib/rspec/mocks/example_methods.rb +379 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/instance_method_stasher.rb +30 -7
- data/rspec-mocks/lib/rspec/mocks/marshal_extension.rb +41 -0
- data/rspec-mocks/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/have_received.rb +36 -14
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/receive.rb +24 -30
- data/rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb +66 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/matchers/receive_messages.rb +9 -10
- data/rspec-mocks/lib/rspec/mocks/message_chain.rb +91 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/message_expectation.rb +156 -105
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/method_double.rb +81 -30
- data/rspec-mocks/lib/rspec/mocks/method_reference.rb +155 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/mutate_const.rb +84 -166
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/object_reference.rb +19 -18
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/order_group.rb +4 -5
- data/rspec-mocks/lib/rspec/mocks/proxy.rb +431 -0
- data/rspec-mocks/lib/rspec/mocks/space.rb +221 -0
- data/rspec-mocks/lib/rspec/mocks/standalone.rb +3 -0
- data/rspec-mocks/lib/rspec/mocks/syntax.rb +329 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/targets.rb +20 -13
- data/rspec-mocks/lib/rspec/mocks/test_double.rb +135 -0
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_double.rb +69 -19
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_message_expecation.rb +23 -21
- data/{vendor_lib → rspec-mocks/lib}/rspec/mocks/verifying_proxy.rb +58 -38
- data/rspec-mocks/lib/rspec/mocks/version.rb +9 -0
- data/rspec-mocks/lib/rspec/mocks.rb +126 -0
- data/rspec-mocks/spec/rspec/mocks/and_call_original_spec.rb +267 -0
- data/rspec-mocks/spec/rspec/mocks/and_return_spec.rb +21 -0
- data/rspec-mocks/spec/rspec/mocks/and_wrap_original_spec.rb +63 -0
- data/rspec-mocks/spec/rspec/mocks/and_yield_spec.rb +161 -0
- data/rspec-mocks/spec/rspec/mocks/any_instance/message_chains_spec.rb +39 -0
- data/rspec-mocks/spec/rspec/mocks/any_instance_spec.rb +1242 -0
- data/rspec-mocks/spec/rspec/mocks/argument_matchers_spec.rb +336 -0
- data/rspec-mocks/spec/rspec/mocks/array_including_matcher_spec.rb +39 -0
- data/rspec-mocks/spec/rspec/mocks/at_least_spec.rb +147 -0
- data/rspec-mocks/spec/rspec/mocks/at_most_spec.rb +113 -0
- data/rspec-mocks/spec/rspec/mocks/before_all_spec.rb +75 -0
- data/rspec-mocks/spec/rspec/mocks/block_return_value_spec.rb +68 -0
- data/rspec-mocks/spec/rspec/mocks/combining_implementation_instructions_spec.rb +196 -0
- data/rspec-mocks/spec/rspec/mocks/configuration_spec.rb +175 -0
- data/rspec-mocks/spec/rspec/mocks/double_spec.rb +830 -0
- data/rspec-mocks/spec/rspec/mocks/example_methods_spec.rb +11 -0
- data/rspec-mocks/spec/rspec/mocks/expiration_spec.rb +90 -0
- data/rspec-mocks/spec/rspec/mocks/hash_excluding_matcher_spec.rb +65 -0
- data/rspec-mocks/spec/rspec/mocks/hash_including_matcher_spec.rb +92 -0
- data/rspec-mocks/spec/rspec/mocks/instance_method_stasher_spec.rb +72 -0
- data/rspec-mocks/spec/rspec/mocks/marshal_extension_spec.rb +67 -0
- data/rspec-mocks/spec/rspec/mocks/matchers/have_received_spec.rb +513 -0
- data/rspec-mocks/spec/rspec/mocks/matchers/receive_message_chain_spec.rb +227 -0
- data/rspec-mocks/spec/rspec/mocks/matchers/receive_messages_spec.rb +148 -0
- data/rspec-mocks/spec/rspec/mocks/matchers/receive_spec.rb +525 -0
- data/rspec-mocks/spec/rspec/mocks/methods_spec.rb +24 -0
- data/rspec-mocks/spec/rspec/mocks/mock_expectation_error_spec.rb +20 -0
- data/rspec-mocks/spec/rspec/mocks/mock_ordering_spec.rb +112 -0
- data/rspec-mocks/spec/rspec/mocks/multiple_return_value_spec.rb +130 -0
- data/rspec-mocks/spec/rspec/mocks/mutate_const_spec.rb +561 -0
- data/rspec-mocks/spec/rspec/mocks/nil_expectation_warning_spec.rb +52 -0
- data/rspec-mocks/spec/rspec/mocks/null_object_double_spec.rb +135 -0
- data/rspec-mocks/spec/rspec/mocks/once_counts_spec.rb +50 -0
- data/rspec-mocks/spec/rspec/mocks/order_group_spec.rb +26 -0
- data/rspec-mocks/spec/rspec/mocks/partial_double_spec.rb +379 -0
- data/rspec-mocks/spec/rspec/mocks/partial_double_using_mocks_directly_spec.rb +83 -0
- data/rspec-mocks/spec/rspec/mocks/precise_counts_spec.rb +66 -0
- data/rspec-mocks/spec/rspec/mocks/serialization_spec.rb +89 -0
- data/rspec-mocks/spec/rspec/mocks/should_syntax_spec.rb +539 -0
- data/rspec-mocks/spec/rspec/mocks/space_spec.rb +242 -0
- data/rspec-mocks/spec/rspec/mocks/spy_spec.rb +127 -0
- data/rspec-mocks/spec/rspec/mocks/stash_spec.rb +43 -0
- data/rspec-mocks/spec/rspec/mocks/stub_chain_spec.rb +166 -0
- data/rspec-mocks/spec/rspec/mocks/stub_implementation_spec.rb +98 -0
- data/rspec-mocks/spec/rspec/mocks/stub_spec.rb +520 -0
- data/rspec-mocks/spec/rspec/mocks/stubbed_message_expectations_spec.rb +56 -0
- data/rspec-mocks/spec/rspec/mocks/syntax_agnostic_message_matchers_spec.rb +99 -0
- data/rspec-mocks/spec/rspec/mocks/syntax_spec.rb +7 -0
- data/rspec-mocks/spec/rspec/mocks/test_double_spec.rb +53 -0
- data/rspec-mocks/spec/rspec/mocks/thrice_counts_spec.rb +72 -0
- data/rspec-mocks/spec/rspec/mocks/to_ary_spec.rb +52 -0
- data/rspec-mocks/spec/rspec/mocks/twice_counts_spec.rb +64 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/class_double_with_class_loaded_spec.rb +118 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb +58 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/construction_spec.rb +54 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/expected_arg_verification_spec.rb +81 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/instance_double_with_class_loaded_spec.rb +195 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/instance_double_with_class_not_loaded_spec.rb +57 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/method_visibility_spec.rb +129 -0
- data/rspec-mocks/spec/rspec/mocks/verifying_doubles/object_double_spec.rb +68 -0
- data/rspec-mocks/spec/rspec/mocks_spec.rb +199 -0
- data/rspec-mocks/spec/spec_helper.rb +131 -0
- data/rspec-mocks/spec/support/before_all_shared_example_group.rb +16 -0
- data/rspec-mocks/spec/support/doubled_classes.rb +74 -0
- data/rspec-mocks/spec/support/matchers.rb +15 -0
- data/rspec-support/benchmarks/caller.rb +81 -0
- data/{vendor_lib → rspec-support/lib}/rspec/support/caller_filter.rb +11 -4
- data/rspec-support/lib/rspec/support/differ.rb +214 -0
- data/rspec-support/lib/rspec/support/directory_maker.rb +61 -0
- data/rspec-support/lib/rspec/support/encoded_string.rb +69 -0
- data/rspec-support/lib/rspec/support/fuzzy_matcher.rb +48 -0
- data/rspec-support/lib/rspec/support/hunk_generator.rb +47 -0
- data/rspec-support/lib/rspec/support/matcher_definition.rb +31 -0
- data/rspec-support/lib/rspec/support/method_signature_verifier.rb +272 -0
- data/rspec-support/lib/rspec/support/os.rb +18 -0
- data/rspec-support/lib/rspec/support/recursive_const_methods.rb +76 -0
- data/rspec-support/lib/rspec/support/ruby_features.rb +45 -0
- data/rspec-support/lib/rspec/support/spec/deprecation_helpers.rb +60 -0
- data/rspec-support/lib/rspec/support/spec/formatting_support.rb +9 -0
- data/{vendor_lib → rspec-support/lib}/rspec/support/spec/in_sub_process.rb +5 -2
- data/rspec-support/lib/rspec/support/spec/prevent_load_time_warnings.rb +44 -0
- data/rspec-support/lib/rspec/support/spec/shell_out.rb +69 -0
- data/{vendor_lib → rspec-support/lib}/rspec/support/spec/stderr_splitter.rb +7 -5
- data/rspec-support/lib/rspec/support/spec/with_isolated_directory.rb +9 -0
- data/rspec-support/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
- data/rspec-support/lib/rspec/support/spec.rb +72 -0
- data/{vendor_lib → rspec-support/lib}/rspec/support/version.rb +1 -1
- data/rspec-support/lib/rspec/support/version_checker.rb +53 -0
- data/rspec-support/lib/rspec/support/warnings.rb +39 -0
- data/rspec-support/lib/rspec/support.rb +76 -0
- data/rspec-support/spec/rspec/support/caller_filter_spec.rb +66 -0
- data/rspec-support/spec/rspec/support/differ_spec.rb +322 -0
- data/rspec-support/spec/rspec/support/directory_maker_spec.rb +58 -0
- data/rspec-support/spec/rspec/support/encoded_string_spec.rb +86 -0
- data/rspec-support/spec/rspec/support/fuzzy_matcher_spec.rb +179 -0
- data/rspec-support/spec/rspec/support/method_signature_verifier_spec.rb +357 -0
- data/rspec-support/spec/rspec/support/os_spec.rb +36 -0
- data/rspec-support/spec/rspec/support/recursive_const_methods_spec.rb +49 -0
- data/rspec-support/spec/rspec/support/spec/in_sub_process_spec.rb +36 -0
- data/rspec-support/spec/rspec/support/spec/prevent_load_time_warnings_spec.rb +10 -0
- data/rspec-support/spec/rspec/support/spec/shell_out_spec.rb +44 -0
- data/rspec-support/spec/rspec/support/spec/stderr_splitter_spec.rb +60 -0
- data/rspec-support/spec/rspec/support/spec/with_isolated_std_err_spec.rb +21 -0
- data/rspec-support/spec/rspec/support/version_checker_spec.rb +29 -0
- data/rspec-support/spec/rspec/support/warnings_spec.rb +66 -0
- data/rspec-support/spec/rspec/support_spec.rb +119 -0
- data/rspec-support/spec/spec_helper.rb +2 -0
- data/spec/after_hooks_spec.rb +140 -0
- data/spec/around_hooks_spec.rb +223 -0
- data/spec/async_spec.rb +147 -1
- data/spec/before_hooks_spec.rb +183 -0
- data/spec/example_spec.rb +11 -0
- data/spec/matchers_spec.rb +4 -0
- data/spec/skip_pending_spec.rb +43 -0
- data/spec/subject_spec.rb +87 -0
- data/util/create_requires.rb +45 -0
- metadata +443 -147
- data/spec/named_subject_spec.rb +0 -11
- data/vendor_lib/rspec/core/backtrace_formatter.rb +0 -65
- data/vendor_lib/rspec/core/command_line.rb +0 -36
- data/vendor_lib/rspec/core/configuration_options.rb +0 -143
- data/vendor_lib/rspec/core/drb_command_line.rb +0 -26
- data/vendor_lib/rspec/core/drb_options.rb +0 -87
- data/vendor_lib/rspec/core/dsl.rb +0 -26
- data/vendor_lib/rspec/core/example.rb +0 -312
- data/vendor_lib/rspec/core/example_group.rb +0 -540
- data/vendor_lib/rspec/core/filter_manager.rb +0 -224
- data/vendor_lib/rspec/core/formatters/base_formatter.rb +0 -291
- data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +0 -307
- data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +0 -67
- data/vendor_lib/rspec/core/formatters/json_formatter.rb +0 -99
- data/vendor_lib/rspec/core/formatters/progress_formatter.rb +0 -32
- data/vendor_lib/rspec/core/formatters.rb +0 -54
- data/vendor_lib/rspec/core/hooks.rb +0 -535
- data/vendor_lib/rspec/core/metadata.rb +0 -313
- data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/vendor_lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/vendor_lib/rspec/core/mocking/with_rr.rb +0 -27
- data/vendor_lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/vendor_lib/rspec/core/pending.rb +0 -110
- data/vendor_lib/rspec/core/project_initializer.rb +0 -88
- data/vendor_lib/rspec/core/rake_task.rb +0 -128
- data/vendor_lib/rspec/core/reporter.rb +0 -132
- data/vendor_lib/rspec/core/runner.rb +0 -97
- data/vendor_lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/vendor_lib/rspec/core/shared_example_group.rb +0 -146
- data/vendor_lib/rspec/core/version.rb +0 -7
- data/vendor_lib/rspec/core/warnings.rb +0 -22
- data/vendor_lib/rspec/expectations/differ.rb +0 -154
- data/vendor_lib/rspec/expectations/errors.rb +0 -9
- data/vendor_lib/rspec/expectations/expectation_target.rb +0 -87
- data/vendor_lib/rspec/expectations/extensions/object.rb +0 -29
- data/vendor_lib/rspec/expectations/extensions.rb +0 -1
- data/vendor_lib/rspec/expectations/fail_with.rb +0 -79
- data/vendor_lib/rspec/expectations/handler.rb +0 -68
- data/vendor_lib/rspec/expectations/syntax.rb +0 -182
- data/vendor_lib/rspec/expectations.rb +0 -75
- data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +0 -68
- data/vendor_lib/rspec/matchers/built_in/be.rb +0 -213
- data/vendor_lib/rspec/matchers/built_in/be_within.rb +0 -55
- data/vendor_lib/rspec/matchers/built_in/change.rb +0 -141
- data/vendor_lib/rspec/matchers/built_in/eq.rb +0 -22
- data/vendor_lib/rspec/matchers/built_in/equal.rb +0 -48
- data/vendor_lib/rspec/matchers/built_in/exist.rb +0 -26
- data/vendor_lib/rspec/matchers/built_in/has.rb +0 -48
- data/vendor_lib/rspec/matchers/built_in/include.rb +0 -61
- data/vendor_lib/rspec/matchers/built_in/match.rb +0 -17
- data/vendor_lib/rspec/matchers/built_in/match_array.rb +0 -51
- data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +0 -48
- data/vendor_lib/rspec/matchers/built_in/yield.rb +0 -297
- data/vendor_lib/rspec/matchers/built_in.rb +0 -39
- data/vendor_lib/rspec/matchers/compatibility.rb +0 -14
- data/vendor_lib/rspec/matchers/dsl.rb +0 -23
- data/vendor_lib/rspec/matchers/method_missing.rb +0 -12
- data/vendor_lib/rspec/matchers/operator_matcher.rb +0 -99
- data/vendor_lib/rspec/matchers/pretty.rb +0 -70
- data/vendor_lib/rspec/matchers/test_unit_integration.rb +0 -11
- data/vendor_lib/rspec/mocks/argument_list_matcher.rb +0 -104
- data/vendor_lib/rspec/mocks/argument_matchers.rb +0 -264
- data/vendor_lib/rspec/mocks/arity_calculator.rb +0 -66
- data/vendor_lib/rspec/mocks/errors.rb +0 -12
- data/vendor_lib/rspec/mocks/example_methods.rb +0 -201
- data/vendor_lib/rspec/mocks/extensions/marshal.rb +0 -17
- data/vendor_lib/rspec/mocks/framework.rb +0 -36
- data/vendor_lib/rspec/mocks/method_reference.rb +0 -95
- data/vendor_lib/rspec/mocks/mock.rb +0 -7
- data/vendor_lib/rspec/mocks/proxy.rb +0 -269
- data/vendor_lib/rspec/mocks/proxy_for_nil.rb +0 -37
- data/vendor_lib/rspec/mocks/space.rb +0 -95
- data/vendor_lib/rspec/mocks/standalone.rb +0 -3
- data/vendor_lib/rspec/mocks/stub_chain.rb +0 -51
- data/vendor_lib/rspec/mocks/syntax.rb +0 -374
- data/vendor_lib/rspec/mocks/test_double.rb +0 -109
- data/vendor_lib/rspec/mocks/version.rb +0 -7
- data/vendor_lib/rspec/mocks.rb +0 -100
- data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +0 -29
- data/vendor_lib/rspec/support/spec.rb +0 -14
- data/vendor_lib/rspec/support/warnings.rb +0 -41
- data/vendor_lib/rspec/support.rb +0 -6
- data/vendor_lib/rspec-expectations.rb +0 -1
@@ -0,0 +1,1963 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'rspec/support/spec/in_sub_process'
|
4
|
+
|
5
|
+
module RSpec::Core
|
6
|
+
|
7
|
+
RSpec.describe Configuration do
|
8
|
+
include RSpec::Support::InSubProcess
|
9
|
+
|
10
|
+
let(:config) { Configuration.new }
|
11
|
+
let(:exclusion_filter) { config.exclusion_filter.rules }
|
12
|
+
let(:inclusion_filter) { config.inclusion_filter.rules }
|
13
|
+
|
14
|
+
shared_examples_for "warning of deprecated `:example_group` during filtering configuration" do |method, *args|
|
15
|
+
it "issues a deprecation warning when filtering by `:example_group`" do
|
16
|
+
args << { :example_group => { :file_location => /spec\/unit/ } }
|
17
|
+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /:example_group/)
|
18
|
+
config.__send__(method, *args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#deprecation_stream' do
|
23
|
+
it 'defaults to standard error' do
|
24
|
+
expect($rspec_core_without_stderr_monkey_patch.deprecation_stream).to eq STDERR
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'is configurable' do
|
28
|
+
io = double 'deprecation io'
|
29
|
+
config.deprecation_stream = io
|
30
|
+
expect(config.deprecation_stream).to eq io
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the reporter has already been initialized' do
|
34
|
+
before do
|
35
|
+
config.reporter
|
36
|
+
allow(config).to receive(:warn)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'prints a notice indicating the reconfigured output_stream will be ignored' do
|
40
|
+
config.deprecation_stream = double("IO")
|
41
|
+
expect(config).to have_received(:warn).with(/deprecation_stream.*#{__FILE__}:#{__LINE__ - 1}/)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'does not change the value of `deprecation_stream`' do
|
45
|
+
value = config.deprecation_stream
|
46
|
+
config.deprecation_stream = double("IO")
|
47
|
+
expect(config.deprecation_stream).to equal(value)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'does not print a warning if set to the value it already has' do
|
51
|
+
config.deprecation_stream = config.deprecation_stream
|
52
|
+
expect(config).not_to have_received(:warn)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#output_stream" do
|
58
|
+
it 'defaults to standard output' do
|
59
|
+
expect(config.output_stream).to eq $stdout
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'is configurable' do
|
63
|
+
io = double 'output io'
|
64
|
+
config.output_stream = io
|
65
|
+
expect(config.output_stream).to eq io
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when the reporter has already been initialized' do
|
69
|
+
before do
|
70
|
+
config.reporter
|
71
|
+
allow(config).to receive(:warn)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'prints a notice indicating the reconfigured output_stream will be ignored' do
|
75
|
+
config.output_stream = StringIO.new
|
76
|
+
expect(config).to have_received(:warn).with(/output_stream.*#{__FILE__}:#{__LINE__ - 1}/)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'does not change the value of `output_stream`' do
|
80
|
+
config.output_stream = StringIO.new
|
81
|
+
expect(config.output_stream).to eq($stdout)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'does not print a warning if set to the value it already has' do
|
85
|
+
config.output_stream = config.output_stream
|
86
|
+
expect(config).not_to have_received(:warn)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#requires=" do
|
92
|
+
def absolute_path_to(dir)
|
93
|
+
File.expand_path("../../../../#{dir}", __FILE__)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'adds `lib` to the load path' do
|
97
|
+
lib_dir = absolute_path_to("lib")
|
98
|
+
$LOAD_PATH.delete(lib_dir)
|
99
|
+
|
100
|
+
expect($LOAD_PATH).not_to include(lib_dir)
|
101
|
+
config.requires = []
|
102
|
+
expect($LOAD_PATH).to include(lib_dir)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'adds the configured `default_path` to the load path' do
|
106
|
+
config.default_path = 'features'
|
107
|
+
foo_dir = absolute_path_to("features")
|
108
|
+
|
109
|
+
expect($LOAD_PATH).not_to include(foo_dir)
|
110
|
+
config.requires = []
|
111
|
+
expect($LOAD_PATH).to include(foo_dir)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'stores the required files' do
|
115
|
+
expect(config).to receive(:require).with('a/path')
|
116
|
+
config.requires = ['a/path']
|
117
|
+
expect(config.requires).to eq ['a/path']
|
118
|
+
end
|
119
|
+
|
120
|
+
context "when `default_path` refers to a file rather than a directory" do
|
121
|
+
it 'does not add it to the load path' do
|
122
|
+
config.default_path = 'Rakefile'
|
123
|
+
config.requires = []
|
124
|
+
expect($LOAD_PATH).not_to include(match(/Rakefile/))
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#load_spec_files" do
|
130
|
+
it "loads files using load" do
|
131
|
+
config.files_to_run = ["foo.bar", "blah_spec.rb"]
|
132
|
+
expect(config).to receive(:load).twice
|
133
|
+
config.load_spec_files
|
134
|
+
end
|
135
|
+
|
136
|
+
it "loads each file once, even if duplicated in list" do
|
137
|
+
config.files_to_run = ["a_spec.rb", "a_spec.rb"]
|
138
|
+
expect(config).to receive(:load).once
|
139
|
+
config.load_spec_files
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "#mock_framework" do
|
144
|
+
it "defaults to :rspec" do
|
145
|
+
expect(RSpec::Support).to receive(:require_rspec_core).with('mocking_adapters/rspec')
|
146
|
+
expect(config.mock_framework).to eq(MockingAdapters::RSpec)
|
147
|
+
end
|
148
|
+
|
149
|
+
context "when rspec-mocks is not installed" do
|
150
|
+
it 'gracefully falls back to :nothing' do
|
151
|
+
allow(RSpec::Support).to receive(:require_rspec_core).and_call_original
|
152
|
+
allow(RSpec::Support).to receive(:require_rspec_core).with('mocking_adapters/rspec').and_raise(LoadError)
|
153
|
+
|
154
|
+
expect(config.mock_framework).to eq(MockingAdapters::Null)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#mock_framework="do
|
160
|
+
it "delegates to mock_with" do
|
161
|
+
expect(config).to receive(:mock_with).with(:rspec)
|
162
|
+
config.mock_framework = :rspec
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
shared_examples "a configurable framework adapter" do |m|
|
167
|
+
it "yields a config object if the framework_module supports it" do
|
168
|
+
custom_config = Struct.new(:custom_setting).new
|
169
|
+
mod = Module.new
|
170
|
+
allow(mod).to receive_messages(:configuration => custom_config)
|
171
|
+
|
172
|
+
config.send m, mod do |mod_config|
|
173
|
+
mod_config.custom_setting = true
|
174
|
+
end
|
175
|
+
|
176
|
+
expect(custom_config.custom_setting).to be_truthy
|
177
|
+
end
|
178
|
+
|
179
|
+
it "raises if framework module doesn't support configuration" do
|
180
|
+
mod = Module.new
|
181
|
+
|
182
|
+
expect {
|
183
|
+
config.send m, mod do |mod_config|
|
184
|
+
end
|
185
|
+
}.to raise_error(/must respond to `configuration`/)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#mock_with" do
|
190
|
+
before { allow(config).to receive(:require) }
|
191
|
+
|
192
|
+
it_behaves_like "a configurable framework adapter", :mock_with
|
193
|
+
|
194
|
+
it "allows rspec-mocks to be configured with a provided block" do
|
195
|
+
mod = Module.new
|
196
|
+
|
197
|
+
expect(RSpec::Mocks.configuration).to receive(:add_stub_and_should_receive_to).with(mod)
|
198
|
+
|
199
|
+
config.mock_with :rspec do |c|
|
200
|
+
c.add_stub_and_should_receive_to mod
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context "with a module" do
|
205
|
+
it "sets the mock_framework_adapter to that module" do
|
206
|
+
mod = Module.new
|
207
|
+
config.mock_with mod
|
208
|
+
expect(config.mock_framework).to eq(mod)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'uses the named adapter' do
|
213
|
+
expect(RSpec::Support).to receive(:require_rspec_core).with('mocking_adapters/mocha')
|
214
|
+
stub_const("RSpec::Core::MockingAdapters::Mocha", Module.new)
|
215
|
+
config.mock_with :mocha
|
216
|
+
end
|
217
|
+
|
218
|
+
it "uses the null adapter when given :nothing" do
|
219
|
+
expect(RSpec::Support).to receive(:require_rspec_core).with('mocking_adapters/null').and_call_original
|
220
|
+
config.mock_with :nothing
|
221
|
+
end
|
222
|
+
|
223
|
+
it "raises an error when given an unknown key" do
|
224
|
+
expect {
|
225
|
+
config.mock_with :crazy_new_mocking_framework_ive_not_yet_heard_of
|
226
|
+
}.to raise_error(ArgumentError, /unknown mocking framework/i)
|
227
|
+
end
|
228
|
+
|
229
|
+
it "raises an error when given another type of object" do
|
230
|
+
expect {
|
231
|
+
config.mock_with Object.new
|
232
|
+
}.to raise_error(ArgumentError, /unknown mocking framework/i)
|
233
|
+
end
|
234
|
+
|
235
|
+
context 'when there are already some example groups defined' do
|
236
|
+
before { allow(RSpec::Support).to receive(:require_rspec_core) }
|
237
|
+
|
238
|
+
it 'raises an error since this setting must be applied before any groups are defined' do
|
239
|
+
allow(RSpec.world).to receive(:example_groups).and_return([double.as_null_object])
|
240
|
+
mocha = stub_const("RSpec::Core::MockingAdapters::Mocha", Module.new)
|
241
|
+
allow(mocha).to receive_messages(:framework_name => :mocha)
|
242
|
+
|
243
|
+
expect {
|
244
|
+
config.mock_with :mocha
|
245
|
+
}.to raise_error(/must be configured before any example groups are defined/)
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'does not raise an error if the default `mock_with :rspec` is re-configured' do
|
249
|
+
config.mock_framework # called by RSpec when configuring the first example group
|
250
|
+
allow(RSpec.world).to receive(:example_groups).and_return([double.as_null_object])
|
251
|
+
config.mock_with :rspec
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'does not raise an error if re-setting the same config' do
|
255
|
+
mocha = stub_const("RSpec::Core::MockingAdapters::Mocha", Module.new)
|
256
|
+
allow(mocha).to receive_messages(:framework_name => :mocha)
|
257
|
+
|
258
|
+
groups = []
|
259
|
+
allow(RSpec.world).to receive_messages(:example_groups => groups)
|
260
|
+
config.mock_with :mocha
|
261
|
+
groups << double.as_null_object
|
262
|
+
config.mock_with :mocha
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "#expectation_frameworks" do
|
268
|
+
it "defaults to :rspec" do
|
269
|
+
expect(config).to receive(:require).with('rspec/expectations')
|
270
|
+
expect(config.expectation_frameworks).to eq([RSpec::Matchers])
|
271
|
+
end
|
272
|
+
|
273
|
+
context "when rspec-expectations is not installed" do
|
274
|
+
def an_anonymous_module
|
275
|
+
name = RUBY_VERSION.to_f < 1.9 ? '' : nil
|
276
|
+
an_object_having_attributes(:class => Module, :name => name)
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'gracefully falls back to an anonymous module' do
|
280
|
+
allow(config).to receive(:require).with('rspec/expectations').and_raise(LoadError)
|
281
|
+
expect(config.expectation_frameworks).to match([an_anonymous_module])
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe "#expectation_framework=" do
|
287
|
+
it "delegates to expect_with" do
|
288
|
+
expect(config).to receive(:expect_with).with(:rspec)
|
289
|
+
config.expectation_framework = :rspec
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def stub_expectation_adapters
|
294
|
+
stub_const("Test::Unit::Assertions", Module.new)
|
295
|
+
stub_const("Minitest::Assertions", Module.new)
|
296
|
+
stub_const("RSpec::Core::TestUnitAssertionsAdapter", Module.new)
|
297
|
+
stub_const("RSpec::Core::MinitestAssertionsAdapter", Module.new)
|
298
|
+
allow(config).to receive(:require)
|
299
|
+
end
|
300
|
+
|
301
|
+
describe "#expect_with" do
|
302
|
+
before do
|
303
|
+
stub_expectation_adapters
|
304
|
+
end
|
305
|
+
|
306
|
+
it_behaves_like "a configurable framework adapter", :expect_with
|
307
|
+
|
308
|
+
context "with :rspec" do
|
309
|
+
it "requires rspec/expectations" do
|
310
|
+
expect(config).to receive(:require).with('rspec/expectations')
|
311
|
+
config.expect_with :rspec
|
312
|
+
end
|
313
|
+
|
314
|
+
it "sets the expectation framework to ::RSpec::Matchers" do
|
315
|
+
config.expect_with :rspec
|
316
|
+
expect(config.expectation_frameworks).to eq [::RSpec::Matchers]
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
context "with :test_unit" do
|
321
|
+
it "requires rspec/core/test_unit_assertions_adapter" do
|
322
|
+
expect(config).to receive(:require).
|
323
|
+
with('rspec/core/test_unit_assertions_adapter')
|
324
|
+
config.expect_with :test_unit
|
325
|
+
end
|
326
|
+
|
327
|
+
it "sets the expectation framework to ::Test::Unit::Assertions" do
|
328
|
+
config.expect_with :test_unit
|
329
|
+
expect(config.expectation_frameworks).to eq [
|
330
|
+
::RSpec::Core::TestUnitAssertionsAdapter
|
331
|
+
]
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context "with :minitest" do
|
336
|
+
it "requires rspec/core/minitest_assertions_adapter" do
|
337
|
+
expect(config).to receive(:require).
|
338
|
+
with('rspec/core/minitest_assertions_adapter')
|
339
|
+
config.expect_with :minitest
|
340
|
+
end
|
341
|
+
|
342
|
+
it "sets the expectation framework to ::Minitest::Assertions" do
|
343
|
+
config.expect_with :minitest
|
344
|
+
expect(config.expectation_frameworks).to eq [
|
345
|
+
::RSpec::Core::MinitestAssertionsAdapter
|
346
|
+
]
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
it "supports multiple calls" do
|
351
|
+
config.expect_with :rspec
|
352
|
+
config.expect_with :minitest
|
353
|
+
expect(config.expectation_frameworks).to eq [
|
354
|
+
RSpec::Matchers,
|
355
|
+
RSpec::Core::MinitestAssertionsAdapter
|
356
|
+
]
|
357
|
+
end
|
358
|
+
|
359
|
+
it "raises if block given with multiple args" do
|
360
|
+
expect {
|
361
|
+
config.expect_with :rspec, :minitest do |mod_config|
|
362
|
+
end
|
363
|
+
}.to raise_error(/expect_with only accepts/)
|
364
|
+
end
|
365
|
+
|
366
|
+
it "raises ArgumentError if framework is not supported" do
|
367
|
+
expect do
|
368
|
+
config.expect_with :not_supported
|
369
|
+
end.to raise_error(ArgumentError)
|
370
|
+
end
|
371
|
+
|
372
|
+
context 'when there are already some example groups defined' do
|
373
|
+
it 'raises an error since this setting must be applied before any groups are defined' do
|
374
|
+
allow(RSpec.world).to receive(:example_groups).and_return([double.as_null_object])
|
375
|
+
expect {
|
376
|
+
config.expect_with :rspec
|
377
|
+
}.to raise_error(/must be configured before any example groups are defined/)
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'does not raise an error if the default `expect_with :rspec` is re-configured' do
|
381
|
+
config.expectation_frameworks # called by RSpec when configuring the first example group
|
382
|
+
allow(RSpec.world).to receive(:example_groups).and_return([double.as_null_object])
|
383
|
+
config.expect_with :rspec
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'does not raise an error if re-setting the same config' do
|
387
|
+
groups = []
|
388
|
+
allow(RSpec.world).to receive_messages(:example_groups => groups)
|
389
|
+
config.expect_with :minitest
|
390
|
+
groups << double.as_null_object
|
391
|
+
config.expect_with :minitest
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
describe "#expecting_with_rspec?" do
|
397
|
+
before do
|
398
|
+
stub_expectation_adapters
|
399
|
+
end
|
400
|
+
|
401
|
+
it "returns false by default" do
|
402
|
+
expect(config).not_to be_expecting_with_rspec
|
403
|
+
end
|
404
|
+
|
405
|
+
it "returns true when `expect_with :rspec` has been configured" do
|
406
|
+
config.expect_with :rspec
|
407
|
+
expect(config).to be_expecting_with_rspec
|
408
|
+
end
|
409
|
+
|
410
|
+
it "returns true when `expect_with :rspec, :minitest` has been configured" do
|
411
|
+
config.expect_with :rspec, :minitest
|
412
|
+
expect(config).to be_expecting_with_rspec
|
413
|
+
end
|
414
|
+
|
415
|
+
it "returns true when `expect_with :minitest, :rspec` has been configured" do
|
416
|
+
config.expect_with :minitest, :rspec
|
417
|
+
expect(config).to be_expecting_with_rspec
|
418
|
+
end
|
419
|
+
|
420
|
+
it "returns false when `expect_with :minitest` has been configured" do
|
421
|
+
config.expect_with :minitest
|
422
|
+
expect(config).not_to be_expecting_with_rspec
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
describe "#files_to_run" do
|
427
|
+
it "loads files not following pattern if named explicitly" do
|
428
|
+
assign_files_or_directories_to_run "spec/rspec/core/resources/a_bar.rb"
|
429
|
+
expect(config.files_to_run).to contain_files("spec/rspec/core/resources/a_bar.rb")
|
430
|
+
end
|
431
|
+
|
432
|
+
it "prevents repetition of dir when start of the pattern" do
|
433
|
+
config.pattern = "spec/**/a_spec.rb"
|
434
|
+
assign_files_or_directories_to_run "spec"
|
435
|
+
expect(config.files_to_run).to contain_files("spec/rspec/core/resources/a_spec.rb")
|
436
|
+
end
|
437
|
+
|
438
|
+
it "does not prevent repetition of dir when later of the pattern" do
|
439
|
+
config.pattern = "rspec/**/a_spec.rb"
|
440
|
+
assign_files_or_directories_to_run "spec"
|
441
|
+
expect(config.files_to_run).to contain_files("spec/rspec/core/resources/a_spec.rb")
|
442
|
+
end
|
443
|
+
|
444
|
+
it "supports patterns starting with ./" do
|
445
|
+
config.pattern = "./spec/**/a_spec.rb"
|
446
|
+
assign_files_or_directories_to_run "spec"
|
447
|
+
expect(config.files_to_run).to contain_files("./spec/rspec/core/resources/a_spec.rb")
|
448
|
+
end
|
449
|
+
|
450
|
+
it "supports absolute path patterns" do
|
451
|
+
dir = File.expand_path("../resources", __FILE__)
|
452
|
+
config.pattern = File.join(dir, "**/*_spec.rb")
|
453
|
+
assign_files_or_directories_to_run "spec"
|
454
|
+
|
455
|
+
expect(config.files_to_run).to contain_files(
|
456
|
+
"./spec/rspec/core/resources/acceptance/foo_spec.rb",
|
457
|
+
"./spec/rspec/core/resources/a_spec.rb"
|
458
|
+
)
|
459
|
+
end
|
460
|
+
|
461
|
+
it "supports relative path patterns for an alternate directory from `spec`" do
|
462
|
+
Dir.chdir("./spec/rspec/core") do
|
463
|
+
config.pattern = "resources/**/*_spec.rb"
|
464
|
+
assign_files_or_directories_to_run "spec" # default dir
|
465
|
+
|
466
|
+
expect(config.files_to_run).to contain_files(
|
467
|
+
"resources/acceptance/foo_spec.rb",
|
468
|
+
"resources/a_spec.rb"
|
469
|
+
)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
it "does not attempt to treat the pattern relative to `.` if it uses `**` in the first path segment as that would cause it load specs from vendored gems" do
|
474
|
+
Dir.chdir("./spec/rspec/core") do
|
475
|
+
config.pattern = "**/*_spec.rb"
|
476
|
+
assign_files_or_directories_to_run "spec" # default dir
|
477
|
+
|
478
|
+
expect(config.files_to_run).to contain_files()
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
it 'reloads when `files_or_directories_to_run` is reassigned' do
|
483
|
+
config.pattern = "spec/**/a_spec.rb"
|
484
|
+
config.files_or_directories_to_run = "empty_dir"
|
485
|
+
|
486
|
+
expect {
|
487
|
+
config.files_or_directories_to_run = "spec"
|
488
|
+
}.to change { config.files_to_run }.
|
489
|
+
to(a_file_collection("spec/rspec/core/resources/a_spec.rb"))
|
490
|
+
end
|
491
|
+
|
492
|
+
it 'attempts to load the provided file names' do
|
493
|
+
assign_files_or_directories_to_run "path/to/some/file.rb"
|
494
|
+
expect(config.files_to_run).to eq(["path/to/some/file.rb"])
|
495
|
+
end
|
496
|
+
|
497
|
+
it 'does not attempt to load a file at the `default_path`' do
|
498
|
+
config.default_path = "path/to/dir"
|
499
|
+
assign_files_or_directories_to_run "path/to/dir"
|
500
|
+
expect(config.files_to_run).to eq([])
|
501
|
+
end
|
502
|
+
|
503
|
+
context "with <path>:<line_number>" do
|
504
|
+
it "overrides inclusion filters set on config" do
|
505
|
+
config.filter_run_including :foo => :bar
|
506
|
+
assign_files_or_directories_to_run "path/to/file.rb:37"
|
507
|
+
expect(inclusion_filter.size).to eq(1)
|
508
|
+
expect(inclusion_filter[:locations].keys.first).to match(/path\/to\/file\.rb$/)
|
509
|
+
expect(inclusion_filter[:locations].values.first).to eq([37])
|
510
|
+
end
|
511
|
+
|
512
|
+
it "overrides inclusion filters set before config" do
|
513
|
+
config.force(:inclusion_filter => {:foo => :bar})
|
514
|
+
assign_files_or_directories_to_run "path/to/file.rb:37"
|
515
|
+
expect(inclusion_filter.size).to eq(1)
|
516
|
+
expect(inclusion_filter[:locations].keys.first).to match(/path\/to\/file\.rb$/)
|
517
|
+
expect(inclusion_filter[:locations].values.first).to eq([37])
|
518
|
+
end
|
519
|
+
|
520
|
+
it "clears exclusion filters set on config" do
|
521
|
+
config.exclusion_filter = { :foo => :bar }
|
522
|
+
assign_files_or_directories_to_run "path/to/file.rb:37"
|
523
|
+
expect(exclusion_filter).to be_empty,
|
524
|
+
"expected exclusion filter to be empty:\n#{exclusion_filter}"
|
525
|
+
end
|
526
|
+
|
527
|
+
it "clears exclusion filters set before config" do
|
528
|
+
config.force(:exclusion_filter => { :foo => :bar })
|
529
|
+
assign_files_or_directories_to_run "path/to/file.rb:37"
|
530
|
+
expect(config.exclusion_filter).to be_empty,
|
531
|
+
"expected exclusion filter to be empty:\n#{config.exclusion_filter}"
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
context "with default pattern" do
|
536
|
+
it "loads files named _spec.rb" do
|
537
|
+
assign_files_or_directories_to_run "spec/rspec/core/resources"
|
538
|
+
expect(config.files_to_run).to contain_files("spec/rspec/core/resources/a_spec.rb", "spec/rspec/core/resources/acceptance/foo_spec.rb")
|
539
|
+
end
|
540
|
+
|
541
|
+
it "loads files in Windows", :if => RSpec.world.windows_os? do
|
542
|
+
assign_files_or_directories_to_run "C:\\path\\to\\project\\spec\\sub\\foo_spec.rb"
|
543
|
+
expect(config.files_to_run).to contain_files("C:/path/to/project/spec/sub/foo_spec.rb")
|
544
|
+
end
|
545
|
+
|
546
|
+
it "loads files in Windows when directory is specified", :if => RSpec.world.windows_os? do
|
547
|
+
assign_files_or_directories_to_run "spec\\rspec\\core\\resources"
|
548
|
+
expect(config.files_to_run).to contain_files("spec/rspec/core/resources/a_spec.rb")
|
549
|
+
end
|
550
|
+
|
551
|
+
it_behaves_like "handling symlinked directories when loading spec files" do
|
552
|
+
def loaded_files
|
553
|
+
assign_files_or_directories_to_run "spec"
|
554
|
+
config.files_to_run
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
context "with default default_path" do
|
560
|
+
it "loads files in the default path when run by rspec" do
|
561
|
+
allow(config).to receive(:command) { 'rspec' }
|
562
|
+
assign_files_or_directories_to_run []
|
563
|
+
expect(config.files_to_run).not_to be_empty
|
564
|
+
end
|
565
|
+
|
566
|
+
it "loads files in the default path when run with DRB (e.g., spork)" do
|
567
|
+
allow(config).to receive(:command) { 'spork' }
|
568
|
+
allow(RSpec::Core::Runner).to receive(:running_in_drb?) { true }
|
569
|
+
assign_files_or_directories_to_run []
|
570
|
+
expect(config.files_to_run).not_to be_empty
|
571
|
+
end
|
572
|
+
|
573
|
+
it "does not load files in the default path when run by ruby" do
|
574
|
+
allow(config).to receive(:command) { 'ruby' }
|
575
|
+
assign_files_or_directories_to_run []
|
576
|
+
expect(config.files_to_run).to be_empty
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
def specify_consistent_ordering_of_files_to_run
|
581
|
+
allow(File).to receive(:directory?).with('a') { true }
|
582
|
+
allow(File).to receive(:directory?).with('.') { true }
|
583
|
+
globbed_files = nil
|
584
|
+
allow(Dir).to receive(:[]).with(/^\{?a/) { globbed_files }
|
585
|
+
allow(Dir).to receive(:[]).with(/^\{?\./) { [] }
|
586
|
+
|
587
|
+
orderings = [
|
588
|
+
%w[ a/1.rb a/2.rb a/3.rb ],
|
589
|
+
%w[ a/2.rb a/1.rb a/3.rb ],
|
590
|
+
%w[ a/3.rb a/2.rb a/1.rb ]
|
591
|
+
].map do |files|
|
592
|
+
globbed_files = files
|
593
|
+
yield
|
594
|
+
config.files_to_run
|
595
|
+
end
|
596
|
+
|
597
|
+
expect(orderings.uniq.size).to eq(1)
|
598
|
+
end
|
599
|
+
|
600
|
+
context 'when the given directories match the pattern' do
|
601
|
+
it 'orders the files in a consistent ordering, regardless of the underlying OS ordering' do
|
602
|
+
specify_consistent_ordering_of_files_to_run do
|
603
|
+
config.pattern = 'a/*.rb'
|
604
|
+
assign_files_or_directories_to_run 'a'
|
605
|
+
end
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
609
|
+
context 'when the pattern is given relative to the given directories' do
|
610
|
+
it 'orders the files in a consistent ordering, regardless of the underlying OS ordering' do
|
611
|
+
specify_consistent_ordering_of_files_to_run do
|
612
|
+
config.pattern = '*.rb'
|
613
|
+
assign_files_or_directories_to_run 'a'
|
614
|
+
end
|
615
|
+
end
|
616
|
+
end
|
617
|
+
|
618
|
+
context 'when given multiple file paths' do
|
619
|
+
it 'orders the files in a consistent ordering, regardless of the given order' do
|
620
|
+
allow(File).to receive(:directory?) { false } # fake it into thinking these a full file paths
|
621
|
+
|
622
|
+
files = ['a/b/c_spec.rb', 'c/b/a_spec.rb']
|
623
|
+
assign_files_or_directories_to_run(*files)
|
624
|
+
ordering_1 = config.files_to_run
|
625
|
+
|
626
|
+
assign_files_or_directories_to_run(*files.reverse)
|
627
|
+
ordering_2 = config.files_to_run
|
628
|
+
|
629
|
+
expect(ordering_1).to eq(ordering_2)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
describe "#pattern" do
|
635
|
+
context "with single pattern" do
|
636
|
+
before { config.pattern = "**/*_foo.rb" }
|
637
|
+
|
638
|
+
it "loads all explicitly specified files, even those that do not match the pattern" do
|
639
|
+
file_1 = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
|
640
|
+
file_2 = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb")
|
641
|
+
|
642
|
+
assign_files_or_directories_to_run file_1, file_2
|
643
|
+
expect(config.files_to_run).to contain_exactly(file_1, file_2)
|
644
|
+
end
|
645
|
+
|
646
|
+
it "loads files in directories following pattern" do
|
647
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
648
|
+
assign_files_or_directories_to_run dir
|
649
|
+
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
650
|
+
end
|
651
|
+
|
652
|
+
it "does not load files in directories not following pattern" do
|
653
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
654
|
+
assign_files_or_directories_to_run dir
|
655
|
+
expect(config.files_to_run).not_to include("#{dir}/a_bar.rb")
|
656
|
+
end
|
657
|
+
|
658
|
+
it "ignores pattern if files are specified" do
|
659
|
+
files = [
|
660
|
+
File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb"),
|
661
|
+
File.expand_path(File.dirname(__FILE__) + "/resources/a_spec.rb")
|
662
|
+
]
|
663
|
+
assign_files_or_directories_to_run(files)
|
664
|
+
expect(config.files_to_run).to match_array(files)
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
context "with multiple patterns" do
|
669
|
+
it "supports comma separated values" do
|
670
|
+
config.pattern = "**/*_foo.rb,**/*_bar.rb"
|
671
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
672
|
+
assign_files_or_directories_to_run dir
|
673
|
+
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
674
|
+
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
|
675
|
+
end
|
676
|
+
|
677
|
+
it "supports comma separated values with spaces" do
|
678
|
+
config.pattern = "**/*_foo.rb, **/*_bar.rb"
|
679
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
680
|
+
assign_files_or_directories_to_run dir
|
681
|
+
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
682
|
+
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
|
683
|
+
end
|
684
|
+
|
685
|
+
it "supports curly braces glob syntax" do
|
686
|
+
config.pattern = "**/*_{foo,bar}.rb"
|
687
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
688
|
+
assign_files_or_directories_to_run dir
|
689
|
+
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
|
690
|
+
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
context "after files have already been loaded" do
|
695
|
+
it 'warns that it will have no effect' do
|
696
|
+
expect_warning_with_call_site(__FILE__, __LINE__ + 2, /has no effect/)
|
697
|
+
config.load_spec_files
|
698
|
+
config.pattern = "rspec/**/*.spec"
|
699
|
+
end
|
700
|
+
|
701
|
+
it 'does not warn if reset is called after load_spec_files' do
|
702
|
+
config.load_spec_files
|
703
|
+
config.reset
|
704
|
+
expect(RSpec).to_not receive(:warning)
|
705
|
+
config.pattern = "rspec/**/*.spec"
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
context "after `files_to_run` has been accessed but before files have been loaded" do
|
710
|
+
it 'still takes affect' do
|
711
|
+
file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
|
712
|
+
assign_files_or_directories_to_run File.dirname(file)
|
713
|
+
expect(config.files_to_run).not_to include(file)
|
714
|
+
config.pattern = "**/*_foo.rb"
|
715
|
+
expect(config.files_to_run).to include(file)
|
716
|
+
end
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
describe "#exclude_pattern" do
|
721
|
+
context "with single pattern" do
|
722
|
+
before { config.exclude_pattern = "**/*_foo.rb" }
|
723
|
+
|
724
|
+
it "does not load files in directories following exclude pattern" do
|
725
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
726
|
+
assign_files_or_directories_to_run dir
|
727
|
+
expect(config.files_to_run).not_to include("#{dir}/a_foo.rb")
|
728
|
+
end
|
729
|
+
|
730
|
+
it "loads files in directories not following exclude pattern" do
|
731
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
732
|
+
assign_files_or_directories_to_run dir
|
733
|
+
expect(config.files_to_run).to include("#{dir}/a_spec.rb")
|
734
|
+
end
|
735
|
+
|
736
|
+
it "ignores exclude_pattern if files are specified" do
|
737
|
+
files = [
|
738
|
+
File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb"),
|
739
|
+
File.expand_path(File.dirname(__FILE__) + "/resources/a_spec.rb")
|
740
|
+
]
|
741
|
+
assign_files_or_directories_to_run(files)
|
742
|
+
expect(config.files_to_run).to match_array(files)
|
743
|
+
end
|
744
|
+
end
|
745
|
+
|
746
|
+
context "with multiple patterns" do
|
747
|
+
it "supports comma separated values" do
|
748
|
+
config.exclude_pattern = "**/*_foo.rb,**/*_bar.rb"
|
749
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
750
|
+
assign_files_or_directories_to_run dir
|
751
|
+
expect(config.files_to_run).not_to include("#{dir}/a_foo.rb")
|
752
|
+
expect(config.files_to_run).not_to include("#{dir}/a_bar.rb")
|
753
|
+
end
|
754
|
+
|
755
|
+
it "supports comma separated values with spaces" do
|
756
|
+
config.exclude_pattern = "**/*_foo.rb, **/*_bar.rb"
|
757
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
758
|
+
assign_files_or_directories_to_run dir
|
759
|
+
expect(config.files_to_run).not_to include("#{dir}/a_foo.rb")
|
760
|
+
expect(config.files_to_run).not_to include("#{dir}/a_bar.rb")
|
761
|
+
end
|
762
|
+
|
763
|
+
it "supports curly braces glob syntax" do
|
764
|
+
config.exclude_pattern = "**/*_{foo,bar}.rb"
|
765
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
766
|
+
assign_files_or_directories_to_run dir
|
767
|
+
expect(config.files_to_run).not_to include("#{dir}/a_foo.rb")
|
768
|
+
expect(config.files_to_run).not_to include("#{dir}/a_bar.rb")
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
context "after files have already been loaded" do
|
773
|
+
it 'warns that it will have no effect' do
|
774
|
+
expect_warning_with_call_site(__FILE__, __LINE__ + 2, /has no effect/)
|
775
|
+
config.load_spec_files
|
776
|
+
config.exclude_pattern = "rspec/**/*.spec"
|
777
|
+
end
|
778
|
+
|
779
|
+
it 'does not warn if reset is called after load_spec_files' do
|
780
|
+
config.load_spec_files
|
781
|
+
config.reset
|
782
|
+
expect(RSpec).to_not receive(:warning)
|
783
|
+
config.exclude_pattern = "rspec/**/*.spec"
|
784
|
+
end
|
785
|
+
end
|
786
|
+
|
787
|
+
context "after `files_to_run` has been accessed but before files have been loaded" do
|
788
|
+
it 'still takes affect' do
|
789
|
+
config.pattern = "**/*.rb"
|
790
|
+
file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
|
791
|
+
assign_files_or_directories_to_run File.dirname(file)
|
792
|
+
expect(config.files_to_run).to include(file)
|
793
|
+
config.exclude_pattern = "**/*_foo.rb"
|
794
|
+
expect(config.files_to_run).not_to include(file)
|
795
|
+
end
|
796
|
+
end
|
797
|
+
end
|
798
|
+
|
799
|
+
describe "path with line number" do
|
800
|
+
it "assigns the line number as a location filter" do
|
801
|
+
assign_files_or_directories_to_run "path/to/a_spec.rb:37"
|
802
|
+
expect(inclusion_filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
806
|
+
context "with full_description set" do
|
807
|
+
it "overrides filters" do
|
808
|
+
config.filter_run :focused => true
|
809
|
+
config.full_description = "foo"
|
810
|
+
expect(inclusion_filter).not_to have_key(:focused)
|
811
|
+
end
|
812
|
+
|
813
|
+
it 'is possible to access the full description regular expression' do
|
814
|
+
config.full_description = "foo"
|
815
|
+
expect(config.full_description).to eq(/foo/)
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
819
|
+
context "without full_description having been set" do
|
820
|
+
it 'returns nil from #full_description' do
|
821
|
+
expect(config.full_description).to eq nil
|
822
|
+
end
|
823
|
+
end
|
824
|
+
|
825
|
+
context "with line number" do
|
826
|
+
it "assigns the file and line number as a location filter" do
|
827
|
+
assign_files_or_directories_to_run "path/to/a_spec.rb:37"
|
828
|
+
expect(inclusion_filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
|
829
|
+
end
|
830
|
+
|
831
|
+
it "assigns multiple files with line numbers as location filters" do
|
832
|
+
assign_files_or_directories_to_run "path/to/a_spec.rb:37", "other_spec.rb:44"
|
833
|
+
expect(inclusion_filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37],
|
834
|
+
File.expand_path("other_spec.rb") => [44]}})
|
835
|
+
end
|
836
|
+
|
837
|
+
it "assigns files with multiple line numbers as location filters" do
|
838
|
+
assign_files_or_directories_to_run "path/to/a_spec.rb:37", "path/to/a_spec.rb:44"
|
839
|
+
expect(inclusion_filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37, 44]}})
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
context "with multiple line numbers" do
|
844
|
+
it "assigns the file and line numbers as a location filter" do
|
845
|
+
assign_files_or_directories_to_run "path/to/a_spec.rb:1:3:5:7"
|
846
|
+
expect(inclusion_filter).to eq({:locations => {File.expand_path("path/to/a_spec.rb") => [1,3,5,7]}})
|
847
|
+
end
|
848
|
+
end
|
849
|
+
|
850
|
+
it "assigns the example name as the filter on description" do
|
851
|
+
config.full_description = "foo"
|
852
|
+
expect(inclusion_filter).to eq({:full_description => /foo/})
|
853
|
+
end
|
854
|
+
|
855
|
+
it "assigns the example names as the filter on description if description is an array" do
|
856
|
+
config.full_description = [ "foo", "bar" ]
|
857
|
+
expect(inclusion_filter).to eq({:full_description => Regexp.union(/foo/, /bar/)})
|
858
|
+
end
|
859
|
+
|
860
|
+
it 'is possible to access the full description regular expression' do
|
861
|
+
config.full_description = "foo","bar"
|
862
|
+
expect(config.full_description).to eq Regexp.union(/foo/,/bar/)
|
863
|
+
end
|
864
|
+
|
865
|
+
describe "#default_path" do
|
866
|
+
it 'defaults to "spec"' do
|
867
|
+
expect(config.default_path).to eq('spec')
|
868
|
+
end
|
869
|
+
end
|
870
|
+
|
871
|
+
describe "#include" do
|
872
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :include, Enumerable
|
873
|
+
|
874
|
+
module InstanceLevelMethods
|
875
|
+
def you_call_this_a_blt?
|
876
|
+
"egad man, where's the mayo?!?!?"
|
877
|
+
end
|
878
|
+
end
|
879
|
+
|
880
|
+
it_behaves_like "metadata hash builder" do
|
881
|
+
def metadata_hash(*args)
|
882
|
+
config.include(InstanceLevelMethods, *args)
|
883
|
+
config.include_or_extend_modules.last.last
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|
887
|
+
context "with no filter" do
|
888
|
+
it "includes the given module into each example group" do
|
889
|
+
RSpec.configure do |c|
|
890
|
+
c.include(InstanceLevelMethods)
|
891
|
+
end
|
892
|
+
|
893
|
+
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
894
|
+
expect(group).not_to respond_to(:you_call_this_a_blt?)
|
895
|
+
expect(group.new.you_call_this_a_blt?).to eq("egad man, where's the mayo?!?!?")
|
896
|
+
end
|
897
|
+
end
|
898
|
+
|
899
|
+
context "with a filter" do
|
900
|
+
it "includes the given module into each matching example group" do
|
901
|
+
RSpec.configure do |c|
|
902
|
+
c.include(InstanceLevelMethods, :magic_key => :include)
|
903
|
+
end
|
904
|
+
|
905
|
+
group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
|
906
|
+
expect(group).not_to respond_to(:you_call_this_a_blt?)
|
907
|
+
expect(group.new.you_call_this_a_blt?).to eq("egad man, where's the mayo?!?!?")
|
908
|
+
end
|
909
|
+
end
|
910
|
+
|
911
|
+
end
|
912
|
+
|
913
|
+
describe "#extend" do
|
914
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :extend, Enumerable
|
915
|
+
|
916
|
+
module ThatThingISentYou
|
917
|
+
def that_thing
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
it_behaves_like "metadata hash builder" do
|
922
|
+
def metadata_hash(*args)
|
923
|
+
config.extend(ThatThingISentYou, *args)
|
924
|
+
config.include_or_extend_modules.last.last
|
925
|
+
end
|
926
|
+
end
|
927
|
+
|
928
|
+
it "extends the given module into each matching example group" do
|
929
|
+
RSpec.configure do |c|
|
930
|
+
c.extend(ThatThingISentYou, :magic_key => :extend)
|
931
|
+
end
|
932
|
+
|
933
|
+
group = ExampleGroup.describe(ThatThingISentYou, :magic_key => :extend) { }
|
934
|
+
expect(group).to respond_to(:that_thing)
|
935
|
+
end
|
936
|
+
|
937
|
+
end
|
938
|
+
|
939
|
+
describe "#run_all_when_everything_filtered?" do
|
940
|
+
|
941
|
+
it "defaults to false" do
|
942
|
+
expect(config.run_all_when_everything_filtered?).to be_falsey
|
943
|
+
end
|
944
|
+
|
945
|
+
it "can be queried with question method" do
|
946
|
+
config.run_all_when_everything_filtered = true
|
947
|
+
expect(config.run_all_when_everything_filtered?).to be_truthy
|
948
|
+
end
|
949
|
+
end
|
950
|
+
|
951
|
+
describe "#color=" do
|
952
|
+
context "given true" do
|
953
|
+
before { config.color = true }
|
954
|
+
|
955
|
+
context "with config.tty? and output.tty?" do
|
956
|
+
it "sets color_enabled?" do
|
957
|
+
output = StringIO.new
|
958
|
+
config.output_stream = output
|
959
|
+
|
960
|
+
config.tty = true
|
961
|
+
allow(config.output_stream).to receive_messages :tty? => true
|
962
|
+
|
963
|
+
expect(config.color_enabled?).to be_truthy
|
964
|
+
expect(config.color_enabled?(output)).to be_truthy
|
965
|
+
end
|
966
|
+
end
|
967
|
+
|
968
|
+
context "with config.tty? and !output.tty?" do
|
969
|
+
it "sets color_enabled?" do
|
970
|
+
output = StringIO.new
|
971
|
+
config.output_stream = output
|
972
|
+
|
973
|
+
config.tty = true
|
974
|
+
allow(config.output_stream).to receive_messages :tty? => false
|
975
|
+
|
976
|
+
expect(config.color_enabled?).to be_truthy
|
977
|
+
expect(config.color_enabled?(output)).to be_truthy
|
978
|
+
end
|
979
|
+
end
|
980
|
+
|
981
|
+
context "with config.tty? and !output.tty?" do
|
982
|
+
it "does not set color_enabled?" do
|
983
|
+
output = StringIO.new
|
984
|
+
config.output_stream = output
|
985
|
+
|
986
|
+
config.tty = false
|
987
|
+
allow(config.output_stream).to receive_messages :tty? => true
|
988
|
+
|
989
|
+
expect(config.color_enabled?).to be_truthy
|
990
|
+
expect(config.color_enabled?(output)).to be_truthy
|
991
|
+
end
|
992
|
+
end
|
993
|
+
|
994
|
+
context "with !config.tty? and !output.tty?" do
|
995
|
+
it "does not set color_enabled?" do
|
996
|
+
output = StringIO.new
|
997
|
+
config.output_stream = output
|
998
|
+
|
999
|
+
config.tty = false
|
1000
|
+
allow(config.output_stream).to receive_messages :tty? => false
|
1001
|
+
|
1002
|
+
expect(config.color_enabled?).to be_falsey
|
1003
|
+
expect(config.color_enabled?(output)).to be_falsey
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
context "on windows" do
|
1008
|
+
before do
|
1009
|
+
@original_host = RbConfig::CONFIG['host_os']
|
1010
|
+
RbConfig::CONFIG['host_os'] = 'mingw'
|
1011
|
+
allow(config).to receive(:require)
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
after do
|
1015
|
+
RbConfig::CONFIG['host_os'] = @original_host
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
context "with ANSICON available" do
|
1019
|
+
around(:each) { |e| with_env_vars('ANSICON' => 'ANSICON', &e) }
|
1020
|
+
|
1021
|
+
it "enables colors" do
|
1022
|
+
config.output_stream = StringIO.new
|
1023
|
+
allow(config.output_stream).to receive_messages :tty? => true
|
1024
|
+
config.color = true
|
1025
|
+
expect(config.color).to be_truthy
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it "leaves output stream intact" do
|
1029
|
+
config.output_stream = $stdout
|
1030
|
+
allow(config).to receive(:require) do |what|
|
1031
|
+
config.output_stream = 'foo' if what =~ /Win32/
|
1032
|
+
end
|
1033
|
+
config.color = true
|
1034
|
+
expect(config.output_stream).to eq($stdout)
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
context "with ANSICON NOT available" do
|
1039
|
+
before do
|
1040
|
+
allow_warning
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
it "warns to install ANSICON" do
|
1044
|
+
allow(config).to receive(:require) { raise LoadError }
|
1045
|
+
expect_warning_with_call_site(__FILE__, __LINE__ + 1, /You must use ANSICON/)
|
1046
|
+
config.color = true
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
it "sets color to false" do
|
1050
|
+
allow(config).to receive(:require) { raise LoadError }
|
1051
|
+
config.color = true
|
1052
|
+
expect(config.color).to be_falsey
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
it "prefers incoming cli_args" do
|
1059
|
+
config.output_stream = StringIO.new
|
1060
|
+
allow(config.output_stream).to receive_messages :tty? => true
|
1061
|
+
config.force :color => true
|
1062
|
+
config.color = false
|
1063
|
+
expect(config.color).to be_truthy
|
1064
|
+
end
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
%w[formatter= add_formatter].each do |config_method|
|
1068
|
+
describe "##{config_method}" do
|
1069
|
+
it "delegates to formatters#add" do
|
1070
|
+
expect(config.formatter_loader).to receive(:add).with('these','options')
|
1071
|
+
config.send(config_method,'these','options')
|
1072
|
+
end
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
describe "#formatters" do
|
1077
|
+
it "returns a dup of the formatter_loader formatters" do
|
1078
|
+
config.add_formatter 'doc'
|
1079
|
+
config.formatters.clear
|
1080
|
+
expect(config.formatters).to_not eq []
|
1081
|
+
end
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
describe "#default_formatter" do
|
1085
|
+
it 'defaults to `progress`' do
|
1086
|
+
expect(config.default_formatter).to eq('progress')
|
1087
|
+
end
|
1088
|
+
|
1089
|
+
it 'remembers changes' do
|
1090
|
+
config.default_formatter = 'doc'
|
1091
|
+
expect(config.default_formatter).to eq('doc')
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
context 'when another formatter has been set' do
|
1095
|
+
it 'does not get used' do
|
1096
|
+
config.default_formatter = 'doc'
|
1097
|
+
config.add_formatter 'progress'
|
1098
|
+
|
1099
|
+
expect(used_formatters).to include(an_instance_of Formatters::ProgressFormatter)
|
1100
|
+
expect(used_formatters).not_to include(an_instance_of Formatters::DocumentationFormatter)
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
context 'when no other formatter has been set' do
|
1105
|
+
it 'gets used' do
|
1106
|
+
config.default_formatter = 'doc'
|
1107
|
+
|
1108
|
+
expect(used_formatters).not_to include(an_instance_of Formatters::ProgressFormatter)
|
1109
|
+
expect(used_formatters).to include(an_instance_of Formatters::DocumentationFormatter)
|
1110
|
+
end
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
context 'using a legacy formatter as default' do
|
1114
|
+
# Generating warnings during formatter initialisation triggers the
|
1115
|
+
# ProxyReporter code path.
|
1116
|
+
it 'remembers changes' do
|
1117
|
+
legacy_formatter = Class.new
|
1118
|
+
|
1119
|
+
config = RSpec.configuration
|
1120
|
+
config.default_formatter = legacy_formatter
|
1121
|
+
config.reporter
|
1122
|
+
expect(config.default_formatter).to eq(legacy_formatter)
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
def used_formatters
|
1127
|
+
config.reporter # to force freezing of formatters
|
1128
|
+
config.formatters
|
1129
|
+
end
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
describe "#filter_run_including" do
|
1133
|
+
it_behaves_like "metadata hash builder" do
|
1134
|
+
def metadata_hash(*args)
|
1135
|
+
config.filter_run_including(*args)
|
1136
|
+
config.inclusion_filter.rules
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :filter_run_including
|
1141
|
+
|
1142
|
+
it "sets the filter with a hash" do
|
1143
|
+
config.filter_run_including :foo => true
|
1144
|
+
expect(inclusion_filter).to eq( {:foo => true} )
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
it "sets the filter with a symbol" do
|
1148
|
+
config.filter_run_including :foo
|
1149
|
+
expect(inclusion_filter).to eq( {:foo => true} )
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
it "merges with existing filters" do
|
1153
|
+
config.filter_run_including :foo => true
|
1154
|
+
config.filter_run_including :bar => false
|
1155
|
+
expect(inclusion_filter).to eq( {:foo => true, :bar => false} )
|
1156
|
+
end
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
describe "#filter_run_excluding" do
|
1160
|
+
it_behaves_like "metadata hash builder" do
|
1161
|
+
def metadata_hash(*args)
|
1162
|
+
config.filter_run_excluding(*args)
|
1163
|
+
config.exclusion_filter.rules
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :filter_run_excluding
|
1168
|
+
|
1169
|
+
it "sets the filter" do
|
1170
|
+
config.filter_run_excluding :foo => true
|
1171
|
+
expect(exclusion_filter).to eq( {:foo => true} )
|
1172
|
+
end
|
1173
|
+
|
1174
|
+
it "sets the filter using a symbol" do
|
1175
|
+
config.filter_run_excluding :foo
|
1176
|
+
expect(exclusion_filter).to eq( {:foo => true} )
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
it "merges with existing filters" do
|
1180
|
+
config.filter_run_excluding :foo => true
|
1181
|
+
config.filter_run_excluding :bar => false
|
1182
|
+
expect(exclusion_filter).to eq( {:foo => true, :bar => false} )
|
1183
|
+
end
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
shared_examples_for "a spec filter" do |type|
|
1187
|
+
describe "##{type}" do
|
1188
|
+
it "returns {} even if set to nil" do
|
1189
|
+
config.send("#{type}=", nil)
|
1190
|
+
expect(send(type)).to eq({})
|
1191
|
+
end
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
describe "##{type}=" do
|
1195
|
+
it "treats symbols as hash keys with true values when told to" do
|
1196
|
+
config.send("#{type}=", :foo)
|
1197
|
+
expect(send(type)).to eq( {:foo => true} )
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
it "overrides any #{type} set on the command line or in configuration files" do
|
1201
|
+
config.force(type => { :foo => :bar })
|
1202
|
+
config.send("#{type}=", {:want => :this})
|
1203
|
+
expect(send(type)).to eq( {:want => :this} )
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :"#{type}="
|
1207
|
+
end
|
1208
|
+
end
|
1209
|
+
it_behaves_like "a spec filter", :inclusion_filter
|
1210
|
+
it_behaves_like "a spec filter", :exclusion_filter
|
1211
|
+
|
1212
|
+
describe "#treat_symbols_as_metadata_keys_with_true_values=" do
|
1213
|
+
it 'is deprecated' do
|
1214
|
+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
1215
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
1216
|
+
end
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
describe "#full_backtrace=" do
|
1220
|
+
it "doesn't impact other instances of config" do
|
1221
|
+
config_1 = Configuration.new
|
1222
|
+
config_2 = Configuration.new
|
1223
|
+
|
1224
|
+
config_1.full_backtrace = true
|
1225
|
+
expect(config_2.full_backtrace?).to be_falsey
|
1226
|
+
end
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
describe "#backtrace_exclusion_patterns=" do
|
1230
|
+
it "actually receives the new filter values" do
|
1231
|
+
config = Configuration.new
|
1232
|
+
config.backtrace_exclusion_patterns = [/.*/]
|
1233
|
+
expect(config.backtrace_formatter.exclude? "this").to be_truthy
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
|
1237
|
+
describe 'full_backtrace' do
|
1238
|
+
it 'returns true when backtrace patterns is empty' do
|
1239
|
+
config.backtrace_exclusion_patterns = []
|
1240
|
+
expect(config.full_backtrace?).to eq true
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
it 'returns false when backtrace patterns isnt empty' do
|
1244
|
+
config.backtrace_exclusion_patterns = [:lib]
|
1245
|
+
expect(config.full_backtrace?).to eq false
|
1246
|
+
end
|
1247
|
+
end
|
1248
|
+
|
1249
|
+
describe "#backtrace_exclusion_patterns" do
|
1250
|
+
it "can be appended to" do
|
1251
|
+
config = Configuration.new
|
1252
|
+
config.backtrace_exclusion_patterns << /.*/
|
1253
|
+
expect(config.backtrace_formatter.exclude? "this").to be_truthy
|
1254
|
+
end
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
describe "#filter_gems_from_backtrace" do
|
1258
|
+
def exclude?(line)
|
1259
|
+
config.backtrace_formatter.exclude?(line)
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
it 'filters the named gems from the backtrace' do
|
1263
|
+
line_1 = "/Users/myron/.gem/ruby/2.1.1/gems/foo-1.6.3.1/foo.rb:13"
|
1264
|
+
line_2 = "/Users/myron/.gem/ruby/2.1.1/gems/bar-1.6.3.1/bar.rb:13"
|
1265
|
+
|
1266
|
+
expect {
|
1267
|
+
config.filter_gems_from_backtrace "foo", "bar"
|
1268
|
+
}.to change { exclude?(line_1) }.from(false).to(true).
|
1269
|
+
and change { exclude?(line_2) }.from(false).to(true)
|
1270
|
+
end
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
describe "#libs=" do
|
1274
|
+
it "adds directories to the LOAD_PATH" do
|
1275
|
+
expect($LOAD_PATH).to receive(:unshift).with("a/dir")
|
1276
|
+
config.libs = ["a/dir"]
|
1277
|
+
end
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
describe "libs" do
|
1281
|
+
it 'records paths added to the load path' do
|
1282
|
+
config.libs = ["a/dir"]
|
1283
|
+
expect(config.libs).to eq ["a/dir"]
|
1284
|
+
end
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
describe "#define_derived_metadata" do
|
1288
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :define_derived_metadata
|
1289
|
+
|
1290
|
+
it 'allows the provided block to mutate example group metadata' do
|
1291
|
+
RSpec.configuration.define_derived_metadata do |metadata|
|
1292
|
+
metadata[:reverse_description] = metadata[:description].reverse
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
group = RSpec.describe("My group")
|
1296
|
+
expect(group.metadata).to include(:description => "My group", :reverse_description => "puorg yM")
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
it 'allows the provided block to mutate example metadata' do
|
1300
|
+
RSpec.configuration.define_derived_metadata do |metadata|
|
1301
|
+
metadata[:reverse_description] = metadata[:description].reverse
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
ex = RSpec.describe("My group").example("foo")
|
1305
|
+
expect(ex.metadata).to include(:description => "foo", :reverse_description => "oof")
|
1306
|
+
end
|
1307
|
+
|
1308
|
+
it 'allows multiple configured blocks to be applied, in order of definition' do
|
1309
|
+
RSpec.configure do |c|
|
1310
|
+
c.define_derived_metadata { |m| m[:b1_desc] = m[:description] + " (block 1)" }
|
1311
|
+
c.define_derived_metadata { |m| m[:b2_desc] = m[:b1_desc] + " (block 2)" }
|
1312
|
+
end
|
1313
|
+
|
1314
|
+
group = RSpec.describe("bar")
|
1315
|
+
expect(group.metadata).to include(:b1_desc => "bar (block 1)", :b2_desc => "bar (block 1) (block 2)")
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
it "derives metadata before the group or example blocks are eval'd so their logic can depend on the derived metadata" do
|
1319
|
+
RSpec.configure do |c|
|
1320
|
+
c.define_derived_metadata(:foo) do |metadata|
|
1321
|
+
metadata[:bar] = "bar"
|
1322
|
+
end
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
group_bar_value = example_bar_value = nil
|
1326
|
+
|
1327
|
+
RSpec.describe "Group", :foo do
|
1328
|
+
group_bar_value = metadata[:bar]
|
1329
|
+
example_bar_value = example("ex", :foo).metadata[:bar]
|
1330
|
+
end
|
1331
|
+
|
1332
|
+
expect(group_bar_value).to eq("bar")
|
1333
|
+
expect(example_bar_value).to eq("bar")
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
context "when passed a metadata filter" do
|
1337
|
+
it 'only applies to the groups and examples that match that filter' do
|
1338
|
+
RSpec.configure do |c|
|
1339
|
+
c.define_derived_metadata(:apply => true) do |metadata|
|
1340
|
+
metadata[:reverse_description] = metadata[:description].reverse
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
g1 = RSpec.describe("G1", :apply)
|
1345
|
+
g2 = RSpec.describe("G2")
|
1346
|
+
e1 = g1.example("E1")
|
1347
|
+
e2 = g2.example("E2", :apply)
|
1348
|
+
e3 = g2.example("E3")
|
1349
|
+
|
1350
|
+
expect(g1.metadata).to include(:reverse_description => "1G")
|
1351
|
+
expect(g2.metadata).not_to include(:reverse_description)
|
1352
|
+
|
1353
|
+
expect(e1.metadata).to include(:reverse_description => "1E")
|
1354
|
+
expect(e2.metadata).to include(:reverse_description => "2E")
|
1355
|
+
expect(e3.metadata).not_to include(:reverse_description)
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
it 'applies if any of multiple filters apply (to align with module inclusion semantics)' do
|
1359
|
+
RSpec.configure do |c|
|
1360
|
+
c.define_derived_metadata(:a => 1, :b => 2) do |metadata|
|
1361
|
+
metadata[:reverse_description] = metadata[:description].reverse
|
1362
|
+
end
|
1363
|
+
end
|
1364
|
+
|
1365
|
+
g1 = RSpec.describe("G1", :a => 1)
|
1366
|
+
g2 = RSpec.describe("G2", :b => 2)
|
1367
|
+
g3 = RSpec.describe("G3", :c => 3)
|
1368
|
+
|
1369
|
+
expect(g1.metadata).to include(:reverse_description => "1G")
|
1370
|
+
expect(g2.metadata).to include(:reverse_description => "2G")
|
1371
|
+
expect(g3.metadata).not_to include(:reverse_description)
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
it 'allows a metadata filter to be passed as a raw symbol' do
|
1375
|
+
RSpec.configure do |c|
|
1376
|
+
c.define_derived_metadata(:apply) do |metadata|
|
1377
|
+
metadata[:reverse_description] = metadata[:description].reverse
|
1378
|
+
end
|
1379
|
+
end
|
1380
|
+
|
1381
|
+
g1 = RSpec.describe("G1", :apply)
|
1382
|
+
g2 = RSpec.describe("G2")
|
1383
|
+
|
1384
|
+
expect(g1.metadata).to include(:reverse_description => "1G")
|
1385
|
+
expect(g2.metadata).not_to include(:reverse_description)
|
1386
|
+
end
|
1387
|
+
end
|
1388
|
+
end
|
1389
|
+
|
1390
|
+
describe "#add_setting" do
|
1391
|
+
describe "with no modifiers" do
|
1392
|
+
context "with no additional options" do
|
1393
|
+
before do
|
1394
|
+
config.add_setting :custom_option
|
1395
|
+
end
|
1396
|
+
|
1397
|
+
it "defaults to nil" do
|
1398
|
+
expect(config.custom_option).to be_nil
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
it "adds a predicate" do
|
1402
|
+
expect(config.custom_option?).to be_falsey
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
it "can be overridden" do
|
1406
|
+
config.custom_option = "a value"
|
1407
|
+
expect(config.custom_option).to eq("a value")
|
1408
|
+
end
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
context "with :default => 'a value'" do
|
1412
|
+
before do
|
1413
|
+
config.add_setting :custom_option, :default => 'a value'
|
1414
|
+
end
|
1415
|
+
|
1416
|
+
it "defaults to 'a value'" do
|
1417
|
+
expect(config.custom_option).to eq("a value")
|
1418
|
+
end
|
1419
|
+
|
1420
|
+
it "returns true for the predicate" do
|
1421
|
+
expect(config.custom_option?).to be_truthy
|
1422
|
+
end
|
1423
|
+
|
1424
|
+
it "can be overridden with a truthy value" do
|
1425
|
+
config.custom_option = "a new value"
|
1426
|
+
expect(config.custom_option).to eq("a new value")
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
it "can be overridden with nil" do
|
1430
|
+
config.custom_option = nil
|
1431
|
+
expect(config.custom_option).to eq(nil)
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
it "can be overridden with false" do
|
1435
|
+
config.custom_option = false
|
1436
|
+
expect(config.custom_option).to eq(false)
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
context "with :alias_with => " do
|
1442
|
+
before do
|
1443
|
+
config.add_setting :custom_option, :alias_with => :another_custom_option
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
it "delegates the getter to the other option" do
|
1447
|
+
config.another_custom_option = "this value"
|
1448
|
+
expect(config.custom_option).to eq("this value")
|
1449
|
+
end
|
1450
|
+
|
1451
|
+
it "delegates the setter to the other option" do
|
1452
|
+
config.custom_option = "this value"
|
1453
|
+
expect(config.another_custom_option).to eq("this value")
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
it "delegates the predicate to the other option" do
|
1457
|
+
config.custom_option = true
|
1458
|
+
expect(config.another_custom_option?).to be_truthy
|
1459
|
+
end
|
1460
|
+
end
|
1461
|
+
end
|
1462
|
+
|
1463
|
+
describe "#configure_group" do
|
1464
|
+
it "extends with 'extend'" do
|
1465
|
+
mod = Module.new
|
1466
|
+
group = ExampleGroup.describe("group", :foo => :bar)
|
1467
|
+
|
1468
|
+
config.extend(mod, :foo => :bar)
|
1469
|
+
config.configure_group(group)
|
1470
|
+
expect(group).to be_a(mod)
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
it "extends with 'module'" do
|
1474
|
+
mod = Module.new
|
1475
|
+
group = ExampleGroup.describe("group", :foo => :bar)
|
1476
|
+
|
1477
|
+
config.include(mod, :foo => :bar)
|
1478
|
+
config.configure_group(group)
|
1479
|
+
expect(group.included_modules).to include(mod)
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
it "requires only one matching filter" do
|
1483
|
+
mod = Module.new
|
1484
|
+
group = ExampleGroup.describe("group", :foo => :bar)
|
1485
|
+
|
1486
|
+
config.include(mod, :foo => :bar, :baz => :bam)
|
1487
|
+
config.configure_group(group)
|
1488
|
+
expect(group.included_modules).to include(mod)
|
1489
|
+
end
|
1490
|
+
|
1491
|
+
it "includes each one before deciding whether to include the next" do
|
1492
|
+
mod1 = Module.new do
|
1493
|
+
def self.included(host)
|
1494
|
+
host.metadata[:foo] = :bar
|
1495
|
+
end
|
1496
|
+
end
|
1497
|
+
mod2 = Module.new
|
1498
|
+
|
1499
|
+
group = ExampleGroup.describe("group")
|
1500
|
+
|
1501
|
+
config.include(mod1)
|
1502
|
+
config.include(mod2, :foo => :bar)
|
1503
|
+
config.configure_group(group)
|
1504
|
+
expect(group.included_modules).to include(mod1)
|
1505
|
+
expect(group.included_modules).to include(mod2)
|
1506
|
+
end
|
1507
|
+
|
1508
|
+
module IncludeOrExtendMeOnce
|
1509
|
+
def self.included(host)
|
1510
|
+
raise "included again" if host.instance_methods.include?(:foobar)
|
1511
|
+
host.class_exec { def foobar; end }
|
1512
|
+
end
|
1513
|
+
|
1514
|
+
def self.extended(host)
|
1515
|
+
raise "extended again" if host.respond_to?(:foobar)
|
1516
|
+
def host.foobar; end
|
1517
|
+
end
|
1518
|
+
end
|
1519
|
+
|
1520
|
+
it "doesn't include a module when already included in ancestor" do
|
1521
|
+
config.include(IncludeOrExtendMeOnce, :foo => :bar)
|
1522
|
+
|
1523
|
+
group = ExampleGroup.describe("group", :foo => :bar)
|
1524
|
+
child = group.describe("child")
|
1525
|
+
|
1526
|
+
config.configure_group(group)
|
1527
|
+
config.configure_group(child)
|
1528
|
+
end
|
1529
|
+
|
1530
|
+
it "doesn't extend when ancestor is already extended with same module" do
|
1531
|
+
config.extend(IncludeOrExtendMeOnce, :foo => :bar)
|
1532
|
+
|
1533
|
+
group = ExampleGroup.describe("group", :foo => :bar)
|
1534
|
+
child = group.describe("child")
|
1535
|
+
|
1536
|
+
config.configure_group(group)
|
1537
|
+
config.configure_group(child)
|
1538
|
+
end
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
describe "#alias_example_group_to" do
|
1542
|
+
after do
|
1543
|
+
RSpec::Core::DSL.example_group_aliases.delete(:my_group_method)
|
1544
|
+
|
1545
|
+
RSpec.module_exec do
|
1546
|
+
class << self
|
1547
|
+
undef :my_group_method if method_defined? :my_group_method
|
1548
|
+
end
|
1549
|
+
end
|
1550
|
+
|
1551
|
+
RSpec::Core::ExampleGroup.module_exec do
|
1552
|
+
class << self
|
1553
|
+
undef :my_group_method if method_defined? :my_group_method
|
1554
|
+
end
|
1555
|
+
end
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
it_behaves_like "metadata hash builder" do
|
1559
|
+
def metadata_hash(*args)
|
1560
|
+
config.alias_example_group_to :my_group_method, *args
|
1561
|
+
group = ExampleGroup.my_group_method("a group")
|
1562
|
+
group.metadata
|
1563
|
+
end
|
1564
|
+
end
|
1565
|
+
|
1566
|
+
it "allows adding additional metadata" do
|
1567
|
+
config.alias_example_group_to :my_group_method, { :some => "thing" }
|
1568
|
+
group = ExampleGroup.my_group_method("a group", :another => "thing")
|
1569
|
+
expect(group.metadata).to include(:some => "thing", :another => "thing")
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
it "passes `nil` as the description arg when no args are given" do
|
1573
|
+
config.alias_example_group_to :my_group_method, { :some => "thing" }
|
1574
|
+
group = ExampleGroup.my_group_method
|
1575
|
+
|
1576
|
+
expect(group.metadata).to include(
|
1577
|
+
:description_args => [nil],
|
1578
|
+
:description => "",
|
1579
|
+
:some => "thing"
|
1580
|
+
)
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
context 'when the aliased method is used' do
|
1584
|
+
it_behaves_like "metadata hash builder" do
|
1585
|
+
def metadata_hash(*args)
|
1586
|
+
config.alias_example_group_to :my_group_method
|
1587
|
+
group = ExampleGroup.my_group_method("a group", *args)
|
1588
|
+
group.metadata
|
1589
|
+
end
|
1590
|
+
end
|
1591
|
+
end
|
1592
|
+
end
|
1593
|
+
|
1594
|
+
describe "#alias_example_to" do
|
1595
|
+
it_behaves_like "metadata hash builder" do
|
1596
|
+
after do
|
1597
|
+
RSpec::Core::ExampleGroup.module_exec do
|
1598
|
+
class << self
|
1599
|
+
undef :my_example_method if method_defined? :my_example_method
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
end
|
1603
|
+
def metadata_hash(*args)
|
1604
|
+
config.alias_example_to :my_example_method, *args
|
1605
|
+
group = ExampleGroup.describe("group")
|
1606
|
+
example = group.my_example_method("description")
|
1607
|
+
example.metadata
|
1608
|
+
end
|
1609
|
+
end
|
1610
|
+
end
|
1611
|
+
|
1612
|
+
describe "#reset" do
|
1613
|
+
it "clears the reporter" do
|
1614
|
+
expect(config.reporter).not_to be_nil
|
1615
|
+
config.reset
|
1616
|
+
expect(config.instance_variable_get("@reporter")).to be_nil
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
it "clears the formatters" do
|
1620
|
+
config.add_formatter "doc"
|
1621
|
+
config.reset
|
1622
|
+
expect(config.formatters).to be_empty
|
1623
|
+
end
|
1624
|
+
end
|
1625
|
+
|
1626
|
+
describe "#force" do
|
1627
|
+
context "for ordering options" do
|
1628
|
+
let(:list) { [1, 2, 3, 4] }
|
1629
|
+
let(:ordering_strategy) { config.ordering_registry.fetch(:global) }
|
1630
|
+
let(:rng) { RSpec::Core::RandomNumberGenerator.new config.seed }
|
1631
|
+
let(:shuffled) { Ordering::Random.new(config).shuffle list, rng }
|
1632
|
+
|
1633
|
+
specify "CLI `--order defined` takes precedence over `config.order = rand`" do
|
1634
|
+
config.force :order => "defined"
|
1635
|
+
config.order = "rand"
|
1636
|
+
|
1637
|
+
expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
|
1638
|
+
end
|
1639
|
+
|
1640
|
+
specify "CLI `--order rand:37` takes precedence over `config.order = defined`" do
|
1641
|
+
config.force :order => "rand:37"
|
1642
|
+
config.order = "defined"
|
1643
|
+
|
1644
|
+
expect(ordering_strategy.order(list)).to eq(shuffled)
|
1645
|
+
end
|
1646
|
+
|
1647
|
+
specify "CLI `--seed 37` forces order and seed" do
|
1648
|
+
config.force :seed => 37
|
1649
|
+
config.order = "defined"
|
1650
|
+
config.seed = 145
|
1651
|
+
|
1652
|
+
expect(ordering_strategy.order(list)).to eq(shuffled)
|
1653
|
+
expect(config.seed).to eq(37)
|
1654
|
+
end
|
1655
|
+
|
1656
|
+
specify "CLI `--order defined` takes precedence over `config.register_ordering(:global)`" do
|
1657
|
+
config.force :order => "defined"
|
1658
|
+
config.register_ordering(:global, &:reverse)
|
1659
|
+
expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
|
1660
|
+
end
|
1661
|
+
end
|
1662
|
+
|
1663
|
+
it "forces 'false' value" do
|
1664
|
+
config.add_setting :custom_option
|
1665
|
+
config.custom_option = true
|
1666
|
+
expect(config.custom_option?).to be_truthy
|
1667
|
+
config.force :custom_option => false
|
1668
|
+
expect(config.custom_option?).to be_falsey
|
1669
|
+
config.custom_option = true
|
1670
|
+
expect(config.custom_option?).to be_falsey
|
1671
|
+
end
|
1672
|
+
end
|
1673
|
+
|
1674
|
+
describe '#seed' do
|
1675
|
+
it 'returns the seed as an int' do
|
1676
|
+
config.seed = '123'
|
1677
|
+
expect(config.seed).to eq(123)
|
1678
|
+
end
|
1679
|
+
end
|
1680
|
+
|
1681
|
+
describe "#seed_used?" do
|
1682
|
+
def use_seed_on(registry)
|
1683
|
+
registry.fetch(:random).order([1, 2])
|
1684
|
+
end
|
1685
|
+
|
1686
|
+
it 'returns false if neither ordering registry used the seed' do
|
1687
|
+
expect(config.seed_used?).to be false
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
it 'returns true if the ordering registry used the seed' do
|
1691
|
+
use_seed_on(config.ordering_registry)
|
1692
|
+
expect(config.seed_used?).to be true
|
1693
|
+
end
|
1694
|
+
end
|
1695
|
+
|
1696
|
+
describe '#order=' do
|
1697
|
+
context 'given "random"' do
|
1698
|
+
before do
|
1699
|
+
config.seed = 7654
|
1700
|
+
config.order = 'random'
|
1701
|
+
end
|
1702
|
+
|
1703
|
+
it 'does not change the seed' do
|
1704
|
+
expect(config.seed).to eq(7654)
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
it 'sets up random ordering' do
|
1708
|
+
allow(RSpec).to receive_messages(:configuration => config)
|
1709
|
+
global_ordering = config.ordering_registry.fetch(:global)
|
1710
|
+
expect(global_ordering).to be_an_instance_of(Ordering::Random)
|
1711
|
+
end
|
1712
|
+
end
|
1713
|
+
|
1714
|
+
context 'given "random:123"' do
|
1715
|
+
before { config.order = 'random:123' }
|
1716
|
+
|
1717
|
+
it 'sets seed to 123' do
|
1718
|
+
expect(config.seed).to eq(123)
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
it 'sets up random ordering' do
|
1722
|
+
allow(RSpec).to receive_messages(:configuration => config)
|
1723
|
+
global_ordering = config.ordering_registry.fetch(:global)
|
1724
|
+
expect(global_ordering).to be_an_instance_of(Ordering::Random)
|
1725
|
+
end
|
1726
|
+
end
|
1727
|
+
|
1728
|
+
context 'given "defined"' do
|
1729
|
+
before do
|
1730
|
+
config.order = 'rand:123'
|
1731
|
+
config.order = 'defined'
|
1732
|
+
end
|
1733
|
+
|
1734
|
+
it "does not change the seed" do
|
1735
|
+
expect(config.seed).to eq(123)
|
1736
|
+
end
|
1737
|
+
|
1738
|
+
it 'clears the random ordering' do
|
1739
|
+
allow(RSpec).to receive_messages(:configuration => config)
|
1740
|
+
list = [1, 2, 3, 4]
|
1741
|
+
ordering_strategy = config.ordering_registry.fetch(:global)
|
1742
|
+
expect(ordering_strategy.order(list)).to eq([1, 2, 3, 4])
|
1743
|
+
end
|
1744
|
+
end
|
1745
|
+
end
|
1746
|
+
|
1747
|
+
describe "#register_ordering" do
|
1748
|
+
def register_reverse_ordering
|
1749
|
+
config.register_ordering(:reverse, &:reverse)
|
1750
|
+
end
|
1751
|
+
|
1752
|
+
it 'stores the ordering for later use' do
|
1753
|
+
register_reverse_ordering
|
1754
|
+
|
1755
|
+
list = [1, 2, 3]
|
1756
|
+
strategy = config.ordering_registry.fetch(:reverse)
|
1757
|
+
expect(strategy).to be_a(Ordering::Custom)
|
1758
|
+
expect(strategy.order(list)).to eq([3, 2, 1])
|
1759
|
+
end
|
1760
|
+
|
1761
|
+
it 'can register an ordering object' do
|
1762
|
+
strategy = Object.new
|
1763
|
+
def strategy.order(list)
|
1764
|
+
list.reverse
|
1765
|
+
end
|
1766
|
+
|
1767
|
+
config.register_ordering(:reverse, strategy)
|
1768
|
+
list = [1, 2, 3]
|
1769
|
+
fetched = config.ordering_registry.fetch(:reverse)
|
1770
|
+
expect(fetched).to be(strategy)
|
1771
|
+
expect(fetched.order(list)).to eq([3, 2, 1])
|
1772
|
+
end
|
1773
|
+
end
|
1774
|
+
|
1775
|
+
describe '#warnings' do
|
1776
|
+
around do |example|
|
1777
|
+
original_setting = $VERBOSE
|
1778
|
+
example.run
|
1779
|
+
$VERBOSE = original_setting
|
1780
|
+
end
|
1781
|
+
|
1782
|
+
it "sets verbose to true when true" do
|
1783
|
+
config.warnings = true
|
1784
|
+
expect($VERBOSE).to eq true
|
1785
|
+
end
|
1786
|
+
|
1787
|
+
it "sets verbose to false when true" do
|
1788
|
+
config.warnings = false
|
1789
|
+
expect($VERBOSE).to eq false
|
1790
|
+
end
|
1791
|
+
|
1792
|
+
it 'returns the verbosity setting' do
|
1793
|
+
config.warnings = true
|
1794
|
+
expect(config.warnings?).to eq true
|
1795
|
+
|
1796
|
+
config.warnings = false
|
1797
|
+
expect(config.warnings?).to eq false
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
it 'is loaded from config by #force' do
|
1801
|
+
config.force :warnings => true
|
1802
|
+
expect($VERBOSE).to eq true
|
1803
|
+
end
|
1804
|
+
end
|
1805
|
+
|
1806
|
+
describe "#raise_errors_for_deprecations!" do
|
1807
|
+
it 'causes deprecations to raise errors rather than printing to the deprecation stream' do
|
1808
|
+
config.deprecation_stream = stream = StringIO.new
|
1809
|
+
config.raise_errors_for_deprecations!
|
1810
|
+
|
1811
|
+
expect {
|
1812
|
+
config.reporter.deprecation(:deprecated => "foo", :call_site => "foo.rb:1")
|
1813
|
+
}.to raise_error(RSpec::Core::DeprecationError, /foo is deprecated/)
|
1814
|
+
|
1815
|
+
expect(stream.string).to eq("")
|
1816
|
+
end
|
1817
|
+
end
|
1818
|
+
|
1819
|
+
describe "#expose_current_running_example_as" do
|
1820
|
+
before { stub_const(Configuration::ExposeCurrentExample.name, Module.new) }
|
1821
|
+
|
1822
|
+
it 'exposes the current example via the named method' do
|
1823
|
+
RSpec.configuration.expose_current_running_example_as :the_example
|
1824
|
+
RSpec.configuration.expose_current_running_example_as :another_example_helper
|
1825
|
+
|
1826
|
+
value_1 = value_2 = nil
|
1827
|
+
|
1828
|
+
ExampleGroup.describe "Group" do
|
1829
|
+
it "works" do
|
1830
|
+
value_1 = the_example
|
1831
|
+
value_2 = another_example_helper
|
1832
|
+
end
|
1833
|
+
end.run
|
1834
|
+
|
1835
|
+
expect(value_1).to be_an(RSpec::Core::Example)
|
1836
|
+
expect(value_1.description).to eq("works")
|
1837
|
+
expect(value_2).to be(value_1)
|
1838
|
+
end
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
describe '#disable_monkey_patching!' do
|
1842
|
+
let!(:config) { RSpec.configuration }
|
1843
|
+
let!(:expectations) { RSpec::Expectations }
|
1844
|
+
let!(:mocks) { RSpec::Mocks }
|
1845
|
+
|
1846
|
+
def in_fully_monkey_patched_rspec_environment
|
1847
|
+
in_sub_process do
|
1848
|
+
config.expose_dsl_globally = true
|
1849
|
+
mocks.configuration.syntax = [:expect, :should]
|
1850
|
+
mocks.configuration.patch_marshal_to_support_partial_doubles = true
|
1851
|
+
expectations.configuration.syntax = [:expect, :should]
|
1852
|
+
|
1853
|
+
yield
|
1854
|
+
end
|
1855
|
+
end
|
1856
|
+
|
1857
|
+
it 'stops exposing the DSL methods globally' do
|
1858
|
+
in_fully_monkey_patched_rspec_environment do
|
1859
|
+
mod = Module.new
|
1860
|
+
expect {
|
1861
|
+
config.disable_monkey_patching!
|
1862
|
+
}.to change { mod.respond_to?(:describe) }.from(true).to(false)
|
1863
|
+
end
|
1864
|
+
end
|
1865
|
+
|
1866
|
+
it 'stops using should syntax for expectations' do
|
1867
|
+
in_fully_monkey_patched_rspec_environment do
|
1868
|
+
obj = Object.new
|
1869
|
+
config.expect_with :rspec
|
1870
|
+
expect {
|
1871
|
+
config.disable_monkey_patching!
|
1872
|
+
}.to change { obj.respond_to?(:should) }.from(true).to(false)
|
1873
|
+
end
|
1874
|
+
end
|
1875
|
+
|
1876
|
+
it 'stops using should syntax for mocks' do
|
1877
|
+
in_fully_monkey_patched_rspec_environment do
|
1878
|
+
obj = Object.new
|
1879
|
+
config.mock_with :rspec
|
1880
|
+
expect {
|
1881
|
+
config.disable_monkey_patching!
|
1882
|
+
}.to change { obj.respond_to?(:should_receive) }.from(true).to(false)
|
1883
|
+
end
|
1884
|
+
end
|
1885
|
+
|
1886
|
+
it 'stops patching of Marshal' do
|
1887
|
+
in_fully_monkey_patched_rspec_environment do
|
1888
|
+
expect {
|
1889
|
+
config.disable_monkey_patching!
|
1890
|
+
}.to change { Marshal.respond_to?(:dump_with_rspec_mocks) }.from(true).to(false)
|
1891
|
+
end
|
1892
|
+
end
|
1893
|
+
|
1894
|
+
context 'when user did not configure mock framework' do
|
1895
|
+
def emulate_not_configured_mock_framework
|
1896
|
+
in_fully_monkey_patched_rspec_environment do
|
1897
|
+
allow(config).to receive(:rspec_mocks_loaded?).and_return(false, true)
|
1898
|
+
config.instance_variable_set :@mock_framework, nil
|
1899
|
+
ExampleGroup.send :remove_class_variable, :@@example_groups_configured
|
1900
|
+
|
1901
|
+
yield
|
1902
|
+
end
|
1903
|
+
end
|
1904
|
+
|
1905
|
+
it 'disables monkey patching after example groups being configured' do
|
1906
|
+
emulate_not_configured_mock_framework do
|
1907
|
+
obj = Object.new
|
1908
|
+
config.disable_monkey_patching!
|
1909
|
+
|
1910
|
+
expect {
|
1911
|
+
ExampleGroup.ensure_example_groups_are_configured
|
1912
|
+
}.to change { obj.respond_to?(:should_receive) }.from(true).to(false)
|
1913
|
+
end
|
1914
|
+
end
|
1915
|
+
end
|
1916
|
+
|
1917
|
+
context 'when user did not configure expectation framework' do
|
1918
|
+
def emulate_not_configured_expectation_framework
|
1919
|
+
in_fully_monkey_patched_rspec_environment do
|
1920
|
+
allow(config).to receive(:rspec_expectations_loaded?).and_return(false, true)
|
1921
|
+
config.instance_variable_set :@expectation_frameworks, []
|
1922
|
+
ExampleGroup.send :remove_class_variable, :@@example_groups_configured
|
1923
|
+
|
1924
|
+
yield
|
1925
|
+
end
|
1926
|
+
end
|
1927
|
+
|
1928
|
+
it 'disables monkey patching after example groups being configured' do
|
1929
|
+
emulate_not_configured_expectation_framework do
|
1930
|
+
obj = Object.new
|
1931
|
+
config.disable_monkey_patching!
|
1932
|
+
|
1933
|
+
expect {
|
1934
|
+
ExampleGroup.ensure_example_groups_are_configured
|
1935
|
+
}.to change { obj.respond_to?(:should) }.from(true).to(false)
|
1936
|
+
end
|
1937
|
+
end
|
1938
|
+
end
|
1939
|
+
end
|
1940
|
+
|
1941
|
+
describe 'recording spec start time (for measuring load)' do
|
1942
|
+
it 'returns a time' do
|
1943
|
+
expect(config.start_time).to be_an_instance_of ::Time
|
1944
|
+
end
|
1945
|
+
|
1946
|
+
it 'is configurable' do
|
1947
|
+
config.start_time = 42
|
1948
|
+
expect(config.start_time).to eq 42
|
1949
|
+
end
|
1950
|
+
end
|
1951
|
+
|
1952
|
+
describe "hooks" do
|
1953
|
+
include_examples "warning of deprecated `:example_group` during filtering configuration", :before, :each
|
1954
|
+
end
|
1955
|
+
|
1956
|
+
# assigns files_or_directories_to_run and triggers post-processing
|
1957
|
+
# via `files_to_run`.
|
1958
|
+
def assign_files_or_directories_to_run(*value)
|
1959
|
+
config.files_or_directories_to_run = value
|
1960
|
+
config.files_to_run
|
1961
|
+
end
|
1962
|
+
end
|
1963
|
+
end
|