Sha256: c324937020f308f63b5dbdc51a9106aaf5f700ec1bb8abb57aeb96e6dff8245d

Contents?: true

Size: 1.78 KB

Versions: 55

Compression:

Stored size: 1.78 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")

module RR
  module Errors
    describe RRError do
      describe "#backtrace" do
        before do
          @original_trim_backtrace = RR.trim_backtrace
        end
        after do
          RR.trim_backtrace = @original_trim_backtrace
        end

        it "does not include the rr library files when trim_backtrace is true" do
          RR.trim_backtrace = true

          error = nil
          begin
            obj = Object.new
            mock(obj).foobar
            RR.verify_double(obj, :foobar)
          rescue RRError=> e
            error = e
          end
          backtrace = error.backtrace.join("\n")

          backtrace.should_not include("lib/rr")
        end

        it "includes the rr library files when trim_backtrace is false" do
          RR.trim_backtrace = false

          error = nil
          begin
            obj = Object.new
            mock(obj).foobar
            RR.verify_double(obj, :foobar)
          rescue RRError=> e
            error = e
          end
          backtrace = error.backtrace.join("\n")

          backtrace.should include("lib/rr")
        end

        it "returns custom backtrace when backtrace is set" do
          error = RRError.new
          custom_backtrace = caller
          error.backtrace = custom_backtrace
          error.backtrace.should == custom_backtrace
        end

        it "returns normal backtrace when backtrace is not set" do
          error = nil
          expected_line = __LINE__ + 2
          begin
            raise RRError
          rescue RRError => e
            error = e
          end
          error.backtrace.first.should include(__FILE__)
          error.backtrace.first.should include(expected_line.to_s)
        end
      end
    end
  end
end

Version data entries

55 entries across 51 versions & 9 rubygems

Version Path
adva-0.3.2 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.3.1 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.3.0 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.2.4 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.2.3 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.2.2 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.2.1 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.2.0 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.1.4 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.1.3 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.1.2 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.1.1 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.1.0 test/rr/spec/rr/errors/rr_error_spec.rb
adva-0.0.1 test/rr/spec/rr/errors/rr_error_spec.rb
jferris-rr-0.7.1.0.1239654108 spec/rr/errors/rr_error_spec.rb
redinger-redinger-rr-0.10.3 spec/rr/errors/rr_error_spec.rb
redinger-rr-0.10.4 spec/rr/errors/rr_error_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/errors/rr_error_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/errors/rr_error_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/errors/rr_error_spec.rb