Skip to content

Commit

Permalink
Rename backtrace_clean_patterns to backtrace_exclude_patterns
Browse files Browse the repository at this point in the history
This also deprecates backtrace_clean_patterns

Signed-off-by: Sam Phippen <samphippen@googlemail.com>
  • Loading branch information
Sam Phippen committed Mar 25, 2013
1 parent 78051dd commit ffe7c1f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
46 changes: 43 additions & 3 deletions lib/rspec/core/configuration.rb
Expand Up @@ -90,7 +90,7 @@ def self.add_setting(name, opts={})
# To override this behavior and display a full backtrace, use # To override this behavior and display a full backtrace, use
# `--backtrace` on the command line, in a `.rspec` file, or in the # `--backtrace` on the command line, in a `.rspec` file, or in the
# `rspec_options` attribute of RSpec's rake task. # `rspec_options` attribute of RSpec's rake task.
add_setting :backtrace_clean_patterns add_setting :backtrace_exclude_patterns
add_setting :backtrace_include_patterns add_setting :backtrace_include_patterns


# Path to use if no path is provided to the `rspec` command (default: # Path to use if no path is provided to the `rspec` command (default:
Expand Down Expand Up @@ -194,6 +194,8 @@ def self.add_setting(name, opts={})
/lib\/rspec\/(core|expectations|matchers|mocks)/ /lib\/rspec\/(core|expectations|matchers|mocks)/
] ]


attr_reader :backtrace_cleaner

def initialize def initialize
@expectation_frameworks = [] @expectation_frameworks = []
@include_or_extend_modules = [] @include_or_extend_modules = []
Expand All @@ -203,8 +205,11 @@ def initialize
@color = false @color = false
@pattern = '**/*_spec.rb' @pattern = '**/*_spec.rb'
@failure_exit_code = 1 @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)] @backtrace_include_patterns = [Regexp.new(Dir.getwd)]
recreate_backtrace_cleaner

@default_path = 'spec' @default_path = 'spec'
@filter_manager = FilterManager.new @filter_manager = FilterManager.new
@preferred_options = {} @preferred_options = {}
Expand Down Expand Up @@ -299,6 +304,37 @@ def mock_framework=(framework)
mock_with framework mock_with framework
end 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. # Sets the mock framework adapter module.
# #
# `framework` can be a Symbol or a Module. # `framework` can be a Symbol or a Module.
Expand Down Expand Up @@ -428,7 +464,7 @@ def expect_with(*frameworks)
end end


def full_backtrace=(true_or_false) 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 end


def color(output=output_stream) def color(output=output_stream)
Expand Down Expand Up @@ -945,6 +981,10 @@ def order_groups_and_examples(&block)


private private


def recreate_backtrace_cleaner
@backtrace_cleaner = BacktraceCleaner.new(@backtrace_include_patterns, @backtrace_exclude_patterns)
end

def get_files_to_run(paths) def get_files_to_run(paths)
patterns = pattern.split(",") patterns = pattern.split(",")
paths.map do |path| paths.map do |path|
Expand Down
8 changes: 8 additions & 0 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -962,6 +962,14 @@ def metadata_hash(*args)
end end
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 describe "#cleaned_from_backtrace? defaults" do
it "returns true for rspec files" do it "returns true for rspec files" do
expect(config.cleaned_from_backtrace?("lib/rspec/core.rb")).to be_true expect(config.cleaned_from_backtrace?("lib/rspec/core.rb")).to be_true
Expand Down

0 comments on commit ffe7c1f

Please sign in to comment.