diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 4dbd7ea13a..71dd056218 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -90,7 +90,7 @@ def self.add_setting(name, opts={}) # To override this behavior and display a full backtrace, use # `--backtrace` on the command line, in a `.rspec` file, or in the # `rspec_options` attribute of RSpec's rake task. - add_setting :backtrace_clean_patterns + add_setting :backtrace_exclude_patterns add_setting :backtrace_include_patterns # Path to use if no path is provided to the `rspec` command (default: @@ -194,6 +194,8 @@ def self.add_setting(name, opts={}) /lib\/rspec\/(core|expectations|matchers|mocks)/ ] + attr_reader :backtrace_cleaner + def initialize @expectation_frameworks = [] @include_or_extend_modules = [] @@ -203,8 +205,11 @@ def initialize @color = false @pattern = '**/*_spec.rb' @failure_exit_code = 1 - @backtrace_clean_patterns = DEFAULT_BACKTRACE_PATTERNS.dup + + @backtrace_exclude_patterns = DEFAULT_BACKTRACE_PATTERNS.dup @backtrace_include_patterns = [Regexp.new(Dir.getwd)] + recreate_backtrace_cleaner + @default_path = 'spec' @filter_manager = FilterManager.new @preferred_options = {} @@ -299,6 +304,37 @@ def mock_framework=(framework) mock_with framework end + def backtrace_clean_patterns + RSpec.deprecate("RSpec::Core::Configuration#backtrace_clean_patterns", + "RSpec::Core::Configuration#backtrace_exclude_patterns") + backtrace_exclude_patterns + end + + def backtrace_clean_patterns=(patterns) + RSpec.deprecate("RSpec::Core::Configuration#backtrace_clean_patterns", + "RSpec::Core::Configuration#backtrace_exclude_patterns") + backtrace_exclude_patterns = patterns + recreate_backtrace_cleaner + end + + def backtrace_include_patterns + @backtrace_include_patterns + end + + def backtrace_include_patterns=(patterns) + @backtrace_include_patterns = patterns + recreate_backtrace_cleaner + end + + def backtrace_exclude_patterns + @backtrace_exclude_patterns + end + + def backtrace_exclude_patterns=(patterns) + @backtrace_exclude_patterns = patterns + recreate_backtrace_cleaner + end + # Sets the mock framework adapter module. # # `framework` can be a Symbol or a Module. @@ -428,7 +464,7 @@ def expect_with(*frameworks) end def full_backtrace=(true_or_false) - @backtrace_clean_patterns = true_or_false ? [] : DEFAULT_BACKTRACE_PATTERNS + @backtrace_exclude_patterns = true_or_false ? [] : DEFAULT_BACKTRACE_PATTERNS end def color(output=output_stream) @@ -945,6 +981,10 @@ def order_groups_and_examples(&block) private + def recreate_backtrace_cleaner + @backtrace_cleaner = BacktraceCleaner.new(@backtrace_include_patterns, @backtrace_exclude_patterns) + end + def get_files_to_run(paths) patterns = pattern.split(",") paths.map do |path| diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index 9b8c5889de..fcf1371359 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -962,6 +962,14 @@ def metadata_hash(*args) end end + describe "#backtrace_clean_patterns" do + it "is deprecated" do + RSpec.should_receive(:warn_deprecation) + config = Configuration.new + config.backtrace_clean_patterns + end + end + describe "#cleaned_from_backtrace? defaults" do it "returns true for rspec files" do expect(config.cleaned_from_backtrace?("lib/rspec/core.rb")).to be_true