Rewrote all the tests and now all tests pass!
[catagits/Web-Session.git] / t / 004_basic_file_w_customs.t
old mode 100644 (file)
new mode 100755 (executable)
index 90bfa0c..0c663cd
@@ -3,14 +3,10 @@
 use strict;
 use warnings;
 use File::Spec;
+use Test::Requires 'YAML';
 
 use Test::More;
 
-BEGIN {
-    eval "use YAML";
-    plan skip_all => "This test requires YAML" if $@;
-}
-
 use Plack::Request;
 use Plack::Session;
 use Plack::Session::State::Cookie;
@@ -19,15 +15,18 @@ use Plack::Session::Store::File;
 use t::lib::TestSession;
 
 my $TMP = File::Spec->catdir('t', 'tmp');
+if ( !-d $TMP ) {
+    mkdir $TMP;
+}
 
 t::lib::TestSession::run_all_tests(
-    store           => Plack::Session::Store::File->new(
+    store  => Plack::Session::Store::File->new(
         dir          => $TMP,
         serializer   => sub { YAML::DumpFile( reverse @_ ) }, # YAML takes it's args the opposite of Storable
         deserializer => sub { YAML::LoadFile( @_ ) },
     ),
-    state           => Plack::Session::State->new,
-    request_creator => sub {
+    state  => Plack::Session::State->new,
+    env_cb => sub {
         open my $in, '<', \do { my $d };
         my $env = {
             'psgi.version'    => [ 1, 0 ],
@@ -36,10 +35,8 @@ t::lib::TestSession::run_all_tests(
             'psgi.url_scheme' => 'http',
             SERVER_PORT       => 80,
             REQUEST_METHOD    => 'GET',
+            QUERY_STRING      => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
         };
-        my $r = Plack::Request->new( $env );
-        $r->parameters( @_ );
-        $r;
     },
 );