0
+require File.dirname(__FILE__) + "/../../test_helper"
0
+class TestWorkingCopyValidate < Test::Unit::TestCase
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir.rmtree rescue nil
0
+ @wc = Piston::WorkingCopy.new(@wcdir)
0
+ @wcdir.rmtree rescue nil
0
+ def test_exists_when_the_directory_exists
0
+ assert @wc.exist?, "WorkingCopy should have existed, since the directory exists"
0
+ def test_does_not_exist_when_directory_not_present
0
+ deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory does not exist"
0
+ def test_does_not_exist_when_directory_is_a_file
0
+ deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory is a file"
0
+ def test_is_pistonized_if_exist_and_has_piston_dot_yaml_file
0
+ @wc.stubs(:exist?).returns(true)
0
+ touch(@wcdir + ".piston.yml")
0
+ assert @wc.pistonized?, "WorkingCopy should be Pistonized, since the .piston.yml file exists"
0
+ def test_is_NOT_pistonized_if_no_piston_dot_yaml_file
0
+ @wc.stubs(:exist?).returns(true)
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since the .piston.yml does not file exists"
0
+ def test_is_NOT_pistonized_if_exist_returns_false
0
+ @wc.stubs(:exist?).returns(false)
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since #exist? returned false"
0
+ def test_is_NOT_pistonized_if_piston_dot_yaml_is_a_directory
0
+ @wc.stubs(:exist?).returns(true)
0
+ (@wcdir + ".piston.yml").mkdir
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since .piston.yml is a directory"
0
+ def test_validate_bang_returns_self_when_ok
0
+ @wc.stubs(:pistonized?).returns(true)
0
+ assert_equal @wc, @wc.validate!
0
+ def test_validate_bang_raises_not_working_copy_when_not_pistonized
0
+ @wc.stubs(:pistonized?).returns(false)
0
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
+ File.open(path, "wb") {|f| f.write ""}
Comments
No one has commented yet.