Sha256: bc6c681ab261ef3892913f4e7944c78b00be9bc299b1da436a3233f4e3b69eac

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 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
	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

2 entries across 2 versions & 2 rubygems

Version Path
adamwiggins-rest-client-0.9 spec/restclient_spec.rb
rest-client-0.9 spec/restclient_spec.rb