spec/units/output_spec.rb in active_encode-0.2 vs spec/units/output_spec.rb in active_encode-0.4
- old
+ new
@@ -2,11 +2,38 @@
describe ActiveEncode::Output do
subject { described_class.new }
describe 'attributes' do
- it { is_expected.to respond_to(:id, :url) }
+ it { is_expected.to respond_to(:id, :url, :label) }
it { is_expected.to respond_to(:state, :errors, :created_at, :updated_at) }
it { is_expected.to respond_to(:width, :height, :frame_rate, :checksum,
:audio_codec, :video_codec, :audio_bitrate, :video_bitrate) }
+ end
+
+ describe '#valid?' do
+ let(:valid_output) do
+ described_class.new.tap do |obj|
+ obj.id = "1"
+ obj.url = "file:///tmp/video.mp4"
+ obj.label = "HD"
+ obj.created_at = Time.now
+ obj.updated_at = Time.now
+ end
+ end
+
+ it 'returns true when conditions met' do
+ expect(valid_output).to be_valid
+ end
+
+ it 'returns false when conditions not met' do
+ expect(valid_output.tap { |obj| obj.id = nil }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.url = nil }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.label = nil }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.created_at = nil }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.created_at = "today" }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.updated_at = nil }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.updated_at = "today" }).not_to be_valid
+ expect(valid_output.tap { |obj| obj.created_at = Time.now }).not_to be_valid
+ end
end
end