1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Merge remote-tracking branch 'pchambino/payload_to_s' into ab-urlparams

Conflicts:
	lib/restclient/payload.rb
This commit is contained in:
Andy Brody 2015-11-16 02:42:14 -08:00
commit 014e421bfc
2 changed files with 14 additions and 4 deletions

View file

@ -64,7 +64,11 @@ module RestClient
@stream.read(*args)
end
alias :to_s :read
def to_s
result = read
@stream.seek(0)
result
end
# Flatten parameters by converting hashes of hashes to flat hashes
# {keys1 => {keys2 => value}} will be transformed into [keys1[key2], value]
@ -113,9 +117,7 @@ module RestClient
def inspect
# TODO: make this not pretend to be a string (ugh)
result = to_s.inspect
@stream.seek(0)
result
to_s.inspect
end
def short_inspect

View file

@ -3,6 +3,14 @@
require_relative '_lib'
describe RestClient::Payload do
context "Base Payload" do
it "should reset stream after to_s" do
payload = RestClient::Payload::Base.new('foobar')
payload.to_s.should eq 'foobar'
payload.to_s.should eq 'foobar'
end
end
context "A regular Payload" do
it "should use standard enctype as default content-type" do
RestClient::Payload::UrlEncoded.new({}).headers['Content-Type'].