From 7885c070d83b090662aaea7548a4fc57bc2141e4 Mon Sep 17 00:00:00 2001 From: Michael Sievers Date: Thu, 16 Oct 2014 14:39:12 +0200 Subject: [PATCH] Added 'query' to available attribute writers so it can be set during with 'new' --- lib/httpi/request.rb | 2 +- spec/httpi/request_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/httpi/request.rb b/lib/httpi/request.rb index 3a8a3b4..4942ee5 100644 --- a/lib/httpi/request.rb +++ b/lib/httpi/request.rb @@ -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 = {}) diff --git a/spec/httpi/request_spec.rb b/spec/httpi/request_spec.rb index 4e3512e..9184d0a 100644 --- a/spec/httpi/request_spec.rb +++ b/spec/httpi/request_spec.rb @@ -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