Sha256: dc6403fdc561006aeb0d7d50e5955e6ef4e1b08ea12c27d8168034856716469b

Contents?: true

Size: 761 Bytes

Versions: 42

Compression:

Stored size: 761 Bytes

Contents

require 'unit_spec_helper'

describe Rpush::Reflectable do
  class TestReflectable
    include Rpush::Reflectable
  end

  let(:logger) { double(error: nil) }
  let(:test_reflectable) { TestReflectable.new }

  before do
    allow(Rpush.reflection_stack[0]).to receive(:__dispatch)
    allow(Rpush).to receive_messages(logger: logger)
  end

  it 'dispatches the given reflection' do
    expect(Rpush.reflection_stack[0]).to receive(:__dispatch).with(:error)
    test_reflectable.reflect(:error)
  end

  it 'logs errors raised by the reflection' do
    error = StandardError.new
    allow(Rpush.reflection_stack[0]).to receive(:__dispatch).and_raise(error)
    expect(Rpush.logger).to receive(:error).with(error)
    test_reflectable.reflect(:error)
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
rpush-2.3.2-java spec/unit/reflectable_spec.rb
rpush-2.3.2 spec/unit/reflectable_spec.rb