1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
require "spec_helper"
module RSpec::Core
describe BacktraceCleaner do
context "with no patterns" do
it "keeps all lines" do
lines = ["/tmp/a_file", "some_random_text", "hello\330\271!"]
cleaner = BacktraceCleaner.new([], [])
expect(lines.all? {|line| cleaner.exclude? line}).to be_false
end
it 'is considered a full backtrace' do
expect(BacktraceCleaner.new([], []).full_backtrace?).to be_true
end
end
context "with an exclusion pattern but no inclusion patterns" do
it "excludes lines that match the exclusion pattern" do
cleaner = BacktraceCleaner.new([], [/remove/])
expect(cleaner.exclude? "remove me").to be_true
end
it "keeps lines that do not match the exclusion pattern" do
cleaner = BacktraceCleaner.new([], [/remove/])
expect(cleaner.exclude? "apple").to be_false
end
it 'is considered a partial backtrace' do
expect(BacktraceCleaner.new([], [/remove/]).full_backtrace?).to be_false
end
end
context "with an exclusion pattern and an inclusion pattern" do
it "excludes lines that match the exclusion pattern but not the inclusion pattern" do
cleaner = BacktraceCleaner.new([/keep/], [/discard/])
expect(cleaner.exclude? "discard").to be_true
end
it "keeps lines that match the inclusion pattern and the exclusion pattern" do
cleaner = BacktraceCleaner.new([/hi/], [/.*/])
expect(cleaner.exclude? "hi").to be_false
end
it "keeps lines that match neither pattern" do
cleaner = BacktraceCleaner.new([/hi/], [/delete/])
expect(cleaner.exclude? "fish").to be_false
end
it 'is considered a partial backtrace' do
expect(BacktraceCleaner.new([], [/remove/]).full_backtrace?).to be_false
end
end
context "with an exclusion pattern that matches the current working directory" do
it "defaults to having one inclusion pattern, the current working directory" do
cleaner = BacktraceCleaner.new(nil, [/.*/])
expect(Dir.getwd =~ cleaner.inclusion_patterns.first).to be_true
end
end
context "with an exclusion pattern that does not match the current working directory" do
it "defaults to having no exclusion patterns" do
cleaner = BacktraceCleaner.new(nil, [/i_wont_match_a_directory/])
expect(cleaner.inclusion_patterns.length).to be_zero
end
end
end
end
|