active_encode 0.5.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +80 -0
  3. data/.rubocop.yml +9 -70
  4. data/.rubocop_todo.yml +68 -0
  5. data/Gemfile +5 -4
  6. data/README.md +69 -0
  7. data/active_encode.gemspec +12 -3
  8. data/app/controllers/active_encode/encode_record_controller.rb +1 -0
  9. data/app/jobs/active_encode/polling_job.rb +1 -1
  10. data/app/models/active_encode/encode_record.rb +1 -0
  11. data/db/migrate/20180822021048_create_active_encode_encode_records.rb +1 -0
  12. data/db/migrate/20190702153755_add_create_options_to_active_encode_encode_records.rb +6 -0
  13. data/db/migrate/20190712174821_add_progress_to_active_encode_encode_records.rb +6 -0
  14. data/lib/active_encode.rb +1 -0
  15. data/lib/active_encode/base.rb +2 -2
  16. data/lib/active_encode/callbacks.rb +1 -0
  17. data/lib/active_encode/core.rb +4 -3
  18. data/lib/active_encode/engine.rb +1 -0
  19. data/lib/active_encode/engine_adapter.rb +1 -0
  20. data/lib/active_encode/engine_adapters.rb +4 -1
  21. data/lib/active_encode/engine_adapters/elastic_transcoder_adapter.rb +31 -29
  22. data/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +138 -87
  23. data/lib/active_encode/engine_adapters/matterhorn_adapter.rb +5 -4
  24. data/lib/active_encode/engine_adapters/media_convert_adapter.rb +399 -0
  25. data/lib/active_encode/engine_adapters/media_convert_output.rb +104 -0
  26. data/lib/active_encode/engine_adapters/pass_through_adapter.rb +239 -0
  27. data/lib/active_encode/engine_adapters/test_adapter.rb +5 -4
  28. data/lib/active_encode/engine_adapters/zencoder_adapter.rb +3 -2
  29. data/lib/active_encode/errors.rb +6 -0
  30. data/lib/active_encode/global_id.rb +2 -1
  31. data/lib/active_encode/input.rb +3 -2
  32. data/lib/active_encode/output.rb +3 -2
  33. data/lib/active_encode/persistence.rb +11 -5
  34. data/lib/active_encode/polling.rb +3 -2
  35. data/lib/active_encode/spec/shared_specs.rb +2 -0
  36. data/{spec/shared_specs/engine_adapter_specs.rb → lib/active_encode/spec/shared_specs/engine_adapter.rb} +37 -38
  37. data/lib/active_encode/status.rb +1 -0
  38. data/lib/active_encode/technical_metadata.rb +3 -2
  39. data/lib/active_encode/version.rb +2 -1
  40. data/lib/file_locator.rb +8 -9
  41. data/spec/controllers/encode_record_controller_spec.rb +4 -3
  42. data/spec/fixtures/ffmpeg/cancelled-id/cancelled +0 -0
  43. data/spec/fixtures/file with space.low.mp4 +0 -0
  44. data/spec/fixtures/file with space.mp4 +0 -0
  45. data/spec/fixtures/fireworks.low.mp4 +0 -0
  46. data/spec/fixtures/media_convert/endpoints.json +1 -0
  47. data/spec/fixtures/media_convert/job_canceled.json +412 -0
  48. data/spec/fixtures/media_convert/job_canceling.json +1 -0
  49. data/spec/fixtures/media_convert/job_completed.json +359 -0
  50. data/spec/fixtures/media_convert/job_completed_detail.json +1 -0
  51. data/spec/fixtures/media_convert/job_completed_detail_query.json +1 -0
  52. data/spec/fixtures/media_convert/job_completed_empty_detail.json +1 -0
  53. data/spec/fixtures/media_convert/job_created.json +408 -0
  54. data/spec/fixtures/media_convert/job_failed.json +406 -0
  55. data/spec/fixtures/media_convert/job_progressing.json +414 -0
  56. data/spec/fixtures/pass_through/cancelled-id/cancelled +0 -0
  57. data/spec/fixtures/pass_through/cancelled-id/input_metadata +90 -0
  58. data/spec/fixtures/pass_through/completed-id/completed +0 -0
  59. data/spec/fixtures/pass_through/completed-id/input_metadata +102 -0
  60. data/spec/fixtures/pass_through/completed-id/output_metadata-high +90 -0
  61. data/spec/fixtures/pass_through/completed-id/output_metadata-low +90 -0
  62. data/spec/fixtures/pass_through/completed-id/video-high.mp4 +0 -0
  63. data/spec/fixtures/pass_through/completed-id/video-low.mp4 +0 -0
  64. data/spec/fixtures/pass_through/failed-id/error.log +1 -0
  65. data/spec/fixtures/pass_through/failed-id/input_metadata +90 -0
  66. data/spec/fixtures/pass_through/running-id/input_metadata +90 -0
  67. data/spec/integration/elastic_transcoder_adapter_spec.rb +30 -30
  68. data/spec/integration/ffmpeg_adapter_spec.rb +93 -25
  69. data/spec/integration/matterhorn_adapter_spec.rb +45 -44
  70. data/spec/integration/media_convert_adapter_spec.rb +152 -0
  71. data/spec/integration/pass_through_adapter_spec.rb +151 -0
  72. data/spec/integration/zencoder_adapter_spec.rb +210 -209
  73. data/spec/rails_helper.rb +1 -0
  74. data/spec/routing/encode_record_controller_routing_spec.rb +1 -0
  75. data/spec/spec_helper.rb +2 -2
  76. data/spec/test_app_templates/lib/generators/test_app_generator.rb +13 -12
  77. data/spec/units/callbacks_spec.rb +3 -2
  78. data/spec/units/core_spec.rb +26 -25
  79. data/spec/units/engine_adapter_spec.rb +1 -0
  80. data/spec/units/file_locator_spec.rb +20 -19
  81. data/spec/units/global_id_spec.rb +12 -11
  82. data/spec/units/input_spec.rb +8 -5
  83. data/spec/units/output_spec.rb +8 -5
  84. data/spec/units/persistence_spec.rb +15 -11
  85. data/spec/units/polling_job_spec.rb +7 -6
  86. data/spec/units/polling_spec.rb +1 -0
  87. data/spec/units/status_spec.rb +3 -3
  88. metadata +158 -14
  89. data/.travis.yml +0 -19
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'aws-sdk-cloudwatchevents'
4
+ require 'aws-sdk-cloudwatchlogs'
5
+ require 'aws-sdk-mediaconvert'
6
+ require 'aws-sdk-s3'
7
+ require 'json'
8
+ require 'active_encode/spec/shared_specs'
9
+ require 'active_support/json'
10
+ require 'active_support/time'
11
+
12
+ def with_json_parsing
13
+ old_settings = { parse_json_times: ActiveSupport.parse_json_times, time_zone: Time.zone }
14
+ ActiveSupport.parse_json_times = true
15
+ Time.zone = 'America/Chicago'
16
+ yield
17
+ ensure
18
+ ActiveSupport.parse_json_times = old_settings[:parse_json_times]
19
+ Time.zone = old_settings[:time_zone]
20
+ end
21
+
22
+ def reconstitute_response(fixture_path)
23
+ with_json_parsing do
24
+ HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(File.read(File.join("spec/fixtures", fixture_path))))
25
+ end
26
+ end
27
+
28
+ describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
29
+ around do |example|
30
+ # Setting this before each test works around a stubbing + memoization limitation
31
+ ActiveEncode::Base.engine_adapter = :media_convert
32
+ ActiveEncode::Base.engine_adapter.role = 'arn:aws:iam::123456789012:role/service-role/MediaConvert_Default_Role'
33
+ ActiveEncode::Base.engine_adapter.output_bucket = 'output-bucket'
34
+ example.run
35
+ ActiveEncode::Base.engine_adapter = :test
36
+ end
37
+
38
+ let(:job_id) { "1625859001514-vvqfwj" }
39
+ let(:mediaconvert) { Aws::MediaConvert::Client.new(stub_responses: true) }
40
+ let(:cloudwatch_events) { Aws::CloudWatchEvents::Client.new(stub_responses: true) }
41
+ let(:cloudwatch_logs) { Aws::CloudWatchLogs::Client.new(stub_responses: true) }
42
+
43
+ before do
44
+ mediaconvert.stub_responses(:describe_endpoints, reconstitute_response("media_convert/endpoints.json"))
45
+
46
+ allow(Aws::MediaConvert::Client).to receive(:new).and_return(mediaconvert)
47
+ allow(Aws::CloudWatchEvents::Client).to receive(:new).and_return(cloudwatch_events)
48
+ allow(Aws::CloudWatchLogs::Client).to receive(:new).and_return(cloudwatch_logs)
49
+ end
50
+
51
+ let(:created_job) do
52
+ mediaconvert.stub_responses(:create_job, reconstitute_response("media_convert/job_created.json"))
53
+
54
+ ActiveEncode::Base.create(
55
+ "s3://input-bucket/test_files/source_file.mp4",
56
+ output_prefix: "active-encode-test/output",
57
+ outputs: [
58
+ { preset: "System-Avc_16x9_1080p_29_97fps_8500kbps", modifier: "-1080" },
59
+ { preset: "System-Avc_16x9_720p_29_97fps_5000kbps", modifier: "-720" },
60
+ { preset: "System-Avc_16x9_540p_29_97fps_3500kbps", modifier: "-540" }
61
+ ],
62
+ use_original_url: true
63
+ )
64
+ end
65
+
66
+ let(:running_job) do
67
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_progressing.json"))
68
+ ActiveEncode::Base.find(job_id)
69
+ end
70
+
71
+ let(:canceled_job) do
72
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_canceled.json"))
73
+ ActiveEncode::Base.find(job_id)
74
+ end
75
+
76
+ let(:cancelling_job) do
77
+ mediaconvert.stub_responses(:cancel_job, reconstitute_response("media_convert/job_canceling.json"))
78
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_canceled.json"))
79
+ ActiveEncode::Base.find(job_id)
80
+ end
81
+
82
+ let(:completed_job) do
83
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_completed.json"))
84
+ cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
85
+ cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_detail.json"))
86
+
87
+ ActiveEncode::Base.find(job_id)
88
+ end
89
+
90
+ let(:recent_completed_job_without_results) do
91
+ job_response = reconstitute_response("media_convert/job_completed.json")
92
+ job_response["job"]["timing"]["finish_time"] = 5.minutes.ago
93
+ mediaconvert.stub_responses(:get_job, job_response)
94
+ cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
95
+ cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_empty_detail.json"))
96
+
97
+ ActiveEncode::Base.find(job_id)
98
+ end
99
+
100
+ let(:failed_job) do
101
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_failed.json"))
102
+
103
+ ActiveEncode::Base.find(job_id)
104
+ end
105
+
106
+ let(:completed_output) do
107
+ [
108
+ { id: "1625859001514-vvqfwj-output-auto", url: "s3://output-bucket/active-encode-test/output.m3u8",
109
+ label: "output.m3u8", audio_codec: "AAC", duration: 888_020, video_codec: "H_264" },
110
+ { id: "1625859001514-vvqfwj-output-1080", url: "s3://output-bucket/active-encode-test/output-1080.m3u8",
111
+ label: "output-1080.m3u8", audio_bitrate: 128_000, audio_codec: "AAC", duration: 888_020,
112
+ video_bitrate: 8_500_000, height: 1080, width: 1920, video_codec: "H_264", frame_rate: 29.97 },
113
+ { id: "1625859001514-vvqfwj-output-720", url: "s3://output-bucket/active-encode-test/output-720.m3u8",
114
+ label: "output-720.m3u8", audio_bitrate: 96_000, audio_codec: "AAC", duration: 888_020,
115
+ video_bitrate: 5_000_000, height: 720, width: 1280, video_codec: "H_264", frame_rate: 29.97 },
116
+ { id: "1625859001514-vvqfwj-output-540", url: "s3://output-bucket/active-encode-test/output-540.m3u8",
117
+ label: "output-540.m3u8", audio_bitrate: 96_000, audio_codec: "AAC", duration: 888_020,
118
+ video_bitrate: 3_500_000, height: 540, width: 960, video_codec: "H_264", frame_rate: 29.97 }
119
+ ]
120
+ end
121
+ let(:completed_tech_metadata) { {} }
122
+ let(:failed_tech_metadata) { {} }
123
+
124
+ it_behaves_like "an ActiveEncode::EngineAdapter"
125
+
126
+ describe "output" do
127
+ it "contains all expected outputs" do
128
+ completed_output.each do |expected_output|
129
+ found_output = completed_job.output.find { |output| output.id == expected_output[:id] }
130
+ expected_output.each_pair do |key, value|
131
+ expect(found_output.send(key)).to eq(value)
132
+ end
133
+ end
134
+ end
135
+
136
+ it "has no logging entries but finished within the last 10 minutes" do
137
+ expect(recent_completed_job_without_results.state).to eq(:running)
138
+ end
139
+
140
+ it "finished more than 10 minutes ago but has no logging entries" do
141
+ mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_completed.json"))
142
+ cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
143
+ cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_empty_detail.json"))
144
+
145
+ expect { ActiveEncode::Base.find(job_id) }.to raise_error do |error|
146
+ expect(error).to be_a(ActiveEncode::EngineAdapters::MediaConvertAdapter::ResultsNotAvailable)
147
+ expect(error.encode).to be_a(ActiveEncode::Base)
148
+ expect(error.encode.state).to eq(:completed)
149
+ end
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+ require 'rails_helper'
3
+ require 'active_encode/spec/shared_specs'
4
+
5
+ describe ActiveEncode::EngineAdapters::PassThroughAdapter do
6
+ around do |example|
7
+ ActiveEncode::Base.engine_adapter = :pass_through
8
+
9
+ Dir.mktmpdir do |dir|
10
+ @dir = dir
11
+ example.run
12
+ Dir.foreach(dir) do |e|
13
+ next if e == "." || e == ".."
14
+ FileUtils.rm_rf(File.join(dir, e))
15
+ end
16
+ end
17
+
18
+ ActiveEncode::Base.engine_adapter = :test
19
+ end
20
+
21
+ let!(:work_dir) { stub_const "ActiveEncode::EngineAdapters::PassThroughAdapter::WORK_DIR", @dir }
22
+ let(:file) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'fireworks.mp4').to_s }
23
+ let(:low_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'fireworks.low.mp4').to_s }
24
+ let(:created_job) do
25
+ ActiveEncode::Base.create(file, outputs: [{ label: 'low', url: low_derivative }])
26
+ end
27
+ let(:running_job) do
28
+ created_job
29
+ end
30
+ let(:canceled_job) do
31
+ find_encode 'cancelled-id'
32
+ end
33
+ let(:cancelling_job) do
34
+ find_encode 'running-id'
35
+ end
36
+ let(:completed_job) { find_encode "completed-id" }
37
+ let(:failed_job) { find_encode 'failed-id' }
38
+ let(:completed_tech_metadata) do
39
+ {
40
+ audio_bitrate: 171_030,
41
+ audio_codec: 'mp4a-40-2',
42
+ duration: 6315.0,
43
+ file_size: 199_160,
44
+ frame_rate: 23.719,
45
+ height: 110.0,
46
+ id: "completed-id",
47
+ url: "/home/pdinh/Downloads/videoshort.mp4",
48
+ video_bitrate: 74_477,
49
+ video_codec: 'avc1',
50
+ width: 200.0
51
+ }
52
+ end
53
+ let(:completed_output) { [{ id: "completed-id" }] }
54
+ let(:failed_tech_metadata) { {} }
55
+
56
+ it_behaves_like "an ActiveEncode::EngineAdapter"
57
+
58
+ def find_encode(id)
59
+ # Precreate ffmpeg output directory and files
60
+ FileUtils.copy_entry "spec/fixtures/pass_through/#{id}", "#{work_dir}/#{id}"
61
+
62
+ # Simulate that progress is modified later than other files
63
+ sleep 0.1
64
+ FileUtils.touch Dir.glob("#{work_dir}/#{id}/*.mp4")
65
+ touch_fixture(id, "completed")
66
+ touch_fixture(id, "cancelled")
67
+ touch_fixture(id, "error.log")
68
+
69
+ # Stub out system calls
70
+ allow_any_instance_of(ActiveEncode::EngineAdapters::PassThroughAdapter).to receive(:`).and_return(1234)
71
+
72
+ ActiveEncode::Base.find(id)
73
+ end
74
+
75
+ def touch_fixture(id, filename)
76
+ FileUtils.touch("#{work_dir}/#{id}/#{filename}") if File.exist? "#{work_dir}/#{id}/#{filename}"
77
+ end
78
+
79
+ describe "#create" do
80
+ subject { created_job }
81
+
82
+ it "creates a directory whose name is the encode id" do
83
+ expect(File).to exist("#{work_dir}/#{subject.id}")
84
+ end
85
+
86
+ context "input file exists" do
87
+ it "has the input technical metadata in a file" do
88
+ expect(File.read("#{work_dir}/#{subject.id}/input_metadata")).not_to be_empty
89
+ end
90
+ end
91
+
92
+ context "input file doesn't exist" do
93
+ let(:missing_file) { "file:///a_bogus_file.mp4" }
94
+ let(:missing_job) { ActiveEncode::Base.create(missing_file, outputs: [{ label: "low", url: 'mp4' }]) }
95
+
96
+ it "returns the encode with correct error" do
97
+ expect(missing_job.errors).to include("#{missing_file} does not exist or is not accessible")
98
+ expect(missing_job.percent_complete).to be 1
99
+ end
100
+ end
101
+
102
+ context "input file is not media" do
103
+ let(:nonmedia_file) { "file://" + Rails.root.join('Gemfile').to_s }
104
+ let(:nonmedia_job) { ActiveEncode::Base.create(nonmedia_file, outputs: [{ label: "low", url: nonmedia_file }]) }
105
+
106
+ it "returns the encode with correct error" do
107
+ expect(nonmedia_job.errors).to include("Error inspecting input: #{nonmedia_file}")
108
+ expect(nonmedia_job.percent_complete).to be 1
109
+ end
110
+ end
111
+
112
+ context "input filename with spaces" do
113
+ let(:file_with_space) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.mp4').to_s }
114
+ let(:file_with_space_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.low.mp4').to_s }
115
+ let!(:create_space_job) { ActiveEncode::Base.create(file_with_space, outputs: [{ label: "low", url: file_with_space_derivative }]) }
116
+ let(:find_space_job) { ActiveEncode::Base.find create_space_job.id }
117
+
118
+ it "does not have errors" do
119
+ expect(find_space_job.errors).to be_empty
120
+ end
121
+
122
+ it "has the input technical metadata in a file" do
123
+ expect(File.read("#{work_dir}/#{create_space_job.id}/input_metadata")).not_to be_empty
124
+ end
125
+
126
+ context 'when uri encoded' do
127
+ let(:file_with_space) { URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.mp4').to_s) }
128
+ let(:file_with_space_derivative) { URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.low.mp4').to_s) }
129
+
130
+ it "does not have errors" do
131
+ expect(find_space_job.errors).to be_empty
132
+ end
133
+
134
+ it "has the input technical metadata in a file" do
135
+ expect(File.read("#{work_dir}/#{create_space_job.id}/input_metadata")).not_to be_empty
136
+ end
137
+ end
138
+ end
139
+
140
+ context 'when failed' do
141
+ subject { created_job }
142
+
143
+ before do
144
+ allow_any_instance_of(Object).to receive(:`).and_raise Errno::ENOENT
145
+ end
146
+
147
+ it { is_expected.to be_failed }
148
+ it { expect(subject.errors).to be_present }
149
+ end
150
+ end
151
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'zencoder'
3
4
  require 'json'
@@ -24,66 +25,66 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
24
25
  allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
25
26
  end
26
27
 
28
+ subject { ActiveEncode::Base.create(file) }
27
29
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_create.json'))) }
28
30
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_create.json'))) }
29
31
  let(:create_output) { [{ id: "511404522", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527", label: nil }] }
30
32
 
31
- subject { ActiveEncode::Base.create(file) }
32
33
  it { is_expected.to be_a ActiveEncode::Base }
33
- its(:id) { is_expected.not_to be_empty }
34
+ it { expect(subject.id).not_to be_empty }
34
35
  it { is_expected.to be_running }
35
- # its(:output) { is_expected.to eq create_output }
36
- its(:current_operations) { is_expected.to be_empty }
37
- its(:percent_complete) { is_expected.to eq 0 }
38
- its(:errors) { is_expected.to be_empty }
39
- its(:created_at) { is_expected.to eq '2015-06-10T14:38:47Z' }
40
- its(:updated_at) { is_expected.to eq '2015-06-10T14:38:47Z' }
36
+ # it { expect(subject.output).to eq create_output }
37
+ it { expect(subject.current_operations).to be_empty }
38
+ it { expect(subject.percent_complete).to eq 0 }
39
+ it { expect(subject.errors).to be_empty }
40
+ it { expect(subject.created_at).to eq '2015-06-10T14:38:47Z' }
41
+ it { expect(subject.updated_at).to eq '2015-06-10T14:38:47Z' }
41
42
 
42
43
  context 'input' do
43
44
  subject { ActiveEncode::Base.create(file).input }
44
45
 
45
46
  it { is_expected.to be_a ActiveEncode::Input }
46
- its(:id) { is_expected.to eq "166179248" }
47
- its(:url) { is_expected.to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
48
- its(:width) { is_expected.to be_blank }
49
- its(:height) { is_expected.to be_blank }
50
- its(:frame_rate) { is_expected.to be_blank }
51
- its(:duration) { is_expected.to be_blank }
52
- its(:file_size) { is_expected.to be_blank }
53
- its(:checksum) { is_expected.to be_blank }
54
- its(:audio_codec) { is_expected.to be_blank }
55
- its(:video_codec) { is_expected.to be_blank }
56
- its(:audio_bitrate) { is_expected.to be_blank }
57
- its(:video_bitrate) { is_expected.to be_blank }
58
- its(:state) { is_expected.to eq :running }
59
- its(:created_at) { is_expected.to eq "2015-06-10T14:38:47Z" }
60
- its(:updated_at) { is_expected.to eq "2015-06-10T14:38:00Z" }
47
+ it { expect(subject.id).to eq "166179248" }
48
+ it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
49
+ it { expect(subject.width).to be_blank }
50
+ it { expect(subject.height).to be_blank }
51
+ it { expect(subject.frame_rate).to be_blank }
52
+ it { expect(subject.duration).to be_blank }
53
+ it { expect(subject.file_size).to be_blank }
54
+ it { expect(subject.checksum).to be_blank }
55
+ it { expect(subject.audio_codec).to be_blank }
56
+ it { expect(subject.video_codec).to be_blank }
57
+ it { expect(subject.audio_bitrate).to be_blank }
58
+ it { expect(subject.video_bitrate).to be_blank }
59
+ it { expect(subject.state).to eq :running }
60
+ it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
61
+ it { expect(subject.updated_at).to eq "2015-06-10T14:38:00Z" }
61
62
  end
62
63
 
63
64
  context 'output' do
64
- let(:output) { ActiveEncode::Base.find('166019107').reload.output }
65
65
  subject { output.first }
66
+ let(:output) { ActiveEncode::Base.find('166019107').reload.output }
66
67
 
67
68
  it 'is an array' do
68
69
  expect(output).to be_a Array
69
70
  end
70
71
  it { is_expected.to be_a ActiveEncode::Output }
71
- its(:id) { is_expected.to eq "511404522" }
72
- its(:url) { is_expected.to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527" }
73
- its(:label) { is_expected.to be_blank }
74
- its(:width) { is_expected.to be_blank }
75
- its(:height) { is_expected.to be_blank }
76
- its(:frame_rate) { is_expected.to be_blank }
77
- its(:duration) { is_expected.to be_blank }
78
- its(:file_size) { is_expected.to be_blank }
79
- its(:checksum) { is_expected.to be_blank }
80
- its(:audio_codec) { is_expected.to be_blank }
81
- its(:video_codec) { is_expected.to be_blank }
82
- its(:audio_bitrate) { is_expected.to be_blank }
83
- its(:video_bitrate) { is_expected.to be_blank }
84
- its(:state) { is_expected.to eq :running }
85
- its(:created_at) { is_expected.to eq "2015-06-10T14:38:47Z" }
86
- its(:updated_at) { is_expected.to eq "2015-06-10T14:38:47Z" }
72
+ it { expect(subject.id).to eq "511404522" }
73
+ it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527" }
74
+ it { expect(subject.label).to be_blank }
75
+ it { expect(subject.width).to be_blank }
76
+ it { expect(subject.height).to be_blank }
77
+ it { expect(subject.frame_rate).to be_blank }
78
+ it { expect(subject.duration).to be_blank }
79
+ it { expect(subject.file_size).to be_blank }
80
+ it { expect(subject.checksum).to be_blank }
81
+ it { expect(subject.audio_codec).to be_blank }
82
+ it { expect(subject.video_codec).to be_blank }
83
+ it { expect(subject.audio_bitrate).to be_blank }
84
+ it { expect(subject.video_bitrate).to be_blank }
85
+ it { expect(subject.state).to eq :running }
86
+ it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
87
+ it { expect(subject.updated_at).to eq "2015-06-10T14:38:47Z" }
87
88
  end
88
89
  end
89
90
 
@@ -94,208 +95,208 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
94
95
  end
95
96
 
96
97
  context "a running encode" do
98
+ subject { ActiveEncode::Base.find('166019107') }
97
99
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
98
100
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
99
101
  # let(:running_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
100
102
  # let(:running_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
101
103
 
102
- subject { ActiveEncode::Base.find('166019107') }
103
104
  it { is_expected.to be_a ActiveEncode::Base }
104
- its(:id) { is_expected.to eq '166019107' }
105
+ it { expect(subject.id).to eq '166019107' }
105
106
  it { is_expected.to be_running }
106
- # its(:output) { is_expected.to eq running_output }
107
- its(:current_operations) { is_expected.to be_empty }
108
- its(:percent_complete) { is_expected.to eq 30.0 }
109
- its(:errors) { is_expected.to be_empty }
110
- its(:created_at) { is_expected.to eq '2015-06-09T16:18:26Z' }
111
- its(:updated_at) { is_expected.to eq '2015-06-09T16:18:28Z' }
112
-
113
- # its(:tech_metadata) { is_expected.to eq running_tech_metadata }
107
+ # it { expect(subject.output).to eq running_output }
108
+ it { expect(subject.current_operations).to be_empty }
109
+ it { expect(subject.percent_complete).to eq 30.0 }
110
+ it { expect(subject.errors).to be_empty }
111
+ it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
112
+ it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }
113
+
114
+ # it { expect(subject.tech_metadata).to eq running_tech_metadata }
114
115
  context 'input' do
115
116
  subject { ActiveEncode::Base.find('166019107').input }
116
117
 
117
118
  it { is_expected.to be_a ActiveEncode::Input }
118
- its(:id) { is_expected.to eq "165990056" }
119
- its(:url) { is_expected.to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
120
- its(:width) { is_expected.to eq 320 }
121
- its(:height) { is_expected.to eq 240 }
122
- its(:frame_rate) { is_expected.to eq 29.97 }
123
- its(:duration) { is_expected.to eq 57992 }
124
- its(:file_size) { is_expected.to be_blank }
125
- its(:checksum) { is_expected.to be_blank }
126
- its(:audio_codec) { is_expected.to eq "aac" }
127
- its(:video_codec) { is_expected.to eq "h264" }
128
- its(:audio_bitrate) { is_expected.to eq 52 }
129
- its(:video_bitrate) { is_expected.to eq 535 }
130
- its(:state) { is_expected.to eq :completed }
131
- its(:created_at) { is_expected.to eq "2015-06-09T16:18:26Z" }
132
- its(:updated_at) { is_expected.to eq "2015-06-09T16:18:32Z" }
119
+ it { expect(subject.id).to eq "165990056" }
120
+ it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
121
+ it { expect(subject.width).to eq 320 }
122
+ it { expect(subject.height).to eq 240 }
123
+ it { expect(subject.frame_rate).to eq 29.97 }
124
+ it { expect(subject.duration).to eq 57_992 }
125
+ it { expect(subject.file_size).to be_blank }
126
+ it { expect(subject.checksum).to be_blank }
127
+ it { expect(subject.audio_codec).to eq "aac" }
128
+ it { expect(subject.video_codec).to eq "h264" }
129
+ it { expect(subject.audio_bitrate).to eq 52 }
130
+ it { expect(subject.video_bitrate).to eq 535 }
131
+ it { expect(subject.state).to eq :completed }
132
+ it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
133
+ it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
133
134
  end
134
135
 
135
136
  context 'output' do
136
- let(:output) { ActiveEncode::Base.find('166019107').output }
137
137
  subject { output.first }
138
+ let(:output) { ActiveEncode::Base.find('166019107').output }
138
139
 
139
140
  it 'is an array' do
140
141
  expect(output).to be_a Array
141
142
  end
142
143
  it { is_expected.to be_a ActiveEncode::Output }
143
- its(:id) { is_expected.to eq "510582971" }
144
- its(:url) { is_expected.to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
145
- its(:label) { is_expected.to be_blank }
146
- its(:width) { is_expected.to be_blank }
147
- its(:height) { is_expected.to be_blank }
148
- its(:frame_rate) { is_expected.to be_blank }
149
- its(:duration) { is_expected.to be_blank }
150
- its(:file_size) { is_expected.to be_blank }
151
- its(:checksum) { is_expected.to be_blank }
152
- its(:audio_codec) { is_expected.to be_blank }
153
- its(:video_codec) { is_expected.to be_blank }
154
- its(:audio_bitrate) { is_expected.to be_blank }
155
- its(:video_bitrate) { is_expected.to be_blank }
156
- its(:state) { is_expected.to eq :running }
157
- its(:created_at) { is_expected.to eq "2015-06-09T16:18:26Z" }
158
- its(:updated_at) { is_expected.to eq "2015-06-09T16:18:32Z" }
144
+ it { expect(subject.id).to eq "510582971" }
145
+ it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
146
+ it { expect(subject.label).to be_blank }
147
+ it { expect(subject.width).to be_blank }
148
+ it { expect(subject.height).to be_blank }
149
+ it { expect(subject.frame_rate).to be_blank }
150
+ it { expect(subject.duration).to be_blank }
151
+ it { expect(subject.file_size).to be_blank }
152
+ it { expect(subject.checksum).to be_blank }
153
+ it { expect(subject.audio_codec).to be_blank }
154
+ it { expect(subject.video_codec).to be_blank }
155
+ it { expect(subject.audio_bitrate).to be_blank }
156
+ it { expect(subject.video_bitrate).to be_blank }
157
+ it { expect(subject.state).to eq :running }
158
+ it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
159
+ it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
159
160
  end
160
161
  end
161
162
 
162
163
  context "a cancelled encode" do
164
+ subject { ActiveEncode::Base.find('165866551') }
163
165
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
164
166
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }
165
167
 
166
- subject { ActiveEncode::Base.find('165866551') }
167
168
  it { is_expected.to be_a ActiveEncode::Base }
168
- its(:id) { is_expected.to eq '165866551' }
169
+ it { expect(subject.id).to eq '165866551' }
169
170
  it { is_expected.to be_cancelled }
170
- its(:current_operations) { is_expected.to be_empty }
171
- its(:percent_complete) { is_expected.to eq 0 }
172
- its(:errors) { is_expected.to be_empty }
173
- its(:created_at) { is_expected.to eq '2015-06-08T20:43:23Z' }
174
- its(:updated_at) { is_expected.to eq '2015-06-08T20:43:26Z' }
171
+ it { expect(subject.current_operations).to be_empty }
172
+ it { expect(subject.percent_complete).to eq 0 }
173
+ it { expect(subject.errors).to be_empty }
174
+ it { expect(subject.created_at).to eq '2015-06-08T20:43:23Z' }
175
+ it { expect(subject.updated_at).to eq '2015-06-08T20:43:26Z' }
175
176
 
176
177
  context 'input' do
177
178
  subject { ActiveEncode::Base.find('165866551').input }
178
179
 
179
180
  it { is_expected.to be_a ActiveEncode::Input }
180
- its(:id) { is_expected.to eq "165837500" }
181
- its(:url) { is_expected.to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
182
- its(:width) { is_expected.to be_blank }
183
- its(:height) { is_expected.to be_blank }
184
- its(:frame_rate) { is_expected.to be_blank }
185
- its(:duration) { is_expected.to be_blank }
186
- its(:file_size) { is_expected.to be_blank }
187
- its(:checksum) { is_expected.to be_blank }
188
- its(:audio_codec) { is_expected.to be_blank }
189
- its(:video_codec) { is_expected.to be_blank }
190
- its(:audio_bitrate) { is_expected.to be_blank }
191
- its(:video_bitrate) { is_expected.to be_blank }
192
- its(:state) { is_expected.to eq :cancelled }
193
- its(:created_at) { is_expected.to eq "2015-06-08T20:43:23Z" }
194
- its(:updated_at) { is_expected.to eq "2015-06-08T20:43:26Z" }
181
+ it { expect(subject.id).to eq "165837500" }
182
+ it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
183
+ it { expect(subject.width).to be_blank }
184
+ it { expect(subject.height).to be_blank }
185
+ it { expect(subject.frame_rate).to be_blank }
186
+ it { expect(subject.duration).to be_blank }
187
+ it { expect(subject.file_size).to be_blank }
188
+ it { expect(subject.checksum).to be_blank }
189
+ it { expect(subject.audio_codec).to be_blank }
190
+ it { expect(subject.video_codec).to be_blank }
191
+ it { expect(subject.audio_bitrate).to be_blank }
192
+ it { expect(subject.video_bitrate).to be_blank }
193
+ it { expect(subject.state).to eq :cancelled }
194
+ it { expect(subject.created_at).to eq "2015-06-08T20:43:23Z" }
195
+ it { expect(subject.updated_at).to eq "2015-06-08T20:43:26Z" }
195
196
  end
196
197
  end
197
198
 
198
199
  context "a completed encode" do
200
+ subject { ActiveEncode::Base.find('165839139') }
199
201
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_completed.json'))) }
200
202
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_completed.json'))) }
201
203
  let(:completed_output) { { id: "509856876", audio_bitrate: "53", audio_codec: "aac", audio_channels: "2", duration: "5000", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "549", video_codec: "h264", width: "320", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646", label: nil } }
202
204
  # let(:completed_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
203
205
 
204
- subject { ActiveEncode::Base.find('165839139') }
205
206
  it { is_expected.to be_a ActiveEncode::Base }
206
- its(:id) { is_expected.to eq '165839139' }
207
+ it { expect(subject.id).to eq '165839139' }
207
208
  it { is_expected.to be_completed }
208
- # its(:output) { is_expected.to include completed_output }
209
- its(:current_operations) { is_expected.to be_empty }
210
- its(:percent_complete) { is_expected.to eq 100 }
211
- its(:errors) { is_expected.to be_empty }
212
- its(:created_at) { is_expected.to eq '2015-06-08T18:13:53Z' }
213
- its(:updated_at) { is_expected.to eq '2015-06-08T18:14:06Z' }
209
+ # it { expect(subject.output).to include completed_output }
210
+ it { expect(subject.current_operations).to be_empty }
211
+ it { expect(subject.percent_complete).to eq 100 }
212
+ it { expect(subject.errors).to be_empty }
213
+ it { expect(subject.created_at).to eq '2015-06-08T18:13:53Z' }
214
+ it { expect(subject.updated_at).to eq '2015-06-08T18:14:06Z' }
214
215
 
215
216
  context 'input' do
216
217
  subject { ActiveEncode::Base.find('165839139').input }
217
218
 
218
219
  it { is_expected.to be_a ActiveEncode::Input }
219
- its(:id) { is_expected.to eq "165810088" }
220
- its(:url) { is_expected.to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
221
- its(:width) { is_expected.to eq 320 }
222
- its(:height) { is_expected.to eq 240 }
223
- its(:frame_rate) { is_expected.to eq 29.97 }
224
- its(:duration) { is_expected.to eq 57992 }
225
- its(:file_size) { is_expected.to be_blank }
226
- its(:checksum) { is_expected.to be_blank }
227
- its(:audio_codec) { is_expected.to eq "aac" }
228
- its(:video_codec) { is_expected.to eq "h264" }
229
- its(:audio_bitrate) { is_expected.to eq 52 }
230
- its(:video_bitrate) { is_expected.to eq 535 }
231
- its(:state) { is_expected.to eq :completed }
232
- its(:created_at) { is_expected.to eq "2015-06-08T18:13:53Z" }
233
- its(:updated_at) { is_expected.to eq "2015-06-08T18:14:06Z" }
220
+ it { expect(subject.id).to eq "165810088" }
221
+ it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
222
+ it { expect(subject.width).to eq 320 }
223
+ it { expect(subject.height).to eq 240 }
224
+ it { expect(subject.frame_rate).to eq 29.97 }
225
+ it { expect(subject.duration).to eq 57_992 }
226
+ it { expect(subject.file_size).to be_blank }
227
+ it { expect(subject.checksum).to be_blank }
228
+ it { expect(subject.audio_codec).to eq "aac" }
229
+ it { expect(subject.video_codec).to eq "h264" }
230
+ it { expect(subject.audio_bitrate).to eq 52 }
231
+ it { expect(subject.video_bitrate).to eq 535 }
232
+ it { expect(subject.state).to eq :completed }
233
+ it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
234
+ it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
234
235
  end
235
236
 
236
237
  context 'output' do
237
- let(:output) { ActiveEncode::Base.find('166019107').reload.output }
238
238
  subject { output.first }
239
+ let(:output) { ActiveEncode::Base.find('166019107').reload.output }
239
240
 
240
241
  it 'is an array' do
241
242
  expect(output).to be_a Array
242
243
  end
243
244
  it { is_expected.to be_a ActiveEncode::Output }
244
- its(:id) { is_expected.to eq "509856876" }
245
- its(:url) { is_expected.to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646" }
246
- its(:label) { is_expected.to be_blank }
247
- its(:width) { is_expected.to eq 320 }
248
- its(:height) { is_expected.to eq 240 }
249
- its(:frame_rate) { is_expected.to eq 29.97 }
250
- its(:duration) { is_expected.to eq 5000 }
251
- its(:file_size) { is_expected.to be_blank }
252
- its(:checksum) { is_expected.to be_blank }
253
- its(:audio_codec) { is_expected.to eq "aac" }
254
- its(:video_codec) { is_expected.to eq "h264" }
255
- its(:audio_bitrate) { is_expected.to eq 53 }
256
- its(:video_bitrate) { is_expected.to eq 549 }
257
- its(:state) { is_expected.to eq :completed }
258
- its(:created_at) { is_expected.to eq "2015-06-08T18:13:53Z" }
259
- its(:updated_at) { is_expected.to eq "2015-06-08T18:14:06Z" }
245
+ it { expect(subject.id).to eq "509856876" }
246
+ it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646" }
247
+ it { expect(subject.label).to be_blank }
248
+ it { expect(subject.width).to eq 320 }
249
+ it { expect(subject.height).to eq 240 }
250
+ it { expect(subject.frame_rate).to eq 29.97 }
251
+ it { expect(subject.duration).to eq 5000 }
252
+ it { expect(subject.file_size).to be_blank }
253
+ it { expect(subject.checksum).to be_blank }
254
+ it { expect(subject.audio_codec).to eq "aac" }
255
+ it { expect(subject.video_codec).to eq "h264" }
256
+ it { expect(subject.audio_bitrate).to eq 53 }
257
+ it { expect(subject.video_bitrate).to eq 549 }
258
+ it { expect(subject.state).to eq :completed }
259
+ it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
260
+ it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
260
261
  end
261
262
  end
262
263
 
263
264
  context "a failed encode" do
265
+ subject { ActiveEncode::Base.find('166079902') }
264
266
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_failed.json'))) }
265
267
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_failed.json'))) }
266
268
  let(:failed_tech_metadata) { { mime_type: "video/mp4", checksum: "7ae24368ccb7a6c6422a14ff73f33c9a", duration: "6314", audio_codec: "AAC", audio_channels: "2", audio_bitrate: "171030.0", video_codec: "AVC", video_bitrate: "74477.0", video_framerate: "23.719", width: "200", height: "110" } }
267
269
  let(:failed_errors) { "The file is an XML file, and doesn't contain audio or video tracks." }
268
270
 
269
- subject { ActiveEncode::Base.find('166079902') }
270
271
  it { is_expected.to be_a ActiveEncode::Base }
271
- its(:id) { is_expected.to eq '166079902' }
272
+ it { expect(subject.id).to eq '166079902' }
272
273
  it { is_expected.to be_failed }
273
- its(:current_operations) { is_expected.to be_empty }
274
- its(:percent_complete) { is_expected.to eq 0 }
275
- its(:errors) { is_expected.to be_empty }
276
- its(:created_at) { is_expected.to eq '2015-06-09T20:52:57Z' }
277
- its(:updated_at) { is_expected.to eq '2015-06-09T20:53:00Z' }
274
+ it { expect(subject.current_operations).to be_empty }
275
+ it { expect(subject.percent_complete).to eq 0 }
276
+ it { expect(subject.errors).to be_empty }
277
+ it { expect(subject.created_at).to eq '2015-06-09T20:52:57Z' }
278
+ it { expect(subject.updated_at).to eq '2015-06-09T20:53:00Z' }
278
279
 
279
280
  context 'input' do
280
281
  subject { ActiveEncode::Base.find('165866551').input }
281
282
 
282
283
  it { is_expected.to be_a ActiveEncode::Input }
283
- its(:id) { is_expected.to eq "166050851" }
284
- its(:url) { is_expected.to eq "s3://zencoder-customer-ingest/uploads/2015-06-09/240330/187007/682c2d90-0eea-11e5-84c9-f158f44c3d50.xml" }
285
- its(:errors) { is_expected.to include failed_errors }
286
- its(:width) { is_expected.to be_blank }
287
- its(:height) { is_expected.to be_blank }
288
- its(:frame_rate) { is_expected.to be_blank }
289
- its(:duration) { is_expected.to be_blank }
290
- its(:file_size) { is_expected.to be_blank }
291
- its(:checksum) { is_expected.to be_blank }
292
- its(:audio_codec) { is_expected.to be_blank }
293
- its(:video_codec) { is_expected.to be_blank }
294
- its(:audio_bitrate) { is_expected.to be_blank }
295
- its(:video_bitrate) { is_expected.to be_blank }
296
- its(:state) { is_expected.to eq :failed }
297
- its(:created_at) { is_expected.to eq "2015-06-09T20:52:57Z" }
298
- its(:updated_at) { is_expected.to eq "2015-06-09T20:53:00Z" }
284
+ it { expect(subject.id).to eq "166050851" }
285
+ it { expect(subject.url).to eq "s3://zencoder-customer-ingest/uploads/2015-06-09/240330/187007/682c2d90-0eea-11e5-84c9-f158f44c3d50.xml" }
286
+ it { expect(subject.errors).to include failed_errors }
287
+ it { expect(subject.width).to be_blank }
288
+ it { expect(subject.height).to be_blank }
289
+ it { expect(subject.frame_rate).to be_blank }
290
+ it { expect(subject.duration).to be_blank }
291
+ it { expect(subject.file_size).to be_blank }
292
+ it { expect(subject.checksum).to be_blank }
293
+ it { expect(subject.audio_codec).to be_blank }
294
+ it { expect(subject.video_codec).to be_blank }
295
+ it { expect(subject.audio_bitrate).to be_blank }
296
+ it { expect(subject.video_bitrate).to be_blank }
297
+ it { expect(subject.state).to eq :failed }
298
+ it { expect(subject.created_at).to eq "2015-06-09T20:52:57Z" }
299
+ it { expect(subject.updated_at).to eq "2015-06-09T20:53:00Z" }
299
300
  end
300
301
  end
301
302
  end
@@ -307,14 +308,14 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
307
308
  allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
308
309
  end
309
310
 
311
+ subject { encode.cancel! }
310
312
  let(:cancel_response) { Zencoder::Response.new(code: 200) } # TODO: check that this is the correct response code for a successful cancel
311
313
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
312
314
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }
313
315
 
314
316
  let(:encode) { ActiveEncode::Base.create(file) }
315
- subject { encode.cancel! }
316
317
  it { is_expected.to be_a ActiveEncode::Base }
317
- its(:id) { is_expected.to eq '165866551' }
318
+ it { expect(subject.id).to eq '165866551' }
318
319
  it { is_expected.to be_cancelled }
319
320
  end
320
321
 
@@ -324,67 +325,67 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
324
325
  allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
325
326
  end
326
327
 
328
+ subject { ActiveEncode::Base.find('166019107').reload }
327
329
  let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
328
330
  let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
329
331
  # let(:reload_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
330
332
  # let(:reload_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
331
333
 
332
- subject { ActiveEncode::Base.find('166019107').reload }
333
334
  it { is_expected.to be_a ActiveEncode::Base }
334
- its(:id) { is_expected.to eq '166019107' }
335
+ it { expect(subject.id).to eq '166019107' }
335
336
  it { is_expected.to be_running }
336
- # its(:output) { is_expected.to eq reload_output }
337
- its(:current_operations) { is_expected.to be_empty }
338
- its(:percent_complete) { is_expected.to eq 30.0 }
339
- its(:errors) { is_expected.to be_empty }
340
- its(:created_at) { is_expected.to eq '2015-06-09T16:18:26Z' }
341
- its(:updated_at) { is_expected.to eq '2015-06-09T16:18:28Z' }
337
+ # it { expect(subject.output).to eq reload_output }
338
+ it { expect(subject.current_operations).to be_empty }
339
+ it { expect(subject.percent_complete).to eq 30.0 }
340
+ it { expect(subject.errors).to be_empty }
341
+ it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
342
+ it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }
342
343
 
343
344
  context 'input' do
344
345
  subject { ActiveEncode::Base.find('166019107').reload.input }
345
346
 
346
347
  it { is_expected.to be_a ActiveEncode::Input }
347
- its(:id) { is_expected.to eq "165990056" }
348
- its(:url) { is_expected.to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
349
- its(:width) { is_expected.to eq 320 }
350
- its(:height) { is_expected.to eq 240 }
351
- its(:frame_rate) { is_expected.to eq 29.97 }
352
- its(:duration) { is_expected.to eq 57992 }
353
- its(:file_size) { is_expected.to be_blank }
354
- its(:checksum) { is_expected.to be_blank }
355
- its(:audio_codec) { is_expected.to eq "aac" }
356
- its(:video_codec) { is_expected.to eq "h264" }
357
- its(:audio_bitrate) { is_expected.to eq 52 }
358
- its(:video_bitrate) { is_expected.to eq 535 }
359
- its(:state) { is_expected.to eq :completed }
360
- its(:created_at) { is_expected.to eq "2015-06-09T16:18:26Z" }
361
- its(:updated_at) { is_expected.to eq "2015-06-09T16:18:32Z" }
348
+ it { expect(subject.id).to eq "165990056" }
349
+ it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
350
+ it { expect(subject.width).to eq 320 }
351
+ it { expect(subject.height).to eq 240 }
352
+ it { expect(subject.frame_rate).to eq 29.97 }
353
+ it { expect(subject.duration).to eq 57_992 }
354
+ it { expect(subject.file_size).to be_blank }
355
+ it { expect(subject.checksum).to be_blank }
356
+ it { expect(subject.audio_codec).to eq "aac" }
357
+ it { expect(subject.video_codec).to eq "h264" }
358
+ it { expect(subject.audio_bitrate).to eq 52 }
359
+ it { expect(subject.video_bitrate).to eq 535 }
360
+ it { expect(subject.state).to eq :completed }
361
+ it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
362
+ it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
362
363
  end
363
364
 
364
365
  context 'output' do
365
- let(:output) { ActiveEncode::Base.find('166019107').reload.output }
366
366
  subject { output.first }
367
+ let(:output) { ActiveEncode::Base.find('166019107').reload.output }
367
368
 
368
369
  it 'is an array' do
369
370
  expect(output).to be_a Array
370
371
  end
371
372
  it { is_expected.to be_a ActiveEncode::Output }
372
- its(:id) { is_expected.to eq "510582971" }
373
- its(:url) { is_expected.to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
374
- its(:label) { is_expected.to be_blank }
375
- its(:width) { is_expected.to be_blank }
376
- its(:height) { is_expected.to be_blank }
377
- its(:frame_rate) { is_expected.to be_blank }
378
- its(:duration) { is_expected.to be_blank }
379
- its(:file_size) { is_expected.to be_blank }
380
- its(:checksum) { is_expected.to be_blank }
381
- its(:audio_codec) { is_expected.to be_blank }
382
- its(:video_codec) { is_expected.to be_blank }
383
- its(:audio_bitrate) { is_expected.to be_blank }
384
- its(:video_bitrate) { is_expected.to be_blank }
385
- its(:state) { is_expected.to eq :running }
386
- its(:created_at) { is_expected.to eq "2015-06-09T16:18:26Z" }
387
- its(:updated_at) { is_expected.to eq "2015-06-09T16:18:32Z" }
373
+ it { expect(subject.id).to eq "510582971" }
374
+ it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
375
+ it { expect(subject.label).to be_blank }
376
+ it { expect(subject.width).to be_blank }
377
+ it { expect(subject.height).to be_blank }
378
+ it { expect(subject.frame_rate).to be_blank }
379
+ it { expect(subject.duration).to be_blank }
380
+ it { expect(subject.file_size).to be_blank }
381
+ it { expect(subject.checksum).to be_blank }
382
+ it { expect(subject.audio_codec).to be_blank }
383
+ it { expect(subject.video_codec).to be_blank }
384
+ it { expect(subject.audio_bitrate).to be_blank }
385
+ it { expect(subject.video_bitrate).to be_blank }
386
+ it { expect(subject.state).to eq :running }
387
+ it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
388
+ it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
388
389
  end
389
390
  end
390
391
  end