Sha256: 544341423e9880e000d41c5b5978f9f2d123e5f05a5d78f89aca3080c1dac015

Contents?: true

Size: 926 Bytes

Versions: 3

Compression:

Stored size: 926 Bytes

Contents

require 'helper'

describe Twitter::Base do
  before do
    @base = Twitter::Base.new(:id => 1)
  end

  describe '#[]' do
    it 'calls methods using [] with symbol' do
      capture_warning do
        expect(@base[:object_id]).to be_an Integer
      end
    end
    it 'calls methods using [] with string' do
      capture_warning do
        expect(@base['object_id']).to be_an Integer
      end
    end
    it 'returns nil for missing method' do
      capture_warning do
        expect(@base[:foo]).to be_nil
        expect(@base['foo']).to be_nil
      end
    end
    it 'outputs a warning' do
      warning = capture_warning do
        @base[:object_id]
      end
      expect(warning).to match(/\[DEPRECATION\] #\[:object_id\] is deprecated. Use #object_id to fetch the value./)
    end
  end

  describe '#attrs' do
    it 'returns a hash of attributes' do
      expect(@base.attrs).to eq(:id => 1)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter-5.11.0 spec/twitter/base_spec.rb
twitter-5.10.0 spec/twitter/base_spec.rb
twitter-5.9.0 spec/twitter/base_spec.rb