Skip to content

Commit

Permalink
Introduce Payload::Unspecified to solve:
Browse files Browse the repository at this point in the history
  • Loading branch information
godfat committed Mar 9, 2018
1 parent b62bb3e commit fd822fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rest-builder/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'thread'
require 'weakref'

require 'rest-builder/payload'
require 'rest-builder/promise'
require 'rest-builder/middleware'
require 'rest-builder/engine/dry'
Expand Down Expand Up @@ -200,7 +201,7 @@ def default_env
{REQUEST_METHOD => :get,
REQUEST_PATH => '/' ,
REQUEST_QUERY => {} ,
REQUEST_PAYLOAD => {} ,
REQUEST_PAYLOAD => Payload::Unspecified.new,
REQUEST_HEADERS => {} ,
FAIL => [] ,
LOG => [] ,
Expand Down
2 changes: 2 additions & 0 deletions lib/rest-builder/payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

module RestBuilder
class Payload
Unspecified = Class.new(Hash)

def self.generate_with_headers payload, headers
h = if p = generate(payload)
p.headers.merge(headers)
Expand Down
9 changes: 9 additions & 0 deletions test/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,13 @@ def default_timeout # module defaults could be overriden
should.eq "#{url}?a=b"
simple.wait
end

would 'give unspecified payload like a hash' do
client = RestBuilder::Builder.client{ run RestBuilder::Identity }.new
payload = client.get(url, {},
RestBuilder::RESPONSE_KEY => RestBuilder::REQUEST_PAYLOAD)

payload.should.kind_of?(Hash)
payload.should.kind_of?(RestBuilder::Payload::Unspecified)
end
end

0 comments on commit fd822fa

Please sign in to comment.