@@ -248,30 +248,26 @@ def do_delete(rev=nil)
248248 end
249249end
250250
251- describe Chef ::CouchDB , "safe_name" do
252- before do
253- @couchdb = mock ( "Chef::CouchDB" , :null_object => true )
254- Chef ::CouchDB . stub! ( :new ) . and_return ( @couchdb )
255- end
256-
257- it "should convert the name to a safe name" do
258- @couchdb . should_receive ( :safe_name ) . with ( "asdf.lol.com" ) . and_return ( "asdf_lol_com" )
259- @couchdb . safe_name ( "asdf.lol.com" )
260- end
261- end
262-
263251describe Chef ::CouchDB , "view_uri" do
264252 before do
265- @couchdb = mock ( "Chef::CouchDB " , :null_object => true )
266- Chef ::CouchDB . stub! ( :new ) . and_return ( @couchdb )
267- Chef ::Config . stub! ( :[] ) . with ( :couchdb_database ) . and_return ( "chef" )
253+ @mock_rest = mock ( "Chef::REST " , :null_object => true , :url => "http://monkeypants" )
254+ Chef ::REST . stub! ( :new ) . and_return ( @mock_rest )
255+ @couchdb = Chef ::CouchDB . new ( "http://localhost" )
268256 end
269257
270258 describe "when the couchdb version is unknown" do
271259 it "should set the couchdb version appropriately" do
272- Chef ::Config . stub! ( :[] ) . with ( :couchdb_version ) . and_return ( nil )
273- Chef ::Config . should_receive ( :couchdb_version ) . and_return ( true )
260+ ov = Chef ::Config [ :couchdb_version ]
261+ Chef ::Config [ :couchdb_version ] = nil
262+ @mock_rest . should_receive ( :run_request ) . with (
263+ :GET ,
264+ URI . parse ( "http://monkeypants/" ) ,
265+ false ,
266+ 10 ,
267+ false
268+ ) . and_return ( { "version" => "0.9" } )
274269 @couchdb . view_uri ( "nodes" , "all" )
270+ Chef ::Config [ :couchdb_version ] = ov
275271 end
276272 end
277273
0 commit comments