jeremylightsmith-piston 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gitignore +6 -0
  2. data/History.txt +6 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +86 -0
  5. data/README.txt +136 -0
  6. data/Rakefile +4 -0
  7. data/bin/piston +5 -0
  8. data/config/hoe.rb +76 -0
  9. data/config/requirements.rb +18 -0
  10. data/lib/piston.rb +18 -0
  11. data/lib/piston/cli.rb +279 -0
  12. data/lib/piston/commands.rb +4 -0
  13. data/lib/piston/commands/base.rb +44 -0
  14. data/lib/piston/commands/import.rb +69 -0
  15. data/lib/piston/commands/info.rb +14 -0
  16. data/lib/piston/commands/lock_unlock.rb +21 -0
  17. data/lib/piston/commands/update.rb +28 -0
  18. data/lib/piston/git.rb +12 -0
  19. data/lib/piston/git/client.rb +77 -0
  20. data/lib/piston/git/commit.rb +70 -0
  21. data/lib/piston/git/repository.rb +63 -0
  22. data/lib/piston/git/working_copy.rb +63 -0
  23. data/lib/piston/repository.rb +57 -0
  24. data/lib/piston/revision.rb +48 -0
  25. data/lib/piston/svn.rb +14 -0
  26. data/lib/piston/svn/client.rb +88 -0
  27. data/lib/piston/svn/repository.rb +67 -0
  28. data/lib/piston/svn/revision.rb +74 -0
  29. data/lib/piston/svn/working_copy.rb +55 -0
  30. data/lib/piston/version.rb +9 -0
  31. data/lib/piston/working_copy.rb +129 -0
  32. data/lib/subclass_responsibility_error.rb +2 -0
  33. data/log/.gitignore +0 -0
  34. data/samples/common.rb +19 -0
  35. data/samples/import_git_git.rb +39 -0
  36. data/samples/import_git_svn.rb +36 -0
  37. data/samples/import_svn_git.rb +29 -0
  38. data/samples/import_svn_svn.rb +24 -0
  39. data/script/destroy +14 -0
  40. data/script/generate +14 -0
  41. data/script/txt2html +74 -0
  42. data/setup.rb +1585 -0
  43. data/tasks/deployment.rake +40 -0
  44. data/tasks/environment.rake +7 -0
  45. data/tasks/samples.rake +6 -0
  46. data/tasks/test.rake +30 -0
  47. data/tasks/website.rake +17 -0
  48. data/test/integration/test_import_git_git.rb +96 -0
  49. data/test/integration/test_import_git_svn.rb +131 -0
  50. data/test/integration/test_import_svn_git.rb +52 -0
  51. data/test/integration/test_import_svn_svn.rb +43 -0
  52. data/test/integration_helpers.rb +33 -0
  53. data/test/test_helper.rb +56 -0
  54. data/test/unit/git/commit/test_checkout.rb +30 -0
  55. data/test/unit/git/commit/test_each.rb +36 -0
  56. data/test/unit/git/commit/test_rememberance.rb +20 -0
  57. data/test/unit/git/commit/test_validation.rb +33 -0
  58. data/test/unit/git/repository/test_at.rb +22 -0
  59. data/test/unit/git/repository/test_basename.rb +12 -0
  60. data/test/unit/git/repository/test_branchanme.rb +15 -0
  61. data/test/unit/git/repository/test_guessing.rb +32 -0
  62. data/test/unit/git/working_copy/test_copying.rb +28 -0
  63. data/test/unit/git/working_copy/test_creation.rb +26 -0
  64. data/test/unit/git/working_copy/test_existence.rb +21 -0
  65. data/test/unit/git/working_copy/test_finalization.rb +18 -0
  66. data/test/unit/git/working_copy/test_guessing.rb +34 -0
  67. data/test/unit/git/working_copy/test_rememberance.rb +25 -0
  68. data/test/unit/svn/repository/test_at.rb +18 -0
  69. data/test/unit/svn/repository/test_basename.rb +24 -0
  70. data/test/unit/svn/repository/test_guessing.rb +45 -0
  71. data/test/unit/svn/revision/test_checkout.rb +27 -0
  72. data/test/unit/svn/revision/test_each.rb +21 -0
  73. data/test/unit/svn/revision/test_rememberance.rb +42 -0
  74. data/test/unit/svn/revision/test_validation.rb +49 -0
  75. data/test/unit/svn/working_copy/test_copying.rb +29 -0
  76. data/test/unit/svn/working_copy/test_creation.rb +19 -0
  77. data/test/unit/svn/working_copy/test_existence.rb +26 -0
  78. data/test/unit/svn/working_copy/test_finalization.rb +21 -0
  79. data/test/unit/svn/working_copy/test_guessing.rb +17 -0
  80. data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
  81. data/test/unit/test_import.rb +13 -0
  82. data/test/unit/test_info.rb +36 -0
  83. data/test/unit/test_lock_unlock.rb +46 -0
  84. data/test/unit/test_repository.rb +50 -0
  85. data/test/unit/test_revision.rb +30 -0
  86. data/test/unit/working_copy/test_guessing.rb +34 -0
  87. data/test/unit/working_copy/test_info.rb +13 -0
  88. data/test/unit/working_copy/test_rememberance.rb +48 -0
  89. data/test/unit/working_copy/test_validate.rb +68 -0
  90. data/website/index.html +11 -0
  91. data/website/index.txt +39 -0
  92. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  93. data/website/stylesheets/screen.css +138 -0
  94. data/website/template.rhtml +48 -0
  95. metadata +228 -0
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRepositoryBasename < Test::Unit::TestCase
4
+ def test_basename_is_urls_path_last_component
5
+ assert_equal "piston", basename("http://svn.rubyforge.org/var/svn/piston")
6
+ end
7
+
8
+ def test_basename_is_urls_path_last_component_minus_trunk
9
+ assert_equal "attachment_fu", basename("svn+ssh://some.host.com/svn/attachment_fu/trunk")
10
+ end
11
+
12
+ def test_basename_is_urls_path_last_component_before_branches
13
+ assert_equal "rails", basename("svn://some.host.com/svn/rails/branches/stable")
14
+ end
15
+
16
+ def test_basename_is_urls_path_last_component_before_tags
17
+ assert_equal "plugin", basename("https://some.host.com/svn/plugin/tags/stable")
18
+ end
19
+
20
+ private
21
+ def basename(url)
22
+ Piston::Svn::Repository.new(url).basename
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRepositoryGuessing < Test::Unit::TestCase
4
+ def test_guesses_with_svn_protocol
5
+ assert Piston::Svn::Repository.understands_url?("svn://a.host.com/")
6
+ end
7
+
8
+ def test_guesses_with_svn_plus_bla_protocol
9
+ assert Piston::Svn::Repository.understands_url?("svn+bla://username@a.host.com/")
10
+ end
11
+
12
+ def test_guesses_with_svn_plus_ssh_protocol
13
+ assert Piston::Svn::Repository.understands_url?("svn+ssh://username@a.host.com/")
14
+ end
15
+
16
+ def test_contacts_repository_for_file_protocol
17
+ url = "file:///home/username/svn/projects/trunk"
18
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
19
+ assert Piston::Svn::Repository.understands_url?(url)
20
+ end
21
+
22
+ def test_contacts_repository_for_http_protocol
23
+ url = "http://svn.collab.net/repos/svn/trunk"
24
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
25
+ assert Piston::Svn::Repository.understands_url?(url)
26
+ end
27
+
28
+ def test_contacts_repository_for_https_protocol
29
+ url = "https://svn.collab.net/repos/svn/trunk"
30
+ Piston::Svn::Repository.expects(:svn).with(:info, url).returns("Repository UUID: abcdef\n")
31
+ assert Piston::Svn::Repository.understands_url?(url)
32
+ end
33
+
34
+ def test_says_does_not_understand_when_svn_info_errors_out
35
+ url = "http://rubyonrails.org/"
36
+ Piston::Svn::Repository.expects(:svn).with(:info, url).raises(Piston::Svn::Client::Failed)
37
+ deny Piston::Svn::Repository.understands_url?(url)
38
+ end
39
+
40
+ def test_says_does_not_understand_when_svn_command_not_found
41
+ url = "http://rubyonrails.org/"
42
+ Piston::Svn::Repository.expects(:svn).with(:info, url).raises(Piston::Svn::Client::BadCommand)
43
+ deny Piston::Svn::Repository.understands_url?(url)
44
+ end
45
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRevisionCheckout < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @repos = mock("repository")
7
+ @repos.stubs(:url).returns("http://a.repos.com/trunk")
8
+ end
9
+
10
+ def test_head_checkout_to_path
11
+ rev = new_revision("HEAD")
12
+ rev.expects(:svn).with(:checkout, "--revision", "HEAD", @repos.url, @wcdir).returns("Checked out revision 1322.")
13
+ rev.checkout_to(@wcdir)
14
+ assert_equal 1322, rev.revision
15
+ end
16
+
17
+ def test_specific_revision_checkout_to_path
18
+ rev = new_revision(1231)
19
+ rev.expects(:svn).with(:checkout, "--revision", 1231, @repos.url, @wcdir).returns("Checked out revision 1231.")
20
+ rev.checkout_to(@wcdir)
21
+ end
22
+
23
+ private
24
+ def new_revision(revision)
25
+ Piston::Svn::Revision.new(@repos, revision)
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRevisionEach < Test::Unit::TestCase
4
+ def setup
5
+ @repos = mock("repository")
6
+ @repos.stubs(:url).returns("http://a.repos.com/project/trunk")
7
+
8
+ @wcdir = Pathname.new("tmp/.wc.tmp")
9
+
10
+ @rev = Piston::Svn::Revision.new(@repos, "HEAD")
11
+ @rev.stubs(:svn).returns("Checked out revision 111.\n")
12
+ @rev.checkout_to(@wcdir)
13
+ end
14
+
15
+ def test_each_skips_over_svn_metadata_folders
16
+ @rev.expects(:svn).with(:ls, "--recursive", @wcdir).returns("CONTRIBUTORS\nREADME\ntest/test_helper.rb\n")
17
+ expected = ["CONTRIBUTORS", "README", "test/test_helper.rb"]
18
+ actual = @rev.inject([]) {|memo, relpath| memo << relpath}
19
+ assert_equal expected.sort, actual.sort
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRevisionRememberance < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wcdir.mkdir rescue nil
7
+ @repos = mock("repository")
8
+ @repos.stubs(:url).returns("http://a.repos.com/svn/trunk")
9
+
10
+ @info = {"Path" => @wcdir.realpath,
11
+ "URL" => "http://a.repos.com/svn/trunk",
12
+ "Repository Root" => "http://a.repos.com/svn",
13
+ "Repository UUID" => "some-long-uuid",
14
+ "Revision" => "9283",
15
+ "Node Kind" => "directory",
16
+ "Schedule" => "normal",
17
+ "Last Changed Author" => "me",
18
+ "Last Changed Rev" => "9283",
19
+ "Last Changed Date" => "2008-03-11 20:44:24 -0400 (Tue, 11 Mar 2008)"}
20
+ end
21
+
22
+ def teardown
23
+ @wcdir.rmtree rescue nil
24
+ end
25
+
26
+ def test_remembers_repos_uuid
27
+ rev = new_revision("HEAD")
28
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repos.url).returns(@info.to_yaml)
29
+ assert_equal "some-long-uuid", rev.remember_values[Piston::Svn::UUID]
30
+ end
31
+
32
+ def test_remembers_repos_revision
33
+ rev = new_revision("HEAD")
34
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repos.url).returns(@info.to_yaml)
35
+ assert_equal "9283", rev.remember_values[Piston::Svn::REMOTE_REV]
36
+ end
37
+
38
+ private
39
+ def new_revision(revision)
40
+ Piston::Svn::Revision.new(@repos, revision)
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnRevisionValidation < Test::Unit::TestCase
4
+ def setup
5
+ @repository = mock("repository")
6
+ @repository.stubs(:url).returns("svn://svn.my-repos.com/projects/libcalc/trunk")
7
+ end
8
+
9
+ def test_revision_is_invalid_unless_same_uuid
10
+ rev = new_revision("HEAD", Piston::Svn::UUID => "1234")
11
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
12
+ assert_raise Piston::Svn::Revision::UuidChanged do
13
+ rev.validate!
14
+ end
15
+ end
16
+
17
+ def test_revision_is_invalid_if_repository_location_does_not_exist_anymore
18
+ rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
19
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns("#{@repository.url}: (Not a valid URL)")
20
+ assert_raise Piston::Svn::Revision::RepositoryMoved do
21
+ rev.validate!
22
+ end
23
+ end
24
+
25
+ def test_revision_is_valid_if_repository_is_present_and_same_uuid
26
+ rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
27
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
28
+ assert_nothing_raised do
29
+ rev.validate!
30
+ end
31
+ end
32
+
33
+ protected
34
+ def new_revision(rev, recalled_values={})
35
+ Piston::Svn::Revision.new(@repository, rev, recalled_values)
36
+ end
37
+
38
+ INFO = <<EOF
39
+ Path: project
40
+ URL: svn://svn.my-repos.com/projects/libcalc/trunk
41
+ Repository Root: svn://svn.my-repos.com/projects
42
+ Repository UUID: 038cbeb6-2227-0410-91ec-8f9533625906
43
+ Revision: 1234
44
+ Node Kind: directory
45
+ Last Changed Author: francois
46
+ Last Changed Rev: 1232
47
+ Last Changed Date: 2008-04-06 21:57:10 -0400 (Sun, 06 Apr 2008)
48
+ EOF
49
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyCopying < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
7
+ @wc.stubs(:svn)
8
+ @wc.stubs(:svn).with(:info, anything).returns("a:b")
9
+ end
10
+
11
+ def teardown
12
+ @wcdir.rmtree rescue nil
13
+ end
14
+
15
+ def test_copies_files
16
+ files = ["file.rb"]
17
+ files.expects(:copy_to).with("file.rb", @wcdir + files.first)
18
+ @wc.copy_from(files)
19
+ end
20
+
21
+ def test_ensures_directories_are_created
22
+ files = ["file/a.rb"]
23
+ @wcdir.expects(:+).with(files.first).returns(target = mock("target"))
24
+ target.expects(:dirname).returns(target)
25
+ target.expects(:mkdir)
26
+ files.expects(:copy_to).with("file/a.rb", target)
27
+ @wc.copy_from(files)
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyCreation < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
7
+ @wc.stubs(:svn)
8
+ @wc.stubs(:svn).with(:info, anything).returns("a:b")
9
+ end
10
+
11
+ def teardown
12
+ @wcdir.rmtree rescue nil
13
+ end
14
+
15
+ def test_create_uses_svn_mkdir
16
+ @wc.expects(:svn).with(:mkdir, @wcdir)
17
+ @wc.create
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyExistence < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
7
+ end
8
+
9
+ def teardown
10
+ @wcdir.rmtree rescue nil
11
+ end
12
+
13
+ def test_exist_false_when_dir_not_present
14
+ deny @wc.exist?
15
+ end
16
+
17
+ def test_exist_false_when_dir_present_but_not_an_svn_wc
18
+ @wcdir.mkdir
19
+ deny @wc.exist?
20
+ end
21
+
22
+ def test_exist_true_when_svn_working_copy_at_path
23
+ @wc.expects(:svn).with(:info, @wcdir).returns("Path: b")
24
+ assert @wc.exist?
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyFinalization < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
7
+ end
8
+
9
+ def teardown
10
+ @wcdir.rmtree rescue nil
11
+ end
12
+
13
+ def test_finalize_adds_all_top_level_entries_to_working_copy
14
+ @wcdir.mkdir
15
+ File.open(@wcdir + "a.rb", "wb") {|f| f.write "Hello World!"}
16
+ File.open(@wcdir + "b.rb", "wb") {|f| f.write "Hello World!"}
17
+ @wc.expects(:svn).with(:add, (@wcdir + "a.rb").to_s)
18
+ @wc.expects(:svn).with(:add, (@wcdir + "b.rb").to_s)
19
+ @wc.finalize
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyGuessing < Test::Unit::TestCase
4
+ def setup
5
+ @dir = Pathname.new("tmp/wc")
6
+ end
7
+
8
+ def test_does_svn_info_on_directory
9
+ Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).returns("Path: xxx\n")
10
+ assert Piston::Svn::WorkingCopy.understands_dir?(@dir)
11
+ end
12
+
13
+ def test_denies_when_svn_not_available
14
+ Piston::Svn::WorkingCopy.expects(:svn).with(:info, @dir).raises(Piston::Svn::Client::BadCommand)
15
+ deny Piston::Svn::WorkingCopy.understands_dir?(@dir)
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + "/../../../test_helper"
2
+
3
+ class TestSvnWorkingCopyRememberance < Test::Unit::TestCase
4
+ def setup
5
+ @wcdir = Pathname.new("tmp/wc")
6
+ @wcdir.mkpath
7
+ @wc = Piston::Svn::WorkingCopy.new(@wcdir)
8
+ @wc.stubs(:svn)
9
+ @wc.stubs(:svn).with(:info, anything).returns("a:b")
10
+ end
11
+
12
+ def teardown
13
+ @wcdir.rmtree rescue nil
14
+ end
15
+
16
+ def test_after_remember_adds_path_using_svn
17
+ @wc.expects(:svn).with(:info, :the_path).returns("a: (Not a versioned resource)\n")
18
+ @wc.expects(:svn).with(:add, :the_path)
19
+ @wc.after_remember(:the_path)
20
+ end
21
+
22
+ def test_after_remember_does_not_add_if_file_already_under_version_control
23
+ @wc.expects(:svn).with(:info, :the_path).returns("a: b\n")
24
+ @wc.after_remember(:the_path)
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + "/../test_helper"
2
+
3
+ class TestImport < Test::Unit::TestCase
4
+ def setup
5
+ @wc = stub_everything("working_copy")
6
+ @cmd = Piston::Commands::Import.new
7
+ end
8
+
9
+ def test_temp_dir_name_hides_tmpdir_as_a_dotfile_and_suffixes_with_tmp
10
+ @wc.stubs(:path).returns(Pathname.new("tmp/a/dir"))
11
+ assert_equal Pathname.new("tmp/a/.dir.tmp"), @cmd.temp_dir_name(@wc)
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + "/../test_helper"
2
+
3
+ class TestInfo < Test::Unit::TestCase
4
+ def setup
5
+ @values = {"lock" => false}
6
+ @wcdir = "tmp/wcdir"
7
+ @wc = mock("WorkingCopy")
8
+ @wc.stubs(:validate!)
9
+ end
10
+
11
+ def test_info
12
+ run_and_verify do
13
+ @wc.expects(:info)
14
+ end
15
+ end
16
+
17
+ def test_validates_working_copy_before_working
18
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
19
+ run_and_verify do
20
+ @wc.expects(:validate!).raises(Piston::WorkingCopy::NotWorkingCopy)
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+ def run_and_verify
27
+ yield
28
+ info_command.run(@wcdir)
29
+ end
30
+
31
+ def info_command
32
+ Piston::WorkingCopy.expects(:guess).with(@wcdir).returns(@wc)
33
+ Piston::Commands::Info.new(:verbose => "verbose",
34
+ :quiet => "quiet", :force => "force")
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + "/../test_helper"
2
+
3
+ class TestLockUnlock < Test::Unit::TestCase
4
+ def setup
5
+ @values = {"lock" => false}
6
+ @wcdir = "tmp/wcdir"
7
+ @wc = mock("WorkingCopy")
8
+ @wc.stubs(:validate!)
9
+ end
10
+
11
+ def test_lock_working_copy
12
+ run_and_verify(true) do
13
+ @wc.expects(:recall).returns(@values)
14
+ @wc.expects(:finalize).returns(@values)
15
+ @wc.expects(:remember).with(@values.merge("lock" => true), @values["handler"]).returns(@values)
16
+ end
17
+ end
18
+
19
+ def test_unlock_working_copy
20
+ run_and_verify(false) do
21
+ @wc.expects(:recall).returns(@values)
22
+ @wc.expects(:finalize).returns(@values)
23
+ @wc.expects(:remember).with(@values.merge("lock" => false), @values["handler"]).returns(@values)
24
+ end
25
+ end
26
+
27
+ def test_validates_working_copy_before_working
28
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
29
+ run_and_verify do
30
+ @wc.expects(:validate!).raises(Piston::WorkingCopy::NotWorkingCopy)
31
+ end
32
+ end
33
+ end
34
+
35
+ private
36
+ def run_and_verify(lock=true)
37
+ yield
38
+ lock_unlock_command.run(@wcdir, lock)
39
+ end
40
+
41
+ def lock_unlock_command
42
+ Piston::WorkingCopy.expects(:guess).with(@wcdir).returns(@wc)
43
+ Piston::Commands::LockUnlock.new(:verbose => "verbose",
44
+ :quiet => "quiet", :force => "force")
45
+ end
46
+ end