diff --git a/lib/osdb/movie_file.rb b/lib/osdb/movie_file.rb index 17d4907..1570e87 100644 --- a/lib/osdb/movie_file.rb +++ b/lib/osdb/movie_file.rb @@ -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 diff --git a/spec/osdb/movie_file_spec.rb b/spec/osdb/movie_file_spec.rb index 8cdfe41..adf0374 100644 --- a/spec/osdb/movie_file_spec.rb +++ b/spec/osdb/movie_file_spec.rb @@ -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