Permalink
Browse files

Handling unexpected or incorrect output from file command.

  • Loading branch information...
jnunemaker committed Jan 22, 2011
1 parent 3d11f8b commit 45e02342d2c550a06465ae74c7c15854e5f8f357
Showing with 8 additions and 1 deletion.
  1. +3 −1 lib/wand.rb
  2. +5 −0 test/test_wand.rb
View
@@ -19,7 +19,9 @@ def self.executable=(path)
private
def self.parse_type(output)
- output.split(';')[0].strip
+ type = output.split(';')[0]
+ type = type.strip unless type.nil?
+ type
end
def self.execute_file_cmd(path)
View
@@ -68,5 +68,10 @@ class TestWand < Test::Unit::TestCase
should "properly handle bad stuff" do
assert_nothing_raised { Wand.wave(';blah') }
end
+
+ should "handle unexpected results frome execute file command" do
+ Wand.expects(:execute_file_cmd).returns('')
+ assert_equal nil, Wand.wave('')
+ end
end
end

0 comments on commit 45e0234

Please sign in to comment.