Permalink
Browse files

fix testsuite, the last commit broke it

t/01_config/02_mime_type.t
  * Dancer::FileUtils is not needed anymore to determine
    the mime type
  * Dancer::Config::mime_type is empty by default, it
    contains only user defined mime types from now on.

t/04_static_file/002_mime_types.t
  * File::MimeInfo::Simple is not needed for this test

t/04_static_file/03_get_mime_type.t
  * the mime magic is gone
  * replace foo.arj with foo.zip, arj doesn't have an IANA
    registered mime type

t/04_static_file/04_file_mimeinfo_simple.t
  * deleted, mime magic is gone
  • Loading branch information...
1 parent 9a3ff51 commit 8e4157886f979a9e364e4bade75f919e85f8ba04 Danijel Tasov committed Feb 12, 2010
@@ -1,18 +1,16 @@
use strict;
use warnings;
-use Test::More tests => 7, import => ['!pass'];
+use Test::More tests => 6, import => ['!pass'];
BEGIN {
use_ok 'Dancer';
- use_ok 'Dancer::FileUtils';
use_ok 'Dancer::Config', 'setting', 'mime_types';
}
-is_deeply(mime_types, Dancer::FileUtils->mime_types,
- 'mime_types are initialized');
+is_deeply(mime_types, {}, 'user defined mime_types are empty');
ok(mime_types(foo => 'text/foo'), 'define text/foo');
-is_deeply(mime_types, {%{Dancer::FileUtils->mime_types}, foo => 'text/foo'}, 'text/foo is saved');
+is_deeply(mime_types, {foo => 'text/foo'}, 'text/foo is saved');
is(mime_types('foo'), 'text/foo', 'mime type foo is found');
@@ -9,8 +9,6 @@ use lib 't';
use TestUtils;
use Test::More import => ['!pass'];
-plan skip_all => "File::MimeInfo::Simple needed"
- unless Dancer::ModuleLoader->load('File::MimeInfo::Simple');
plan tests => 7;
set public => path(dirname(__FILE__), 'static');
@@ -1,25 +1,15 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 2;
use Dancer::ModuleLoader;
use Dancer::Renderer;
use lib 't/lib';
use EasyMocker;
-my $mocker = { 'File::MimeInfo::Simple' => 0 };
-mock 'Dancer::ModuleLoader'
- => method 'load'
- => should sub { $mocker->{$_[1]} };
-
-is(Dancer::ModuleLoader->load('File::MimeInfo::Simple'), 0,
- 'mocker is set');
-
-is(Dancer::Renderer::get_mime_type('foo.arj'), 'application/x-arj',
- "a mime_type is found without File::MimeInfo::Simple");
-
-eval { Dancer::Renderer::get_mime_type('foo.nonexistent') };
-like $@, qr/unknown mime_type for 'foo.nonexistent'/,
- "unknown mime_type exception caught";
+is(Dancer::Renderer::get_mime_type('foo.zip'), 'application/zip',
+ "a mime_type is found with MIME::Types");
+is(Dancer::Renderer::get_mime_type('foo.nonexistent'), 'text/plain',
+ 'mime_type defaults to text/plain' );
@@ -1,32 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use Dancer::ModuleLoader;
-use Dancer::Renderer;
-use Dancer::FileUtils 'path';
-
-plan skip_all => "File::MimeInfo::Simple needed"
- unless Dancer::ModuleLoader->load('File::MimeInfo::Simple');
-
-plan tests => 4;
-
-is(Dancer::Renderer::get_mime_type('foo.arj'), 'application/x-arj',
- "a mime_type is found without File::MimeInfo::Simple");
-
-eval { Dancer::Renderer::get_mime_type('foo.nonexistent') };
-like $@, qr/Unable to read file: foo.nonexistent/,
- "unknown mime_type exception caught, should read a file";
-
-my $test_file = path('t', '04_static_file', 'foo.nonexistent');
-open TESTFILE, '>', $test_file;
-print TESTFILE "this is plain text\n";
-close TESTFILE;
-
-my $mt;
-eval { $mt = Dancer::Renderer::get_mime_type($test_file) };
-is $@, '', "unknown mime_type is detected with File::MimeInfo::Simple";
-like $mt, qr/text\/plain/, "mime_type is text/plain";
-
-unlink $test_file;
-

0 comments on commit 8e41578

Please sign in to comment.