Sha256: 714acc6df15dcb57b022e59abc3183149e0dde785b8ff5974549431cb32b314f

Contents?: true

Size: 1.64 KB

Versions: 35

Compression:

Stored size: 1.64 KB

Contents

require File.dirname(__FILE__) + '/base'

describe RestClient::Exception do
	it "sets the exception message to ErrorMessage" do
		RestClient::ResourceNotFound.new.message.should == 'Resource not found'
	end

	it "contains exceptions in RestClient" do
		RestClient::Unauthorized.new.should be_a_kind_of(RestClient::Exception)
		RestClient::ServerBrokeConnection.new.should be_a_kind_of(RestClient::Exception)
	end
end

describe RestClient::RequestFailed do
	it "stores the http response on the exception" do
		begin
			raise RestClient::RequestFailed, :response
		rescue RestClient::RequestFailed => e
			e.response.should == :response
		end
	end

	it "http_code convenience method for fetching the code as an integer" do
		RestClient::RequestFailed.new(mock('res', :code => '502')).http_code.should == 502
	end

	it "shows the status code in the message" do
		RestClient::RequestFailed.new(mock('res', :code => '502')).to_s.should match(/502/)
	end
end

describe RestClient::ResourceNotFound do
	it "also has the http response attached" do
		begin
			raise RestClient::ResourceNotFound, :response
		rescue RestClient::ResourceNotFound => e
			e.response.should == :response
		end
	end
end

describe "backwards compatibility" do
	it "alias RestClient::Request::Redirect to RestClient::Redirect" do
		RestClient::Request::Redirect.should == RestClient::Redirect
	end

	it "alias RestClient::Request::Unauthorized to RestClient::Unauthorized" do
		RestClient::Request::Unauthorized.should == RestClient::Unauthorized
	end

	it "alias RestClient::Request::RequestFailed to RestClient::RequestFailed" do
		RestClient::Request::RequestFailed.should == RestClient::RequestFailed
	end
end

Version data entries

35 entries across 35 versions & 8 rubygems

Version Path
adamwiggins-rest-client-0.9.1 spec/exceptions_spec.rb
adamwiggins-rest-client-0.9.2 spec/exceptions_spec.rb
adamwiggins-rest-client-0.9 spec/exceptions_spec.rb
adamwiggins-rest-client-1.0.1 spec/exceptions_spec.rb
adamwiggins-rest-client-1.0.2 spec/exceptions_spec.rb
adamwiggins-rest-client-1.0 spec/exceptions_spec.rb
auser-poolparty-1.2.10 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-poolparty-1.2.3 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-poolparty-1.2.4 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-poolparty-1.2.7 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-poolparty-1.2.8 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-poolparty-1.2.9 vendor/gems/rest-client/spec/exceptions_spec.rb
auser-rest-client-1.0.1 spec/exceptions_spec.rb
auser-rest-client-1.0 spec/exceptions_spec.rb
benschwarz-smoke-0.5.2 vendor/rest-client-1.0.1/spec/exceptions_spec.rb
benschwarz-smoke-0.5.3 vendor/rest-client-1.0.1/spec/exceptions_spec.rb
benschwarz-smoke-0.5.4 vendor/rest-client-1.0.1/spec/exceptions_spec.rb
benschwarz-smoke-0.5.5 vendor/rest-client-1.0.1/spec/exceptions_spec.rb
benschwarz-smoke-0.5.6 vendor/rest-client-1.0.1/spec/exceptions_spec.rb
benschwarz-smoke-0.5.7 vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb