Sha256: 47096bcaf7149cfc69b95a7eb635cb6edf2a4263effa91def4c72422323825d5

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

require 'spec_helper'

describe LinkShrink::Request do
  include_examples 'shared_examples'
  before :each do
    LinkShrink.configure { |c| c.api = 'Google'}
  end

  let(:shrinker) { LinkShrink::Config.api }

  describe '.request' do
    it 'is a Typhoeus::Request instance' do
      expect(link_shrink.request(url, shrinker))
      .to be_kind_of(Typhoeus::Response)
    end
  end

  describe '#parse' do
    context 'when response is text/plain' do
      it 'returns response' do
        LinkShrink.configure { |c| c.api = 'TinyUrl' }
        response = link_shrink.request(url, shrinker).body

        expect(link_shrink.parse(response, shrinker))
        .to eq('http://tinyurl.com/1c2')
        LinkShrink.configure { |c| c.api = 'Google' }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
link_shrink-0.0.8 spec/link_shrink/request_spec.rb
link_shrink-0.0.7 spec/link_shrink/request_spec.rb