Skip to content
This repository
tree: 78051dd3fb
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 43 lines (36 sloc) 1.434 kb
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
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
    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.exclude? "remove me").to be_true
      end

      it "keeps lines that do not match the discard pattern" do
        cleaner = BacktraceCleaner.new([], [/remove/])
        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.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.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
    end
  end
end
Something went wrong with that request. Please try again.