Browse files

First cut at Bailador::Test, add some very basic tests too

  • Loading branch information...
1 parent 774bd83 commit 55fe6122e4c2f762fed4e75568cf3bfee32d350a @tadzik tadzik committed Apr 7, 2012
Showing with 48 additions and 0 deletions.
  1. +4 −0 lib/Bailador/Request.pm
  2. +30 −0 lib/Bailador/Test.pm
  3. +14 −0 t/01-route-existance.t
View
4 lib/Bailador/Request.pm
@@ -10,6 +10,10 @@ class Bailador::Request {
return %ret;
}
+ method new_for_request($meth, $path) {
+ self.new: env => { REQUEST_METHOD => $meth, REQUEST_URI => $path}
+ }
+
method port { $.env<SERVER_PORT> }
method request_uri { $.env<REQUEST_URI> }
method uri { self.request_uri }
View
30 lib/Bailador/Test.pm
@@ -0,0 +1,30 @@
+module Bailador::Test;
+
+use Test;
+use Bailador::App;
+
+sub route-exists($meth, $path, $desc = '') is export {
+ my $req = Bailador::Request.new_for_request($meth, $path);
+ ok Bailador::App.current.find_route($req), $desc;
+}
+
+sub route-doesnt-exist($meth, $path, $desc = '') is export {
+ my $req = Bailador::Request.new_for_request($meth, $path);
+ ok !Bailador::App.current.find_route($req), $desc;
+}
+
+sub response-status-is($meth, $path, $status, $desc) is export { ... }
+sub response-status-isnt($meth, $path, $status, $desc) is export { ... }
+
+sub response-content-is($meth, $path, $cont, $desc) is export { ... }
+sub response-content-isnt($meth, $path, $cont, $desc) is export { ... }
+sub response-content-is-deeply($meth, $path, $cont, $desc) is export { ... }
+sub response-content-like($meth, $path, $cont, $desc) is export { ... }
+sub response-content-unlike($meth, $path, $cont, $desc) is export { ... }
+
+sub response-headers-are-deeply($meth, $path, $cont, $desc) is export { ... }
+sub response-headers-include($meth, $path, $cont, $desc) is export { ... }
+
+sub bailador-response($meth, $path, *%opts) is export { ... }
+
+sub read-logs is export { ... }
View
14 t/01-route-existance.t
@@ -0,0 +1,14 @@
+use Test;
+use Bailador;
+use Bailador::Test;
+
+plan 4;
+
+get '/foo' => sub { }
+post '/bar' => sub { }
+
+route-exists('GET', '/foo');
+route-doesnt-exist('POST', '/foo');
+
+route-exists('POST', '/bar');
+route-doesnt-exist('GET', '/bar');

0 comments on commit 55fe612

Please sign in to comment.