spec/pa/cmd_spec.rb in pa-1.3.0 vs spec/pa/cmd_spec.rb in pa-1.3.1
- old
+ new
@@ -1,30 +1,28 @@
require "spec_helper"
require "fileutils"
require "tmpdir"
-module Pa::Cmd::ClassMethods
- public :_copy, :_touch, :_mkdir, :_mktmpname, :_rmdir, :_copy, :_move, :_ln
-end
+public_all_methods Pa::Cmd::ClassMethods
describe Pa do
before :all do
@curdir = Dir.pwd
@tmpdir = Dir.mktmpdir
Dir.chdir @tmpdir
end
- after :all do
- Dir.chdir @curdir
- FileUtils.rm_r @tmpdir
- end
-
# clean up directory after each run
after :each do
FileUtils.rm_r Dir.glob("*", File::FNM_DOTMATCH)-%w[. ..]
end
+ after :all do
+ Dir.chdir @curdir
+ FileUtils.rm_r @tmpdir
+ end
+
describe "#home2" do
it "works" do
Pa.home2.should == Dir.home
end
end
@@ -34,11 +32,11 @@
before :each do
FileUtils.touch %w[_lna]
end
it "works" do
- output = capture :stdout do
+ output = capture do
Pa._ln(:link, "_lna", "_lnb", :verbose => true)
end
output.should == "ln _lna _lnb\n"
File.identical?("_lna", "_lnb").should be_true
@@ -84,11 +82,11 @@
end
it "doesn't raise Errno::EEXIST with :force" do
lambda{ Pa.symln("file1", "file2", :force => true) }.should_not raise_error(Errno::EEXIST)
File.symlink?("file2").should be_true
- File.readlink("file2").should == "file1"
+ File.readlink(File.absolute_path("file2")).should == "file1"
end
end
describe "#readlink" do
# syma -> file1
@@ -194,11 +192,11 @@
it "works" do
Dir.should_receive(:mkdir)
path = Pa.mktmpdir("foo")
- path.should =~ %r~#{Regexp.escape(ENV["TEMP"])}/foo~
+ path.should =~ %r~#{Regexp.escape(Dir.tmpdir)}/foo~
end
end
describe "#mktmpfile2" do
it "works" do
@@ -545,10 +543,10 @@
lambda{ Pa.mv("dir1", "dir2", :force => true) }.should_not raise_error(Errno::EEXIST)
File.exists?("dir2/dir1/filea").should be_true
end
end
- describe "class DELEGATE_METHODS" do
+ describe "DELEGATE_CLASS_METHODS" do
it "works" do
Pa.stub(:home2) { "/home/foo" }
Pa.home.should == Pa("/home/foo")
Pa.should_receive(:home2).with(1, 2)