Commit b480205c2f1b72338c0612f095e94486dc183449

Moved the shared 'A working copy against a local repository' behaviour specification to spec/spec_helper.rb. Implemented a single rooted tmp/ for easy cleanup.

git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@120 d6c2ea82-c31b-0410-8381-e9c44f9824c5

Commit diff

spec/spec_helper.rb

 
22require "logger"
33
44$logger = Logger.new($stderr)
5$logger.level = Logger::INFO
5$logger.level = Logger::INFO unless $DEBUG
66
77describe "A local repository", :shared => true do
88 def logger
99 $logger
1010 end
1111
12 before do
13 @repos_dir = File.expand_path(File.join(File.dirname(__FILE__), "tmp", "repos"))
12 def tmppath(*paths)
13 parts = [File.dirname(__FILE__), "tmp"]
14 parts << (@root_time ||= Time.now.to_i.to_s)
15 parts += paths
16 parts << rand().to_s.split(".").last
17 parts.collect! {|path| path.to_s}
18 path = File.join(*parts)
19 attempts = 10
20 while File.exists?(path)
21 path.succ!
22 attempts -= 1
23 raise "Unable to find a good temp pathname: #{path.inspect}" if attempts.zero?
24 end
25
26 File.expand_path(path)
27 end
1428
15 logger.debug {"Removing #{@repos_dir.inspect}"}
16 FileUtils.rm_rf(@repos_dir)
29 before do
30 @repos_dir = self.tmppath(:repos)
31 logger.debug {@repos_dir.inspect}
1732
1833 @repos = Piston::Repository.new("file://" + @repos_dir)
1934 @repos.logger = self.logger
2035 end
2136
2237 after do
23 logger.debug {"Removing #{@repos_dir.inspect}"}
24 FileUtils.rm_rf(@repos_dir)
38 path = File.expand_path(File.join(File.dirname(__FILE__), "tmp"))
39 logger.debug {"Removing #{path.inspect}"}
40 FileUtils.rm_rf(path)
41 end
42end
43
44describe "A working copy against a local repository", :shared => true do
45 it_should_behave_like "A local repository"
46
47 before do
48 @repos.create!
49
50 @wcdir = self.tmppath(:wc)
51 @wc = Piston::WorkingCopy.new(@wcdir)
52 @wc.logger = self.logger
2553 end
2654end
toggle raw diff

spec/working_copy_spec.rb

 
33require "piston/repository"
44require "fileutils"
55
6describe "A working copy against a local repository", :shared => true do
7 it_should_behave_like "A local repository"
8
9 before do
10 @repos.create!
11 @wcdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp", "wc"))
12 FileUtils.rm_rf(@wcdir)
13 @wc = Piston::WorkingCopy.new(@wcdir)
14 @wc.logger = self.logger
15 end
16
17 after do
18 FileUtils.rm_rf(@wcdir)
19 end
20end
21
226describe Piston::WorkingCopy do
237 it_should_behave_like "A working copy against a local repository"
248
toggle raw diff