Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change include? for exclude? on backtrace cleaner

This also removes the helper methods.

Signed-off-by: Sam Phippen <samphippen@googlemail.com>
  • Loading branch information...
commit a14f97fc718dff8f70f19b28cdd958e0a86127db 1 parent d20f78b
@samphippen authored
View
14 lib/rspec/core/backtrace_cleaner.rb
@@ -10,18 +10,8 @@ def initialize(include_patterns, exclude_patterns)
@exclude_patterns = exclude_patterns
end
- def include?(line)
- matches_an_include_pattern? line or not matches_an_exclude_pattern? line
- end
-
- private
-
- def matches_an_include_pattern?(line)
- @include_patterns.any? {|p| line =~ p}
- end
-
- def matches_an_exclude_pattern?(line)
- @exclude_patterns.any? {|p| line =~ p}
+ def exclude?(line)
+ @include_patterns.none? {|p| line =~ p} and @exclude_patterns.any? {|p| line =~ p}
end
end
end
View
2  lib/rspec/core/configuration.rb
@@ -285,7 +285,7 @@ def cleaned_from_backtrace?(line)
# TODO (David 2011-12-25) why are we asking the configuration to do
# stuff? Either use the patterns directly or enapsulate the filtering
# in a BacktraceCleaner object.
- not RSpec::Core::BacktraceCleaner.new(backtrace_include_patterns, backtrace_clean_patterns).include?(line)
+ RSpec::Core::BacktraceCleaner.new(backtrace_include_patterns, backtrace_clean_patterns).exclude?(line)
end
# Returns the configured mock framework adapter module
View
12 spec/rspec/core/backtrace_cleaner_spec.rb
@@ -6,36 +6,36 @@ module RSpec::Core
it "keeps all lines" do
lines = ["/tmp/a_file", "some_random_text", "hello\330\271!"]
cleaner = BacktraceCleaner.new([], [])
- expect(lines.all? {|line| cleaner.include? line}).to be_true
+ expect(lines.all? {|line| cleaner.exclude? line}).to be_false
end
end
context "with a discard pattern but no keep patterns" do
it "discards lines that match the discard pattern" do
cleaner = BacktraceCleaner.new([], [/remove/])
- expect(cleaner.include? "remove me").to be_false
+ expect(cleaner.exclude? "remove me").to be_true
end
it "keeps lines that do not match the discard pattern" do
cleaner = BacktraceCleaner.new([], [/remove/])
- expect(cleaner.include? "apple").to be_true
+ expect(cleaner.exclude? "apple").to be_false
end
end
context "with a discard pattern and a keep pattern" do
it "discards lines that match the discard pattern but not the keep pattern" do
cleaner = BacktraceCleaner.new([/keep/], [/discard/])
- expect(cleaner.include? "discard").to be_false
+ expect(cleaner.exclude? "discard").to be_true
end
it "keeps lines that match the keep pattern and the discard pattern" do
cleaner = BacktraceCleaner.new([/hi/], [/.*/])
- expect(cleaner.include? "hi").to be_true
+ expect(cleaner.exclude? "hi").to be_false
end
it "keeps lines that do not match the keep pattern, but do not match a discard pattern" do
cleaner = BacktraceCleaner.new([/hi/], [/delete/])
- expect(cleaner.include? "fish").to be_true
+ expect(cleaner.exclude? "fish").to be_false
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.