forked from streamio/streamio-ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamio-ffmpeg_spec.rb
103 lines (80 loc) · 2.95 KB
/
streamio-ffmpeg_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
require 'spec_helper'
describe FFMPEG do
describe "logger" do
after(:each) do
FFMPEG.logger = Logger.new(nil)
end
it "should be a Logger" do
expect(FFMPEG.logger).to be_instance_of(Logger)
end
it "should be at info level" do
FFMPEG.logger = nil # Reset the logger so that we get the default
expect(FFMPEG.logger.level).to eq(Logger::INFO)
end
it "should be assignable" do
new_logger = Logger.new(STDOUT)
FFMPEG.logger = new_logger
expect(FFMPEG.logger).to eq(new_logger)
end
end
describe '.ffmpeg_binary' do
after(:each) do
FFMPEG.ffmpeg_binary = nil
end
it 'should default to finding from path' do
allow(FFMPEG).to receive(:which) { '/usr/local/bin/ffmpeg' }
expect(FFMPEG.ffmpeg_binary).to eq FFMPEG.which('ffprobe')
end
it 'should be assignable' do
allow(File).to receive(:executable?).with('/new/path/to/ffmpeg') { true }
FFMPEG.ffmpeg_binary = '/new/path/to/ffmpeg'
expect(FFMPEG.ffmpeg_binary).to eq '/new/path/to/ffmpeg'
end
it 'should raise exception if it cannot find assigned executable' do
expect { FFMPEG.ffmpeg_binary = '/new/path/to/ffmpeg' }.to raise_error(Errno::ENOENT)
end
it 'should raise exception if it cannot find executable on path' do
allow(File).to receive(:executable?) { false }
expect { FFMPEG.ffmpeg_binary }.to raise_error(Errno::ENOENT)
end
end
describe '.ffprobe_binary' do
after(:each) do
FFMPEG.ffprobe_binary = nil
end
it 'should default to finding from path' do
allow(FFMPEG).to receive(:which) { '/usr/local/bin/ffprobe' }
expect(FFMPEG.ffprobe_binary).to eq FFMPEG.which('ffprobe')
end
it 'should be assignable' do
allow(File).to receive(:executable?).with('/new/path/to/ffprobe') { true }
FFMPEG.ffprobe_binary = '/new/path/to/ffprobe'
expect(FFMPEG.ffprobe_binary).to eq '/new/path/to/ffprobe'
end
it 'should raise exception if it cannot find assigned executable' do
expect { FFMPEG.ffprobe_binary = '/new/path/to/ffprobe' }.to raise_error(Errno::ENOENT)
end
it 'should raise exception if it cannot find executable on path' do
allow(File).to receive(:executable?) { false }
expect { FFMPEG.ffprobe_binary }.to raise_error(Errno::ENOENT)
end
end
describe '.max_http_redirect_attempts' do
after(:each) do
FFMPEG.max_http_redirect_attempts = nil
end
it 'should default to 10' do
expect(FFMPEG.max_http_redirect_attempts).to eq 10
end
it 'should be an Integer' do
expect { FFMPEG.max_http_redirect_attempts = 1.23 }.to raise_error(Errno::ENOENT)
end
it 'should not be negative' do
expect { FFMPEG.max_http_redirect_attempts = -1 }.to raise_error(Errno::ENOENT)
end
it 'should be assignable' do
FFMPEG.max_http_redirect_attempts = 5
expect(FFMPEG.max_http_redirect_attempts).to eq 5
end
end
end