spec/connection_spec.rb in infoblox-0.2.15 vs spec/connection_spec.rb in infoblox-0.2.17

- old
+ new

@@ -1,12 +1,12 @@ require 'spec_helper' describe Infoblox::Connection do ["localhost", "127.0.0.1", "http://localhost:3000", "https://localhost", "http://localhost:3000/"].each do |host| - it "should build URL without failure" do + it "should build URL #{host} without failure" do conn_params = { - username: "billy", + username: "billy", password: "boi", host: host } uri = "/wapi/v1.0/record:host" @@ -17,11 +17,29 @@ # execute the request. There should be no "URI::BadURIError: both URI are relative" error ic.get(uri) end end - def stub_get(uri) + it "should raise Infobloxon invalid response" do + host = 'localhost' + conn_params = { + username: "billy", + password: "boi", + host: host + } + uri = "/wapi/v1.0/record:host" + + ic = Infoblox::Connection.new(conn_params) + ic.adapter = :test + ic.adapter_block = stub_get(uri, 404) + + # execute the request. There should be no "URI::BadURIError: both URI are relative" error + + expect { ic.get(uri) }.to raise_error(Infoblox::Error) + end + + def stub_get(uri, status=200) Proc.new do |stub| - stub.get(uri) { [ 200, {}, 'Yay!'] } + stub.get(uri) { [ status, {}, 'Yay!'] } end end end