Skip to content

Commit

Permalink
ensure the old ripenv is removed during a clone
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Jul 19, 2009
1 parent cbf86ee commit 481b0f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/rip/env.rb
Expand Up @@ -13,7 +13,7 @@ def create(env)
if env.strip.empty?
return "must give a ripenv to create"
end

if env.strip =~ PRIVATE_ENV
return "invalid environment name"
end
Expand Down Expand Up @@ -108,6 +108,7 @@ def copy(new)

if File.exists? ripfile = File.join(dest, "#{env}.ripenv")
FileUtils.cp ripfile, File.join(dest, "#{new}.ripenv")
FileUtils.rm ripfile
end

use new
Expand Down
11 changes: 9 additions & 2 deletions test/env_test.rb
Expand Up @@ -36,7 +36,7 @@
assert_equal 'must give a ripenv to create', Rip::Env.create("\t ")
assert_equal "must give a ripenv to create", Rip::Env.call(:create)
end

test 'fails if attempt to name env active' do
assert_equal 'invalid environment name', Rip::Env.create('active')
end
Expand Down Expand Up @@ -168,6 +168,13 @@
assert_equal @name, Rip::Env.active
end

test "properly renames the ripenv file" do
Rip::Env.copy(@name)

assert File.exists?(File.join(@ripenv, "#{@name}.ripenv"))
assert !File.exists?(File.join(@ripenv, "base.ripenv"))
end

test "makes the new env a copy of the active env"

test "fails if the new env exists" do
Expand All @@ -185,4 +192,4 @@
assert_equal 'must give a ripenv to copy to', Rip::Env.copy("\t ")
assert_equal "must give a ripenv to copy to", Rip::Env.call(:copy)
end
end
end
2 changes: 2 additions & 0 deletions test/test_helper.rb
Expand Up @@ -47,6 +47,8 @@ def self.setup_with_fs(&block)
Rip::Env.create('other')
Rip::Setup.setup_ripenv(Rip.dir)
Rip::Env.create('base')
FileUtils.touch(File.join(Rip.dir, 'other', 'other.ripenv'))
FileUtils.touch(File.join(Rip.dir, 'base', 'base.ripenv'))
setup_block
end

Expand Down

0 comments on commit 481b0f9

Please sign in to comment.