summary refs log tree commit diff
path: root/t/spore-request
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-15 16:14:40 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-15 16:14:40 +0200
commit606b117f2c5246eafd5b2001fd211d79aba85447 (patch)
tree1fe59eafe8690d30404437376d429e813ace8a26 /t/spore-request
parentadd a auth method (diff)
downloadnet-http-spore-606b117f2c5246eafd5b2001fd211d79aba85447.tar.gz
update tests
Diffstat (limited to 't/spore-request')
-rw-r--r--t/spore-request/exception.t9
-rw-r--r--t/spore-request/path_info.t2
-rw-r--r--t/spore-request/request_uri.t25
-rw-r--r--t/spore-request/script_name.t21
4 files changed, 56 insertions, 1 deletions
diff --git a/t/spore-request/exception.t b/t/spore-request/exception.t
index 162370a..5d5af38 100644
--- a/t/spore-request/exception.t
+++ b/t/spore-request/exception.t
@@ -4,11 +4,18 @@ use warnings;
 use Test::More;
 use Net::HTTP::Spore;
 
+my $mock_server = {
+    '/test_spore/_all_docs' => sub {
+        my $req = shift;
+        die;
+    },
+};
+
 ok my $client =
   Net::HTTP::Spore->new_from_spec( 't/specs/couchdb.json',
     api_base_url => 'http://localhost:5984' );
 
-$client->enable( 'Test::Response', callback => sub { die } );
+$client->enable( 'Mock', tests => $mock_server );
 
 my $res = $client->get_all_documents(database => 'test_spore');
 is $res->[0], 599;
diff --git a/t/spore-request/path_info.t b/t/spore-request/path_info.t
index 020a958..17645af 100644
--- a/t/spore-request/path_info.t
+++ b/t/spore-request/path_info.t
@@ -22,4 +22,6 @@ is $request->path_info, '/test_spore/foo';
 $env->{'spore.params'} = [qw/database test_spore key foo another key/];
 is $request->path_info, '/test_spore/foo';
 
+is $request->path, '/test_spore/foo';
+
 done_testing;
diff --git a/t/spore-request/request_uri.t b/t/spore-request/request_uri.t
new file mode 100644
index 0000000..84ba0ff
--- /dev/null
+++ b/t/spore-request/request_uri.t
@@ -0,0 +1,25 @@
+use strict;
+use Test::More;
+
+use Net::HTTP::Spore::Request;
+
+my $env = {
+    REQUEST_METHOD  => 'GET',
+    SERVER_NAME     => 'localhost',
+    SERVER_PORT     => '80',
+    SCRIPT_NAME     => '',
+    PATH_INFO       => '/:database/:key',
+    REQUEST_URI     => '',
+    QUERY_STRING    => '',
+    SERVER_PROTOCOL => 'HTTP/1.0',
+};
+
+ok my $request = Net::HTTP::Spore::Request->new($env);
+
+is $request->request_uri, '';
+
+$env->{REQUEST_URI} = '/';
+
+is $request->request_uri, '/';
+
+done_testing;
diff --git a/t/spore-request/script_name.t b/t/spore-request/script_name.t
new file mode 100644
index 0000000..a283c20
--- /dev/null
+++ b/t/spore-request/script_name.t
@@ -0,0 +1,21 @@
+use strict;
+use Test::More;
+
+use Net::HTTP::Spore::Request;
+
+my $env = {
+    REQUEST_METHOD  => 'GET',
+    SERVER_NAME     => 'localhost',
+    SERVER_PORT     => '80',
+    SCRIPT_NAME     => '',
+};
+
+ok my $request = Net::HTTP::Spore::Request->new($env);
+
+is $request->script_name, '';
+
+$env->{SCRIPT_NAME} = '/1/';
+
+is $request->script_name, '/1/';
+
+done_testing;