277277 Chef ::Resource ::Link . stub! ( :new ) . and_return ( @current_resource )
278278 @provider . current_resource = @current_resource
279279 @new_resource . stub! ( :to_s ) . and_return ( "link[/tmp/fofile]" )
280+ File . stub! ( :symlink? ) . and_return ( true )
280281 File . stub! ( :exists? ) . and_return ( true )
281282 File . stub! ( :delete ) . and_return ( true )
282283 end
283284
284- describe "when the file exists and is writeable " do
285+ describe "when the file exists" do
285286 before do
286287 File . should_receive ( :exists? ) . with ( "/tmp/fofile-link" ) . and_return ( true )
287- File . should_receive ( :writable? ) . with ( "/tmp/fofile-link" ) . and_return ( true )
288288 end
289289
290290 it "should log an appropriate error message" do
303303 end
304304 end
305305
306- describe "when the file does not exist " do
307- before do
308- File . should_receive ( :exists ? ) . with ( "/tmp/fofile-link" ) . and_return ( false )
306+ describe "when the file exists but is not a symbolic link " do
307+ before ( :each ) do
308+ File . should_receive ( :symlink ? ) . with ( "/tmp/fofile-link" ) . and_return ( false )
309309 end
310310
311- it "should raise a runtime error" do
312- lambda { @provider . action_delete } . should raise_error ( RuntimeError )
311+ it "should raise a Link error" do
312+ lambda { @provider . action_delete } . should raise_error ( Chef :: Exceptions :: Link )
313313 end
314314 end
315315
316- describe "when the file isn't writable " do
316+ describe "when the file does not exist " do
317317 before do
318- File . should_receive ( :writable ? ) . with ( "/tmp/fofile-link" ) . and_return ( false )
318+ File . should_receive ( :exists ? ) . with ( "/tmp/fofile-link" ) . and_return ( false )
319319 end
320320
321- it "should raise a runtime error" do
322- lambda { @provider . action_delete } . should raise_error ( RuntimeError )
321+ it "should not raise a Link error" do
322+ lambda { @provider . action_delete } . should_not raise_error ( Chef :: Exceptions :: Link )
323323 end
324324 end
325+
325326end
0 commit comments