Sha256: 0730dbbcac7e187e22e3e2b44789a3afa624ae197cb4e89e95895010d77ab4ba

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

require 'spec_helper'

describe PictureFrom::Crawlers::TwitterCrawler do

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

    describe 'when some profiles are found' do
      it 'returns an image url' do
        fake('https://twitter.com/g_carreiro', file: 'twitter_crawler.response')

        image_url = subject.image_url_by_username('g_carreiro')

        expect(image_url).to eq('https://pbs.twimg.com/profile_images/524721838002143233/nNdh6ftm_400x400.jpeg')
      end
    end

    describe 'when any profile is found' do
      it 'does not return an image url' do
        fake('https://twitter.com/g_carreiro_fake',
             status: 404,
             message: 'Not Found')

        image_url = subject.image_url_by_username('g_carreiro_fake')

        expect(image_url).to be_nil
      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/crawlers/twitter_crawler_spec.rb
picture_from-1.0.0 spec/lib/picture_from/crawlers/twitter_crawler_spec.rb