Sha256: 99a7444d1ae1201b2af6062fc129338cbbb14a2d2b376f40b3b498b9aacd19fa
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
require 'spec_helper' describe Pixy::Shorten do let(:pixy) { Pixy::Shorten.new('API_KEY', 'https://github.com/narkoz/pixy') } describe "#status" do it "should return a response status" do pixy.status.should == 'ok' end end describe "#long_url" do it "should return a long url" do pixy.long_url.should == 'https://github.com/narkoz/pixy' end end describe "#short_url" do it "should return a short url" do pixy.short_url.should == 'http://p.tl/Us9R' end end describe "#counter" do it "should return a request number" do pixy.counter.should == 12 end end describe "exceptions" do context "when empty long url" do it "should raise EmptyLongUrl" do expect { Pixy::Shorten.new('API_KEY', '') }.to raise_error(Pixy::EmptyLongUrl, "Missing long URL.") end end context "when empty API key" do it "should raise EmptyApiKey" do expect { Pixy::Shorten.new('', 'https://github.com/narkoz/pixy') }.to raise_error(Pixy::EmptyApiKey, "Missing API key.") end end context "when invalid API key" do it "should raise InvalidApiKey" do expect { Pixy::Shorten.new('invalid_API_KEY', 'https://github.com/narkoz/pixy') }.to raise_error(Pixy::InvalidApiKey, "API key is invalid.") end end context "when invalid long url" do it "should raise InvalidLongUrl" do expect { Pixy::Shorten.new('API_KEY', '^_^') }.to raise_error(Pixy::InvalidLongUrl, "The URL can not be shortened.") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pixy-0.1.3 | spec/pixy/shorten_spec.rb |
pixy-0.1.2 | spec/pixy/shorten_spec.rb |