spec/httpi/httpi_spec.rb in httpi-2.2.1 vs spec/httpi/httpi_spec.rb in httpi-2.2.3
- old
+ new
@@ -193,16 +193,30 @@
client.delete("http://example.com", :net_http)
end
end
describe ".request" do
+ let(:request) { HTTPI::Request.new('http://example.com') }
+
it "allows custom HTTP methods" do
- request = HTTPI::Request.new("http://example.com")
httpclient.any_instance.expects(:request).with(:custom)
client.request(:custom, request, :httpclient)
end
+
+ it 'follows redirects' do
+ request.follow_redirect = true
+ redirect_location = 'http://foo.bar'
+
+ redirect = HTTPI::Response.new(302, {'location' => redirect_location}, 'Moved')
+ response = HTTPI::Response.new(200, {}, 'success')
+
+ httpclient.any_instance.expects(:request).twice.with(:custom).returns(redirect, response)
+ request.expects(:url=).with(redirect_location)
+
+ client.request(:custom, request, :httpclient)
+ end
end
HTTPI::REQUEST_METHODS.each do |method|
describe ".#{method}" do
let(:request) { HTTPI::Request.new("http://example.com") }
@@ -247,10 +261,10 @@
HTTPI.log = false # disable for specs
end
describe ".log" do
it "defaults to true" do
- expect(HTTPI.log?).to be_true
+ expect(HTTPI.log?).to be_truthy
end
end
describe ".logger" do
it "defaults to Logger writing to STDOUT" do