Skip to content

Commit

Permalink
Entry#rename returns the renamed entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wiggins committed Mar 25, 2009
1 parent c27d16e commit 2b622ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rush/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class NameCannotContainSlash < Exception; end
def rename(new_name)
connection.rename(@path, @name, new_name)
@name = new_name
self
end

# Rename an entry to another name within the same dir. The existing object
Expand Down
4 changes: 4 additions & 0 deletions spec/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
File.exists?("#{@sandbox_dir}/#{new_file}").should be_true
end

it "rename returns the renamed file" do
@entry.rename('file2').should == @entry.parent['file2']
end

it "can't rename itself if another file already exists with that name" do
new_file = "test3"
system "touch #{@sandbox_dir}/#{new_file}"
Expand Down

0 comments on commit 2b622ba

Please sign in to comment.