Sha256: 917c59b968378c4dbca7d1e82064476b3317e8ca8969ffffa4f854b93a5b4f2b

Contents?: true

Size: 1.43 KB

Versions: 19

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'
SearchResponse = Struct.new(:body)

describe Infoblox::Search, ".find" do
  it "searches correctly" do
    conn = double

    # empty response
    return_json = SearchResponse.new("[]")
    uri = Infoblox.base_path + Infoblox::Search.wapi_object
    allow(conn).to receive(:get).with(uri, {"search_string~" => "foo"}).and_return(return_json)
    expect(Infoblox::Search.find(conn, "search_string~" => "foo")).to eq([])

    # response with host
    return_json = SearchResponse.new('[
      {
        "_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmdkaS50b3BzLmRtei1tYWlsc2VuZGVycy5xYy1nb3ZpcG10YTItZXA:foo-bar-baz.inner.domain/Organization",
        "ipv4addrs": [
            {
                "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuZ2RpLnRvcHMuZG16LW1haWxzZW5kZXJzLnFjLWdvdmlwbXRhMi1lcC4xNzIuMjQuNC4xODQu:10.10.10.10/foo-bar-baz.inner.domain/Organization",
                "configure_for_dhcp": false,
                "host": "foo-bar-baz.inner.domain",
                "ipv4addr": "10.10.10.10"
            }
        ],
        "name": "foo-bar-baz.inner.domain",
        "view": "Organization"
      }
    ]')
    allow(conn).to receive(:get).with(uri, {"search_string~" => "foo"}).and_return(return_json)
    result = Infoblox::Search.find(conn, "search_string~" => "foo")
    expect(result[0]).to be_a(Infoblox::Host)
    host = result[0]
    expect(host.name).to eq("foo-bar-baz.inner.domain")
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
infoblox-3.0.0 spec/search_spec.rb
infoblox-2.0.5 spec/search_spec.rb
infoblox-2.0.4 spec/search_spec.rb
infoblox-2.0.3 spec/search_spec.rb
infoblox-2.0.2 spec/search_spec.rb
infoblox-2.0.1 spec/search_spec.rb
infoblox-2.0.0 spec/search_spec.rb
infoblox-1.0.1 spec/search_spec.rb
infoblox-1.0.0 spec/search_spec.rb
infoblox-0.5.3 spec/search_spec.rb
infoblox-0.5.2 spec/search_spec.rb
infoblox-0.5.1 spec/search_spec.rb
infoblox-0.5.0 spec/search_spec.rb
infoblox-0.4.1 spec/search_spec.rb
infoblox-0.4.0 spec/search_spec.rb
infoblox-0.3.3 spec/search_spec.rb
infoblox-0.3.2 spec/search_spec.rb
infoblox-0.3.1 spec/search_spec.rb
infoblox-0.3.0 spec/search_spec.rb