Sha256: 25876ba467f3ea0d5e2934bcf52ca94467321658e8d0cc0da02bd8a927b93fba

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')


describe Zoomit::Content do
  
  describe ".find" do
    
    it "should return a Zoomit Response object" do
      mock_get(200, 'zoomit_create_url.response')
      response = Zoomit::Content.find('7nA')
      response.class.should == Zoomit::Response
    end
    
    it "should raise a Zoomit::NotFoundError if a content element could not be found" do
      mock_get(404)
      lambda { Zoomit::Content.find('f4444444444iL') }.should raise_error(Zoomit::NotFoundError)
    end
    
    it "should raise a Zoomit::ServerError if zoom.it fails" do
      mock_get(500)
      lambda { Zoomit::Content.find('7nA') }.should raise_error(Zoomit::ServerError)
    end
    
    it "should raise a Zoomit::UnavailableError if zoom.it can't scale" do
      mock_get(503)
      lambda { Zoomit::Content.find('7nA') }.should raise_error(Zoomit::UnavailableError)
    end
    
  end
  
  
  describe ".create / .find_by_url" do
    
    it "should return a Zoomit Response object" do
      mock_get(200, 'zoomit_create_url.response')
      response = Zoomit::Content.create('http://www.mit2m.de')
      response.class.should == Zoomit::Response
    end
    
    it "should raise a Zoomit::BadRequestError if an invalid url is passed" do
      mock_get(400)
      lambda { Zoomit::Content.create('htp:/f41L.org') }.should raise_error(Zoomit::BadRequestError)
    end
    
    it "should raise a Zoomit::ServerError if zoom.it fails" do
      mock_get(500)
      lambda { Zoomit::Content.create('htp:/f41L.org') }.should raise_error(Zoomit::ServerError)
    end
    
    it "should raise a Zoomit::UnavailableError if zoom.it can't scale" do
      mock_get(503)
      lambda { Zoomit::Content.create('http:/overload.org') }.should raise_error(Zoomit::UnavailableError)
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zoomit-0.0.2 spec/zoomit/content_spec.rb
zoomit-0.0.1 spec/zoomit/content_spec.rb