Sha256: 8e643b00b93a722ee7a193c71d562cded4e12d0106a741d8327c115b90437d81

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

describe GCMMiddleware do
  context 'authentication' do
    let(:faraday) do
      Faraday.new('http://www.example.com') do |f|
        f.request :gcm_authentication, key: 'my-api-key'

        f.adapter :test do |stub|
          stub.get('/test') { |env| [ 200, {}, {} ] }
        end
      end
    end

    it 'registers :gcm_authentication' do
      response = faraday.get('test')
      expect(response.env.request_headers['Authorization']).to eq 'key=my-api-key'
    end
  end

  context 'canonical id' do
    let(:faraday) do
      Faraday.new('http://www.example.com') do |f|
        f.use :gcm_canonical_id

        f.adapter :test do |stub|
          stub.post('/gcm/send') { |env| [ 200, {}, {'results' => [{}]} ] }
        end
      end
    end

    it 'registers :gcm_canonical_id' do
      response = faraday.post('/gcm/send', { 'registration_ids' => ['1'] })

      expect(response.body['results'][0]['original_id']).to eq '1'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gcm_middleware-0.0.4 spec/gcm_middleware_spec.rb
gcm_middleware-0.0.3 spec/gcm_middleware_spec.rb