Sha256: 7ea4e0ef07d2dca006ff0f246c19d4c9a24f0a1a3d22c4d6e2bc22bed2108bce
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
##################################################################### # test_image.rb # # Test case for the File.image? method. You should run this test # via the 'rake test:image' task. ##################################################################### require 'test-unit' require 'ptools' class TC_Ptools_Image < Test::Unit::TestCase def self.startup Dir.chdir('test') if File.exist?('test') end def setup @txt_file = File.join(Dir.pwd, 'txt', 'english.txt') @uni_file = File.join(Dir.pwd, 'txt', 'korean.txt') @jpg_file = File.join(Dir.pwd, 'img', 'test.jpg') @png_file = File.join(Dir.pwd, 'img', 'test.png') @gif_file = File.join(Dir.pwd, 'img', 'test.gif') @ico_file = File.join(Dir.pwd, 'img', 'test.ico') end test "image? method basic functionality" do assert_respond_to(File, :image?) assert_nothing_raised{ File.image?(@txt_file) } assert_boolean(File.image?(@txt_file)) end test "image? method returns false for a text file" do assert_false(File.image?(@txt_file)) assert_false(File.image?(@uni_file)) end test "image? method returns true for a gif" do assert_true(File.image?(@gif_file)) end test "image? method returns true for a jpeg" do assert_true(File.image?(@jpg_file)) end test "image? method returns true for a png" do assert_true(File.image?(@png_file)) end test "image? method returns true for an ico" do assert_true(File.image?(@ico_file)) end test "image? method raises an error if the file does not exist" do assert_raises(Errno::ENOENT, ArgumentError){ File.image?('bogus') } end def teardown @txt_file = nil @uni_file = nil @jpg_file = nil @png_file = nil @gif_file = nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ptools-1.3.7 | test/test_image.rb |
ptools-1.3.6 | test/test_image.rb |
ptools-1.3.5 | test/test_image.rb |