Sha256: 935e6ed80889c735653c82358004a02fbfebb5eef50e2fa0ad145912bd463e8e

Contents?: true

Size: 991 Bytes

Versions: 4

Compression:

Stored size: 991 Bytes

Contents

require 'core/spec_helper'

describe ZendeskAPI::Middleware::Response::RaiseError do
  before(:each) do
    stub_request(:any, /.*/).to_return(:status => status)
  end

  context "with status = 404" do
    let(:status) { 404 }

    it "should raise RecordNotFound when status is 404" do
      expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::RecordNotFound)
    end
  end

  context "with status in 400...600" do
    let(:status) { 500 }

    it "should raise NetworkError" do
      expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
    end
  end

  context "with status = 422" do
    let(:status) { 422 }

    it "should raise RecordInvalid" do
      expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::RecordInvalid)
    end
  end

  context "with status = 200" do
    let(:status) { 200 }

    it "should not raise" do
      client.connection.get "/abcdef"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk_api-1.0.0 spec/core/middleware/response/raise_error_spec.rb
zendesk_api-0.4.0.rc3 spec/core/middleware/response/raise_error_spec.rb
zendesk_api-0.4.0.rc2 spec/core/middleware/response/raise_error_spec.rb
zendesk_api-0.4.0.rc1 spec/core/middleware/response/raise_error_spec.rb