test/test_wand.rb in wand-0.2.1 vs test/test_wand.rb in wand-0.3

- old
+ new

@@ -13,10 +13,11 @@ 'index.html' => 'text/html', 'jquery.js' => 'application/javascript', 'ol_tiny.jpg' => 'image/jpeg', 'ol_tiny.png' => 'image/png', 'styles.css' => 'text/css', + 'LICENSE' => 'text/plain', }.each_pair do |name, type| should "use mime type gem if it returns type #{name}" do assert_equal type, Wand.wave(FilePath.join(name).expand_path.to_s) end end @@ -30,10 +31,14 @@ should "fall back to unix file command when mime type returns nothing for #{name}" do assert_equal type, Wand.wave(FilePath.join(name).expand_path.to_s) end end + should "return value from mime type when original_filename provided" do + assert_equal 'audio/mpeg', Wand.wave('some_temp_file', :original_filename => 'test.mp3') + end + should "return nil when mime type and file fail" do assert_nil Wand.wave('AVGARDD.eot') end should "detect executable" do @@ -46,8 +51,18 @@ end should "strip newlines and such" do Wand.expects(:execute_file_cmd).returns("image/jpeg\n") assert_equal "image/jpeg", Wand.wave(FilePath.join(name).expand_path.to_s) + end + + should "support old file output format" do + Wand.expects(:execute_file_cmd).returns("text/plain; charset=us-ascii\n") + assert_equal "text/plain", Wand.wave('') + end + + should "return nil if file output matches cannot" do + Wand.expects(:execute_file_cmd).returns("cannot open file") + assert_equal nil, Wand.wave('') end end end