Skip to content

Commit

Permalink
more tests regarding files management
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontaine committed Feb 5, 2014
1 parent ed49e36 commit 99c15fe
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/commands_tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: UTF-8 -*-

require 'tmpdir'
require 'fileutils'

class PoufCommandsTests < Test::Unit::TestCase

def setup
@prev_cmd = ENV['POUF_CMD']
ENV['POUF_CMD'] = 'echo'
@prev_dir = Pouf.sounds_dir
Pouf.sounds_dir = @sounds_dir = Dir.mktmpdir('pouf-tests')
end

def teardown
Pouf.sounds_dir = @prev_dir
FileUtils.rm_rf @sounds_dir
ENV['POUF_CMD'] = @prev_cmd
end

# == Pouf#alias2filename == #

def test_pouf_alias2filename_empty
assert_nil(Pouf.alias2filename('foo'))
end

def test_pouf_alias2filename_one_file_no_extension
f = "#{@sounds_dir}/foo"
FileUtils.touch f
assert_nil(Pouf.alias2filename('foo'))
end

def test_pouf_alias2filename_one_file_extension
f = "#{@sounds_dir}/foo.bar"
FileUtils.touch f
assert_equal(f, Pouf.alias2filename('foo'))
end

def test_pouf_alias2filename_one_file_prefix
f = "#{@sounds_dir}/foobar"
FileUtils.touch f
assert_nil(Pouf.alias2filename('foo'))
end

def test_pouf_alias2filename_two_files_same_basename
f = "#{@sounds_dir}/foo.bar"
FileUtils.touch f
FileUtils.touch "#{@sounds_dir}/foo.qux"
assert_equal(f, Pouf.alias2filename('foo'))
end

end

0 comments on commit 99c15fe

Please sign in to comment.