Sha256: 815757e848e7cb75b63498efdc874d8eda29f36fdea659bf24b3f7bb700f7e7c

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe "Search API operations", type: "acceptance" do
  let(:server_url) { "https://api.opscode.com" }
  let(:client_name) { "reset" }
  let(:client_key) { "/Users/reset/.chef/reset.pem" }
  let(:organization) { "ridley" }

  let(:connection) do
    Ridley.connection(
      server_url: server_url,
      client_name: client_name,
      client_key: client_key,
      organization: organization
    )
  end

  before(:all) { WebMock.allow_net_connect! }
  after(:all) { WebMock.disable_net_connect! }

  describe "listing indexes" do
    it "returns an array of indexes" do
      indexes = connection.search_indexes

      indexes.should include(:role)
      indexes.should include(:node)
      indexes.should include(:client)
    end
  end

  describe "showing an index" do
    before(:each) do
      @result = connection.search(:node)
    end

    it "returns a hash with a total key" do
      @result.should have_key(:total)
    end

    it "returns a hash with a start key" do
      @result.should have_key(:start)
    end

    it "returns a hash with a rows key" do
      @result.should have_key(:rows)
    end
  end

  describe "searching an index that doesn't exist" do
    it "it raises a Ridley::Errors::HTTPNotFound error" do
      lambda {
        connection.search(:notthere)
      }.should raise_error(Ridley::Errors::HTTPNotFound)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ridley-0.0.6 spec/acceptance/search_resource_spec.rb
ridley-0.0.5 spec/acceptance/search_resource_spec.rb
ridley-0.0.4 spec/acceptance/search_resource_spec.rb
ridley-0.0.3 spec/acceptance/search_resource_spec.rb