Skip to content

Commit

Permalink
Merge pull request #24 from mtrovo/issue_23
Browse files Browse the repository at this point in the history
fix to change only the extension of the last path element
  • Loading branch information
byroot committed Mar 29, 2015
2 parents 67fa68d + 87cb113 commit 579bffd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/osdb/movie_file.rb
Expand Up @@ -22,7 +22,7 @@ def sub_path(format)
else
".#{format}"
end
path.gsub(File.extname(path), extension)
File.join(File.dirname(path), File.basename(path, File.extname(path)) + extension)
end

def hash
Expand Down
6 changes: 6 additions & 0 deletions spec/osdb/movie_file_spec.rb
Expand Up @@ -9,4 +9,10 @@
its(:hash) { should == '243339b48f4e8741' }
its(:name) { should == 'somemovie' }

describe '#sub_path' do
it 'should only change the extension of the movie' do
movie_file = OSDb::MovieFile.new('directory-with-extension.avi/movie-file.avi', false)
movie_file.sub_path('srt').should == 'directory-with-extension.avi/movie-file.srt'
end
end
end

0 comments on commit 579bffd

Please sign in to comment.