PageRenderTime 35ms CodeModel.GetById 17ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/spec/rspec/core/backtrace_cleaner_spec.rb

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