Sha256: 303b582164e1a2e658017fe5f5db1de11674487d76f311d5f44d5c12003776b5

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

require 'rollbar'
require 'rollbar/notifier'

describe Rollbar::Notifier do
  describe '#scope' do
    let(:new_scope) do
      { 'foo' => 'bar' }
    end
    let(:new_config) do
      { 'environment' => 'foo' }
    end

    it 'creates a new notifier with merged scope and configuration' do
      new_notifier = subject.scope(new_scope, new_config)

      expect(new_notifier).not_to be(subject)
      expect(subject.configuration.environment).to be_eql(nil)
      expect(new_notifier.configuration.environment).to be_eql('foo')
      expect(new_notifier.scope_object['foo']).to be_eql('bar')
      expect(new_notifier.configuration).not_to be(subject.configuration)
      expect(new_notifier.scope_object).not_to be(subject.scope_object)
    end
  end

  describe '#scope!' do
    let(:new_scope) do
      { 'foo' => 'bar' }
    end
    let(:new_config) do
      { 'environment' => 'foo' }
    end

    it 'mutates the notifier with a merged scope and configuration' do
      result = subject.scope!(new_scope, new_config)

      expect(result).to be(subject)
      expect(subject.configuration.environment).to be_eql('foo')
      expect(subject.scope_object['foo']).to be_eql('bar')
      expect(subject.configuration).to be(subject.configuration)
      expect(subject.scope_object).to be(subject.scope_object)
    end
  end
  
  if RUBY_PLATFORM == 'java'
    describe "#extract_arguments" do
      it "extracts Java exceptions" do
        begin
          raise java.lang.Exception.new("Hello")
        rescue java.lang.Exception => e
          message, exception, extra = Rollbar::Notifier.new.send(:extract_arguments, [e])
          expect(exception).to eq(e)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rollbar-2.16.4 spec/rollbar/notifier_spec.rb
rollbar-2.16.3 spec/rollbar/notifier_spec.rb
rollbar-2.16.2 spec/rollbar/notifier_spec.rb
rollbar-2.16.0 spec/rollbar/notifier_spec.rb
rollbar-2.15.6 spec/rollbar/notifier_spec.rb