Skip to content

Commit

Permalink
Merge pull request #133 from msievers/allow_query_parameter_in_reques…
Browse files Browse the repository at this point in the history
…t_new

Add 'query' to available attribute writers so it can be set with 'new'
  • Loading branch information
rogerleite committed Oct 16, 2014
2 parents 733d706 + 7885c07 commit f783a9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/httpi/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module HTTPI
class Request

# Available attribute writers.
ATTRIBUTES = [:url, :proxy, :headers, :body, :open_timeout, :read_timeout, :follow_redirect]
ATTRIBUTES = [:url, :proxy, :headers, :body, :open_timeout, :read_timeout, :follow_redirect, :query]

# Accepts a Hash of +args+ to mass assign attributes and authentication credentials.
def initialize(args = {})
Expand Down
5 changes: 3 additions & 2 deletions spec/httpi/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
end

it "accepts a Hash of accessors to set" do
request = HTTPI::Request.new :url => "http://example.com", :open_timeout => 30
expect(request.url).to eq(URI("http://example.com"))
request = HTTPI::Request.new :url => "http://example.com", :open_timeout => 30, :query => { key: "value" }
expect(request.url).to eq(URI("http://example.com?key=value"))
expect(request.open_timeout).to eq(30)
expect(request.query).to eq("key=value")
end
end

Expand Down

0 comments on commit f783a9c

Please sign in to comment.