Fix lib path
[catagits/Catalyst-Runtime.git] / t / unit_load_catalyst_test.t
index 08b7e7c..9c9c61c 100644 (file)
@@ -1,16 +1,52 @@
-#!perl\r
-\r
-use strict;\r
-use warnings;\r
-\r
-use Test::More;\r
-\r
-plan tests => 3;\r
-\r
-use_ok('Catalyst::Test');\r
-\r
-eval "get('http://localhost')";\r
-isnt( $@, "", "get returns an error message with no app specified");\r
-\r
-eval "request('http://localhost')";\r
-isnt( $@, "", "request returns an error message with no app specified");\r
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Catalyst::Utils;
+
+plan tests => 8;
+
+use_ok('Catalyst::Test');
+
+eval "get('http://localhost')";
+isnt( $@, "", "get returns an error message with no app specified");
+
+eval "request('http://localhost')";
+isnt( $@, "", "request returns an error message with no app specified");
+
+sub customize { Catalyst::Test::_customize_request(@_) }
+
+{
+    my $req = Catalyst::Utils::request('/dummy');
+    customize( $req );
+    is( $req->header('Host'), undef, 'normal request is unmodified' );
+}
+
+{
+    my $req = Catalyst::Utils::request('/dummy');
+    customize( $req, { host => 'customized.com' } );
+    like( $req->header('Host'), qr/customized.com/, 'request is customizable via opts hash' );
+}
+
+{
+    my $req = Catalyst::Utils::request('/dummy');
+    local $Catalyst::Test::default_host = 'localized.com';
+    customize( $req );
+    like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' );
+}
+
+{
+    my $req = Catalyst::Utils::request('/dummy');
+    local $Catalyst::Test::default_host = 'localized.com';
+    customize( $req, { host => 'customized.com' } );
+    like( $req->header('Host'), qr/customized.com/, 'opts hash takes precedence over package var' );
+}
+
+{
+    my $req = Catalyst::Utils::request('/dummy');
+    local $Catalyst::Test::default_host = 'localized.com';
+    customize( $req, { host => '' } );
+    is( $req->header('Host'), undef, 'default value can be temporarily cleared via opts hash' );
+}