Sha256: 02421fe1253937230d14d9e2904a735cd378aee69c66d4091c1916f591e62ced

Contents?: true

Size: 1.73 KB

Versions: 46

Compression:

Stored size: 1.73 KB

Contents

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

describe RestClient do
	describe "API" do
		it "GET" do
			RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {})
			RestClient.get('http://some/resource')
		end

		it "POST" do
			RestClient::Request.should_receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'payload', :headers => {})
			RestClient.post('http://some/resource', 'payload')
		end

		it "PUT" do
			RestClient::Request.should_receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'payload', :headers => {})
			RestClient.put('http://some/resource', 'payload')
		end

		it "DELETE" do
			RestClient::Request.should_receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {})
			RestClient.delete('http://some/resource')
		end

		it "HEAD" do
			RestClient::Request.should_receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {})
			RestClient.head('http://some/resource')
		end
	end

	describe "logging" do
		after do
			RestClient.log = nil
		end

		it "gets the log source from the RESTCLIENT_LOG environment variable" do
			ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return('from env')
			RestClient.log = 'from class method'
			RestClient.log.should == 'from env'
		end

		it "sets a destination for log output, used if no environment variable is set" do
			ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return(nil)
			RestClient.log = 'from class method'
			RestClient.log.should == 'from class method'
		end

		it "returns nil (no logging) if neither are set (default)" do
			ENV.stub!(:[]).with('RESTCLIENT_LOG').and_return(nil)
			RestClient.log.should == nil
		end
	end
end

Version data entries

46 entries across 46 versions & 14 rubygems

Version Path
adamwiggins-rest-client-0.9.1 spec/restclient_spec.rb
adamwiggins-rest-client-0.9.2 spec/restclient_spec.rb
adamwiggins-rest-client-1.0.1 spec/restclient_spec.rb
adamwiggins-rest-client-1.0.2 spec/restclient_spec.rb
adamwiggins-rest-client-1.0.3 spec/restclient_spec.rb
adamwiggins-rest-client-1.0.4 spec/restclient_spec.rb
adamwiggins-rest-client-1.0 spec/restclient_spec.rb
auser-poolparty-1.2.10 vendor/gems/rest-client/spec/restclient_spec.rb
auser-poolparty-1.2.3 vendor/gems/rest-client/spec/restclient_spec.rb
auser-poolparty-1.2.4 vendor/gems/rest-client/spec/restclient_spec.rb
auser-poolparty-1.2.7 vendor/gems/rest-client/spec/restclient_spec.rb
auser-poolparty-1.2.8 vendor/gems/rest-client/spec/restclient_spec.rb
auser-poolparty-1.2.9 vendor/gems/rest-client/spec/restclient_spec.rb
auser-rest-client-1.0.1 spec/restclient_spec.rb
auser-rest-client-1.0 spec/restclient_spec.rb
benschwarz-smoke-0.5.0 vendor/rest-client/spec/restclient_spec.rb
benschwarz-smoke-0.5.1 vendor/rest-client/spec/restclient_spec.rb
benschwarz-smoke-0.5.2 vendor/rest-client-1.0.1/spec/restclient_spec.rb
benschwarz-smoke-0.5.3 vendor/rest-client-1.0.1/spec/restclient_spec.rb
benschwarz-smoke-0.5.4 vendor/rest-client-1.0.1/spec/restclient_spec.rb