1+ #
2+ # Author:: AJ Christensen (<aj@junglist.gen.nz>)
3+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4+ # License:: Apache License, Version 2.0
5+ #
6+ # Licensed under the Apache License, Version 2.0 (the "License");
7+ # you may not use this file except in compliance with the License.
8+ # You may obtain a copy of the License at
9+ #
10+ # http://www.apache.org/licenses/LICENSE-2.0
11+ #
12+ # Unless required by applicable law or agreed to in writing, software
13+ # distributed under the License is distributed on an "AS IS" BASIS,
14+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ # See the License for the specific language governing permissions and
16+ # limitations under the License.
17+
18+ require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , ".." , ".." , "spec_helper" ) )
19+
20+ describe Chef ::Application ::Indexer , "initialize" do
21+ before do
22+ @app = Chef ::Application ::Indexer . new
23+ end
24+
25+ it "should create an instance of Chef::Application::Indexer" do
26+ @app . should be_kind_of ( Chef ::Application ::Indexer )
27+ end
28+ end
29+
30+ describe Chef ::Application ::Indexer , "setup_application" do
31+ before do
32+ @chef_searchindex = mock ( "Chef::SearchIndex" , :null_object => true )
33+ Chef ::SearchIndex . stub! ( :new ) . and_return ( @chef_searchindex )
34+ Chef ::Queue . stub! ( :connect ) . and_return ( true )
35+ Chef ::Queue . stub! ( :subscribe ) . and_return ( true )
36+ @app = Chef ::Application ::Indexer . new
37+ end
38+
39+ it "should instantiate a chef::client object" do
40+ Chef ::SearchIndex . should_receive ( :new ) . and_return ( @chef_searchindex )
41+ @app . setup_application
42+ end
43+
44+ it "should connect to the queue" do
45+ Chef ::Queue . should_receive ( :connect ) . and_return ( true )
46+ @app . setup_application
47+ end
48+
49+ it "should subscribe to index" do
50+ Chef ::Queue . should_receive ( :subscribe ) . with ( :queue , "index" ) . and_return ( true )
51+ @app . setup_application
52+ end
53+
54+ it "should subscribe to remove" do
55+ Chef ::Queue . should_receive ( :subscribe ) . with ( :queue , "remove" ) . and_return ( true )
56+ @app . setup_application
57+ end
58+ end
0 commit comments