Sha256: 7df1b7d7e8b13c64019a1aec258a2689f3f6816ba03039bde32549120137c731

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Exception, :unless => defined?(BindingOfCaller) do
  should { respond_to :__honeybadger_bindings_stack }
  its(:__honeybadger_bindings_stack) { should eq([]) }
end

describe Exception, :if => defined?(BindingOfCaller) do
  describe "#set_backtrace" do
    context "call stack does not match current file" do
      it "changes the bindings stack" do
        expect { subject.set_backtrace(['foo.rb:1']) }.to change(subject, :__honeybadger_bindings_stack).from([])
      end
    end

    context "call stack includes current file" do
      before do
        subject.stub(:caller).and_return(["#{File.expand_path('../../../lib/honeybadger/exception_extensions.rb', __FILE__)}:1"])
      end

      it "does not change the bindings stack" do
        expect { subject.set_backtrace(['foo.rb:1']) }.not_to change(subject, :__honeybadger_bindings_stack).from([])
      end
    end

    context "call stack includes a non-matching line" do
      before do
        subject.stub(:caller).and_return(['(foo)'])
      end

      it "skips the non-matching line" do
        expect { subject.set_backtrace(['foo.rb:1']) }.not_to raise_error
      end

      it "changes the bindings stack" do
        expect { subject.set_backtrace(['foo.rb:1']) }.to change(subject, :__honeybadger_bindings_stack).from([])
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
honeybadger-1.16.2 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.16.1 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.16.0 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.15.3 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.15.2 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.15.1 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.15.0 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.14.0 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.12.0.beta3 spec/honeybadger/exception_extensions_spec.rb
honeybadger-1.12.0.beta2 spec/honeybadger/exception_extensions_spec.rb