Skip to content

Commit

Permalink
Convert unit tests to RSpec files - two of the engine tests fail for
Browse files Browse the repository at this point in the history
mysterious reasons
  • Loading branch information
anaisbetts committed May 27, 2008
1 parent e8845e9 commit 9192ed1
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 117 deletions.
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -88,6 +88,11 @@ Rake::TestTask.new("test") do |t|
t.warning = true
end

desc "Run specifications"
Spec::Rake::SpecTask.new("spec") do |t|
t.spec_files = FileList['spec/**/*.rb']
end

desc "Run Heckle on tests"
task :heckle do |t|
# Collect a list of defined classes
Expand Down
5 changes: 5 additions & 0 deletions spec/daemonize.rb
@@ -0,0 +1,5 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/daemonize'

46 changes: 46 additions & 0 deletions spec/engine.rb
@@ -0,0 +1,46 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/engine'

describe Engine do
before do
@eng = Engine.new
end

it "should be able to extract subpaths" do
Engine.extract_subpath("/source/path", "/source/path/to/target.avi").should == "to/target.avi"
Engine.extract_subpath("", "/source/path/to/target.avi").should == "/source/path/to/target.avi"
end

it "should be able to build paths" do
Engine.build_target_path("path/test.avi", "/target/dir").should == "/target/dir/path/test.mp4"
end
end

describe FFMpegTranscoder do
before do
@fft = FFMpegTranscoder.new
end

it "should succeed a basic transcode" do
input = File.join(TestDir, 'test_files', 'MH_egyptian_pan_L2R.avi')
output = File.join(TestDir, 'tmp.avi')
@fft.transcode(input, output)

# Let's see if the file exists
opn = Pathname.new(output)
opn.exist?.should == true
opn.delete
end

it "should build an FFMpeg command line" do
input = "foo"; output = 'bar'
ret = @fft.get_command(input, output)

# FIXME: This test sucks
ret.include?(input).should == true
ret.include?(output).should == true
ret.include?("ffmpeg").should == true
end
end
2 changes: 1 addition & 1 deletion test/helper.rb → spec/helper.rb
@@ -1,9 +1,9 @@
require 'pathname'
require 'test/unit' unless defined? $ZENTEST and $ZENTEST

TestDir = File.dirname(__FILE__)

require File.join(TestDir, '..', 'lib', 'config') unless defined? $CONFIG_INCLUDED and $CONFIG_INCLUDED

path_add TestDir
path_add File.join(TestDir, '..')
path_add File.join(TestDir, '..', 'lib')
4 changes: 4 additions & 0 deletions spec/main.rb
@@ -0,0 +1,4 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/main'
23 changes: 23 additions & 0 deletions spec/platform.rb
@@ -0,0 +1,23 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/platform'

describe Platform do
it "should find our bindir" do
Platform.binary_dir.should == (AppConfig::RootDir + "/bin")
end

it "should find home dir" do
Platform.home_dir.should == "#{ENV['HOME']}"
end

it "should identify the OS" do
# TODO: This test is blatantly retarded
Platform.os.should == :osx
end

it "should find external commands" do
Platform.which("ls").should == `which ls`
end
end
5 changes: 5 additions & 0 deletions spec/state.rb
@@ -0,0 +1,5 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/state'

File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions spec/utility.rb
@@ -0,0 +1,22 @@
$:.unshift File.dirname(__FILE__)

require 'helper'
require 'lib/utility'

describe "utility functions" do
it "should escape paths" do
escaped_path("/test/Path Containing Spaces").should == '/test/Path\ Containing\ Spaces'
end

it "should be able to Super Chomp!" do
super_chomp(" chomp").should == "chomp"
super_chomp(" chomp ").should == "chomp"
super_chomp("chomp ").should == "chomp"
end

it "should be able to verify if a path is file'ish" do
filelike?(__FILE__).should == true
filelike?(TestDir).should == false
filelike?("./foobar").should == false
end
end
3 changes: 0 additions & 3 deletions test/test_config.rb

This file was deleted.

59 changes: 0 additions & 59 deletions test/test_engine.rb

This file was deleted.

Empty file removed test/test_main.rb
Empty file.
28 changes: 0 additions & 28 deletions test/test_platform.rb

This file was deleted.

26 changes: 0 additions & 26 deletions test/test_utility.rb

This file was deleted.

0 comments on commit 9192ed1

Please sign in to comment.