Sha256: b3fb61a9a81952eba6f4c188b493f20f6f75099583be287713f483dc38da3ad0
Contents?: true
Size: 1.26 KB
Versions: 8
Compression:
Stored size: 1.26 KB
Contents
require 'helper' describe Octospy::Shortener do let(:url) { 'https://github.com/linyows/octospy' } describe '.shorten_by_github' do subject { VCR.use_cassette "git.io/#{url.escaping}" do described_class.shorten_by_github url end } it { expect(subject).to be_an_instance_of String } it { expect(subject).to eq 'http://git.io/Pd8gXg' } context 'when it is not in the url of github' do let(:url) { 'https://www.google.co.jp/search?q=octospy' } it { expect(subject).to eq url } end context 'when raise error' do it 'return url of argument' do expect(Faraday).to receive(:new).and_raise Faraday::Error expect(described_class.shorten_by_github url).to eq url end end end describe '.shorten_by_google' do subject { VCR.use_cassette "googleapis.com/urlshortener/#{url.escaping}" do described_class.shorten_by_google url end } it { expect(subject).to be_an_instance_of String } it { expect(subject).to eq 'http://goo.gl/8vrLj' } context 'when raise error' do it 'return url of argument' do expect(Faraday).to receive(:new).and_raise Faraday::Error expect(described_class.shorten_by_google url).to eq url end end end end
Version data entries
8 entries across 8 versions & 1 rubygems