Sha256: 4d450c3f4d00fd60ab8c68bce4a122904801fb6a034ae4e7f57ab0c76b4919c2

Contents?: true

Size: 1.95 KB

Versions: 58

Compression:

Stored size: 1.95 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
  module Runner
    describe "QuietBacktraceTweaker" do
      before(:each) do
        @error = RuntimeError.new
        @tweaker = QuietBacktraceTweaker.new
      end

      it "should not barf on nil backtrace" do
        lambda do
          @tweaker.tweak_backtrace(@error)
        end.should_not raise_error
      end

      it "should remove anything from textmate ruby bundle" do
        @error.set_backtrace(["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"])
        @tweaker.tweak_backtrace(@error)
        @error.backtrace.should be_empty
      end

      it "should remove anything in lib spec dir" do
        ["expectations", "mocks", "runner"].each do |child|
          element="/lib/spec/#{child}/anything.rb"
          @error.set_backtrace([element])
          @tweaker.tweak_backtrace(@error)
          unless (@error.backtrace.empty?)
            raise("Should have tweaked away '#{element}'")
          end
        end
      end

      it "should remove mock_frameworks/rspec" do
        element = "mock_frameworks/rspec"
        @error.set_backtrace([element])
        @tweaker.tweak_backtrace(@error)
        unless (@error.backtrace.empty?)
          raise("Should have tweaked away '#{element}'")
        end
      end

      it "should remove bin spec" do
        @error.set_backtrace(["bin/spec:"])
        @tweaker.tweak_backtrace(@error)
        @error.backtrace.should be_empty
      end
      
      it "should clean up double slashes" do
        @error.set_backtrace(["/a//b/c//d.rb"])
        @tweaker.tweak_backtrace(@error)
        @error.backtrace.should include("/a/b/c/d.rb")
      end

      it "should gracefully handle backtraces with newlines" do
        @error.set_backtrace(["we like\nbin/spec:\nnewlines"])
        @tweaker.tweak_backtrace(@error)
        @error.backtrace.should include("we like\nnewlines")
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.4 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.5 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.6 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11.7 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.1 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.13 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.2 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.3 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.4 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.5 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.6 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/runner/quiet_backtrace_tweaker_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/runner/quiet_backtrace_tweaker_spec.rb