我在my project中为rspec编写了一些测试示例。
在我的本地机器上所有测试都通过。但是travis check失败了。它说:
Failures:
1) Transcoding Checker should converts a file from Youtube
Failure/Error: YoutubeDlhelperLibs::Ripper.rip("#{@tempfile}")
Errno::ENOENT:
No such file or directory - the file 'Crystallize___Lindsey_Stirling__Dubstep_Violin_Original_Song_.m4a' does not exist
# ./lib/youtube_dlhelper/libs.rb:114:in `new'
# ./lib/youtube_dlhelper/libs.rb:114:in `rip'
# ./spec/lib_spec.rb:40:in `block (2 levels) in <top (required)>'
2) Cleanup Routine Should cleanup all downloaded and generated files
Failure/Error: File.delete("#{@tempfile}.mp4")
Errno::ENOENT:
No such file or directory - Crystallize___Lindsey_Stirling__Dubstep_Violin_Original_Song_.mp4
# ./spec/lib_spec.rb:50:in `delete'
# ./spec/lib_spec.rb:50:in `block (2 levels) in <top (required)>'
相关代码在我的libs_spec.rb中:
require 'rspec'
require 'dir'
require 'fileutils2'
require File.dirname(__FILE__) + '/spec_helper'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'youtube_dlhelper/libs'
@tempfile = 'Crystallize___Lindsey_Stirling__Dubstep_Violin_Original_Song_'
describe 'Transcoding Checker' do
it 'should converts a file from Youtube' do
puts 'Entering Test: Transcoding Checker'
@tempfile = 'Crystallize___Lindsey_Stirling__Dubstep_Violin_Original_Song_'
YoutubeDlhelperLibs::Ripper.rip("#{@tempfile}")
File.exists?("#{@tempfile}.mp3")
puts 'Test passed...'
end
end
describe 'Cleanup Routine' do
it 'Should cleanup all downloaded and generated files' do
require 'fileutils2'
@tempfile = 'Crystallize___Lindsey_Stirling__Dubstep_Violin_Original_Song_'
File.delete("#{@tempfile}.mp4")
File.delete("#{@tempfile}.m4a")
File.delete("#{@tempfile}.mp3")
end
我的libs中使用的方法:
module Ripper
# Methode for transcoding the *.m4a file to *.mp3. Output should be a valid MP3 file.
def self.rip(filename)
require 'streamio-ffmpeg'
puts 'Initializing the file'
movie = FFMPEG::Movie.new("#{filename}.m4a")
puts 'Initializing finished'
movie.valid?
puts 'Validated'
movie.transcode("#{filename}.m4a", "-acodec libmp3lame -ac 2 -ab 192k #{filename}.mp3")
puts 'Transcoded'
end
有谁知道为什么?