Permalink
Browse files

Refactored the #cd specs for nonexistent dirs.

  • Loading branch information...
benhoskings committed Feb 5, 2012
1 parent bfe0ffd commit c67351b5919dfed543bf5fe7956a9b63de79360f
Showing with 15 additions and 13 deletions.
  1. +15 −13 spec/babushka/path_helpers_spec.rb
@@ -8,9 +8,6 @@
`mkdir -p '#{@tmp_dir_2}'`
@original_pwd = Dir.pwd
-
- @nonexistent_dir = File.join(tmp_prefix, 'nonexistent')
- Dir.rmdir(@nonexistent_dir) if File.directory?(@nonexistent_dir)
end
it "should yield if no dir is given" do
@@ -51,18 +48,23 @@
}
Dir.pwd.should == @original_pwd
end
- it "should fail on nonexistent dirs" do
- L{ cd(@nonexistent_dir) }.should raise_error(Errno::ENOENT)
- end
- it "should create nonexistent dirs if :create => true is specified" do
- cd(@nonexistent_dir, :create => true) {
- Dir.pwd.should == @nonexistent_dir
+ context "nonexistent dirs" do
+ let(:nonexistent_dir) {
+ (tmp_prefix / 'nonexistent').tap(&:rm)
+ }
+ it "should fail on nonexistent dirs" do
+ L{ cd(nonexistent_dir) }.should raise_error(Errno::ENOENT)
+ end
+ it "should create nonexistent dirs if :create => true is specified" do
+ cd(nonexistent_dir, :create => true) {
+ Dir.pwd.should == nonexistent_dir
+ }
+ Dir.pwd.should == @original_pwd
+ end
+ after {
+ nonexistent_dir.rm
}
- Dir.pwd.should == @original_pwd
end
- after {
- Dir.rmdir(@nonexistent_dir) if File.directory?(@nonexistent_dir)
- }
end
describe "in_build_dir" do

0 comments on commit c67351b

Please sign in to comment.