Sha256: 49ecbc8b42a498b1456bc0d0022e813b49d72f6ec1d7f382ea1dcf3a7b41f344

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe PictureFrom::Apis::FacebookApi do

  describe '#image_url_by_username' do
    subject { described_class.new }

    describe 'when username is blank' do
      let(:url) { subject.image_url_by_username('') }

      it 'returns nil' do
        fake('http://graph.facebook.com//picture',
             status: 400,
             message: 'Bad Request')

        expect(url).to be_nil
      end
    end

    describe 'when username does not exist' do
      let(:url) { subject.image_url_by_username('g_carreiro') }

      it 'returns nil' do
        fake('http://graph.facebook.com/g_carreiro/picture',
             status: 404,
             message: 'Not Found')

        expect(url).to be_nil
      end
    end

    describe 'when username is valid' do
      let(:url) { subject.image_url_by_username('karreiro') }

      it 'returns a valid url' do
        fake('http://graph.facebook.com/karreiro/picture',
             status: 302,
             message: 'Found',
             location: 'https://fbcdn-profile-a.akamaihd.net/image.png')

        expect(url).to eq('http://graph.facebook.com/karreiro/picture')
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picture_from-1.0.1 spec/lib/picture_from/apis/facebook_api_spec.rb
picture_from-1.0.0 spec/lib/picture_from/apis/facebook_api_spec.rb