Sha256: 1813220dcbc7722a9994756c30079bfd5be5abd981c5e90c874584af4138ad6f

Contents?: true

Size: 1.71 KB

Versions: 53

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8
require 'spec_helper'

unless RUBY_VERSION.start_with?('1.8')
  require 'rollbar/encoding/encoder'

  describe Rollbar::Encoding::Encoder do
    subject { described_class.new(object) }

    shared_examples 'encoding' do
      it 'encodes ir properly' do
        value = subject.encode

        expect(value).to be_eql(expected)
      end
    end

    describe '#encode' do
      context 'with ascii chars at end of string' do
        it_behaves_like 'encoding' do
          let(:object) { force_to_ascii("bad value 1\255") }
          let(:expected) { 'bad value 1' }
        end
      end

      context 'with ascii chars at middle of string' do
        it_behaves_like 'encoding' do
          let(:object) { force_to_ascii("bad\255 value 2") }
          let(:expected) { 'bad value 2' }
        end
      end

      context 'with ascii chars at end of string' do
        it_behaves_like 'encoding' do
          let(:object) { force_to_ascii("bad value 3\255") }
          let(:expected) { 'bad value 3' }
        end
      end

      context '0xa0 char in exception object' do
        it_behaves_like 'encoding' do
          let(:object) { "foo \xa0".force_encoding(::Encoding::ISO_8859_1) }
          let(:expected) { "foo " }
        end
      end

      context 'with bad symbol' do
        it_behaves_like 'encoding' do
          let(:bad_string) { force_to_ascii("inner \x92bad key") }
          let(:object) { bad_string.to_sym }
          let(:expected) { :"inner bad key" }
        end
      end

      context 'with russian chars in string' do
        it_behaves_like 'encoding' do
          let(:object) { 'Изменение' }
          let(:expected) { 'Изменение' }
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
rollbar-2.5.2 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.5.1 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.5.0 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.4.0 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.3.0 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.2.1 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.2.0 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.1.2 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.1.1 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.1.0 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.0.2 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.0.1 spec/rollbar/encoding/encoder_spec.rb
rollbar-2.0.0 spec/rollbar/encoding/encoder_spec.rb