Sha256: b83bab27efe4c3d606673db95e8c9849f63aff5f491828d5c431a6eb8072d45c

Contents?: true

Size: 1.75 KB

Versions: 52

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/common', __FILE__)

describe "Exception#backtrace" do
  before(:each) do
    @backtrace = ExceptionSpecs::Backtrace.backtrace
  end

  it "returns nil if no backtrace was set" do
    Exception.new.backtrace.should be_nil
  end

  it "returns an Array" do
    @backtrace.should be_an_instance_of(Array)
  end

  it "sets each element to a String" do
    @backtrace.each {|l| l.should be_an_instance_of(String)}
  end

  it "includes the filename of the location where self raised in the first element" do
    @backtrace.first.should =~ /common\.rb/
  end

  it "includes the line number of the location where self raised in the first element" do
    @backtrace.first.should =~ /:22:in /
  end

  it "includes the name of the method from where self raised in the first element" do
    @backtrace.first.should =~ /in `backtrace'/
  end

  it "includes the filename of the location immediately prior to where self raised in the second element" do
    @backtrace[1].should =~ /backtrace_spec\.rb/
  end

  it "includes the line number of the location immediately prior to where self raised in the second element" do
    @backtrace[1].should =~ /:6(:in )?/
  end

  it "contains lines of the same format for each prior position in the stack" do
    @backtrace[2..-1].each do |line|
      # This regexp is deliberately imprecise to account for 1.9 using
      # absolute paths where 1.8 used relative paths, the need to abstract out
      # the paths of the included mspec files, the differences in output
      # between 1.8 and 1.9, and the desire to avoid specifying in any
      # detail what the in `...' portion looks like.
      line.should =~ /^[^ ]+\:\d+(:in `[^`]+')?$/
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/exception/backtrace_spec.rb