Sha256: f8c49453a5c42235f47064967229c4d66ed9401d5abd04eae2aee40aba82d660

Contents?: true

Size: 752 Bytes

Versions: 2

Compression:

Stored size: 752 Bytes

Contents

require 'spec_helper'

describe ApiClient do
  describe "#get" do
    context "when response code is 404" do
      before :each do
        FakeWeb.register_uri(:get, "http://api.example.com/user/5", :status => "404")
      end

      it "should return a NotFound exception" do
        lambda { ApiClient.get('http://api.example.com/user/5') }.should raise_error(ApiClient::Exceptions::NotFound)
      end
    end

    context "when response code is not 404" do
      before :each do
        FakeWeb.register_uri(:get, "http://api.example.com/user/5", :status => "201", :body => "User#3333")
      end

      it "should return the response body" do
        ApiClient.get('http://api.example.com/user/5').should == "User#3333"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api-client-0.1.0 spec/api_client_spec.rb
api-client-0.0.1 spec/api_client_spec.rb