spec/datamosh_spec.rb in aviglitch-0.0.3 vs spec/datamosh_spec.rb in aviglitch-0.1.0

- old
+ new

@@ -4,14 +4,14 @@ before :all do FileUtils.mkdir OUTPUT_DIR unless File.exist? OUTPUT_DIR @in = FILES_DIR + 'sample.avi' @out = OUTPUT_DIR + 'out.avi' - datamosh = Pathname.new( - File.join(File.dirname(__FILE__), '..', 'bin/datamosh') - ).realpath - @cmd = "ruby %s -o %s " % [datamosh, @out] + here = File.dirname(__FILE__) + lib = Pathname.new(File.join(here, '..', 'lib')).realpath + datamosh = Pathname.new(File.join(here, '..', 'bin/datamosh')).realpath + @cmd = "ruby -I%s %s -o %s " % [lib, datamosh, @out] end after :each do FileUtils.rm Dir.glob((OUTPUT_DIR + '*').to_s) end @@ -19,42 +19,35 @@ after :all do FileUtils.rmdir OUTPUT_DIR end it 'should correctly process files' do + a = AviGlitch.open @in + keys = a.frames.inject(0) do |c, f| + c += 1 if f.is_keyframe? + c + end + total = a.frames.size + a.close + system [@cmd, @in].join(' ') o = AviGlitch.open @out - o.frames.each_with_index do |f, i| - if f.is_keyframe? && i == 0 - f.data.should_not match /^\000+$/ - elsif f.is_keyframe? - f.data.should match /^\000+$/ - end - end + o.frames.size.should == total - keys + 1 + o.frames.first.is_keyframe?.should be true o.close AviGlitch::Base.surely_formatted?(@out, true).should be true system [@cmd, '-a', @in].join(' ') o = AviGlitch.open @out - o.frames.each do |f| - if f.is_keyframe? - f.data.should match /^\000+$/ - end - end + o.frames.size.should == total - keys + o.frames.first.is_keyframe?.should be false o.close AviGlitch::Base.surely_formatted?(@out, true).should be true system [@cmd, @in, @in, @in].join(' ') - a = AviGlitch.open @in o = AviGlitch.open @out - o.frames.size.should == a.frames.size * 3 - o.frames.each_with_index do |f, i| - if f.is_keyframe? && i == 0 - f.data.should_not match /^\000+$/ - elsif f.is_keyframe? - f.data.should match /^\000+$/ - end - end + o.frames.size.should == 1 + (total - keys) * 3 + o.frames.first.is_keyframe?.should be true o.close AviGlitch::Base.surely_formatted?(@out, true).should be true end end