Merge pull request #2146 from reitermarkus/spec-prune
Convert `brew prune` test to spec.
This commit is contained in:
		
						commit
						9010c37ab4
					
				
							
								
								
									
										28
									
								
								Library/Homebrew/test/cmd/prune_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Library/Homebrew/test/cmd/prune_spec.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
describe "brew prune", :integration_test do
 | 
			
		||||
  it "removes empty directories and broken symlinks" do
 | 
			
		||||
    share = (HOMEBREW_PREFIX/"share")
 | 
			
		||||
 | 
			
		||||
    (share/"pruneable/directory/here").mkpath
 | 
			
		||||
    (share/"notpruneable/file").write "I'm here"
 | 
			
		||||
    FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"
 | 
			
		||||
 | 
			
		||||
    expect { brew "prune", "--dry-run" }
 | 
			
		||||
      .to output(%r{Would remove \(empty directory\): .*/pruneable/directory/here}).to_stdout
 | 
			
		||||
      .and not_to_output.to_stderr
 | 
			
		||||
      .and be_a_success
 | 
			
		||||
 | 
			
		||||
    expect { brew "prune" }
 | 
			
		||||
      .to output(/Pruned 1 symbolic links and 3 directories/).to_stdout
 | 
			
		||||
      .and not_to_output.to_stderr
 | 
			
		||||
      .and be_a_success
 | 
			
		||||
 | 
			
		||||
    expect(share/"pruneable").not_to be_a_directory
 | 
			
		||||
    expect(share/"notpruneable").to be_a_directory
 | 
			
		||||
    expect(share/"pruneable_symlink").not_to be_a_symlink
 | 
			
		||||
 | 
			
		||||
    expect { brew "prune", "--verbose" }
 | 
			
		||||
      .to output(/Nothing pruned/).to_stdout
 | 
			
		||||
      .and not_to_output.to_stderr
 | 
			
		||||
      .and be_a_success
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -1,21 +0,0 @@
 | 
			
		||||
require "testing_env"
 | 
			
		||||
 | 
			
		||||
class IntegrationCommandTestPrune < IntegrationCommandTestCase
 | 
			
		||||
  def test_prune
 | 
			
		||||
    share = (HOMEBREW_PREFIX/"share")
 | 
			
		||||
 | 
			
		||||
    (share/"pruneable/directory/here").mkpath
 | 
			
		||||
    (share/"notpruneable/file").write "I'm here"
 | 
			
		||||
    FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"
 | 
			
		||||
 | 
			
		||||
    assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here},
 | 
			
		||||
      cmd("prune", "--dry-run")
 | 
			
		||||
    assert_match "Pruned 1 symbolic links and 3 directories",
 | 
			
		||||
      cmd("prune")
 | 
			
		||||
    refute((share/"pruneable").directory?)
 | 
			
		||||
    assert((share/"notpruneable").directory?)
 | 
			
		||||
    refute((share/"pruneable_symlink").symlink?)
 | 
			
		||||
 | 
			
		||||
    assert_match "Nothing pruned", cmd("prune", "--verbose")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user