{"action":"created","issue":{"url":"https://api.github.com/repos/kraih/mojo/issues/827","labels_url":"https://api.github.com/repos/kraih/mojo/issues/827/labels{/name}","comments_url":"https://api.github.com/repos/kraih/mojo/issues/827/comments","events_url":"https://api.github.com/repos/kraih/mojo/issues/827/events","html_url":"https://github.com/kraih/mojo/pull/827","id":100325521,"number":827,"title":"add swat command","user":{"login":"melezhik","id":988105,"avatar_url":"https://avatars.githubusercontent.com/u/988105?v=3","gravatar_id":"","url":"https://api.github.com/users/melezhik","html_url":"https://github.com/melezhik","followers_url":"https://api.github.com/users/melezhik/followers","following_url":"https://api.github.com/users/melezhik/following{/other_user}","gists_url":"https://api.github.com/users/melezhik/gists{/gist_id}","starred_url":"https://api.github.com/users/melezhik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melezhik/subscriptions","organizations_url":"https://api.github.com/users/melezhik/orgs","repos_url":"https://api.github.com/users/melezhik/repos","events_url":"https://api.github.com/users/melezhik/events{/privacy}","received_events_url":"https://api.github.com/users/melezhik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-11T14:29:24Z","updated_at":"2015-08-11T14:37:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/kraih/mojo/pulls/827","html_url":"https://github.com/kraih/mojo/pull/827","diff_url":"https://github.com/kraih/mojo/pull/827.diff","patch_url":"https://github.com/kraih/mojo/pull/827.patch"},"body":"HI @kraih !  [Swat](https://github.com/melezhik/swat) is a Simple Web Application Tests (API).\r\nI found this interesting to generate swat tests for a existed mojo application using routes introspection embedded into mojo core. \r\n\r\nThis is very first draft as swat could be integrated with, and could refined latter. \r\n\r\nNow swat command does this:\r\n\r\n- walk through all available GET|POST mojo routes   and creates a swat test for every one\r\n- when it is done one may run swat tests kept under ./swat directory \r\n\r\n---\r\n\r\nFull documentation for SWAT is available here - https://github.com/melezhik/swat\r\n\r\nHere is the example of swat command usage:\r\n\r\n```\r\n\r\n$ cat myapp.pl\r\n\r\n#!/usr/bin/env perl\r\nuse Mojolicious::Lite;\r\n\r\n# Documentation browser under \"/perldoc\"\r\nplugin 'PODRenderer';\r\n\r\nget '/' => sub {\r\n  my $c = shift;\r\n  $c->render(template => 'index');\r\n};\r\n\r\nget '/foo' => sub {\r\n    my $c = shift;\r\n    $c->render(text => 'Hello World!');\r\n  };\r\n\r\n\r\npost '/foo/bar' => sub {\r\n \"OK\"\r\n};\r\n\r\n\r\napp->start;\r\n__DATA__\r\n\r\n@@ index.html.ep\r\n% layout 'default';\r\n% title 'Welcome';\r\n<h1>Welcome to the Mojolicious real-time web framework!</h1>\r\nTo learn more, you can browse through the documentation\r\n<%= link_to 'here' => '/perldoc' %>.\r\n\r\n@@ foobar.html.ep\r\n% layout 'default';\r\n% title 'Foo Bar';\r\nFoo Bar\r\n\r\n@@ layouts/default.html.ep\r\n<!DOCTYPE html>\r\n<html>\r\n  <head><title><%= title %></title></head>\r\n  <body>\r\n\r\n$ PERL5LIB=~/perl5/lib/perl5/ ./myapp.pl  swat\r\nsorry, swat does not support * methods yet ... at Mojolicious/Command/swat.pm line 26, <DATA> line 43.\r\ngenerate swat route for / ...\r\ngenerate swat data for GET / ...\r\ngenerate swat route for /foo ...\r\ngenerate swat data for GET /foo ...\r\ngenerate swat route for /foo/bar ...\r\ngenerate swat data for POST /foo/bar ...\r\n\r\n---\r\nswat is ready to run: swat ./swat http://127.0.0.1:3000\r\n\r\n$ PERL5LIB=~/perl5/lib/perl5/ ~/perl5/bin/morbo ./myapp.pl\r\nServer available at http://127.0.0.1:3000\r\n\r\n$ swat ./swat http://127.0.0.1:3000\r\n/home/vagrant/.swat/reports/http://127.0.0.1:3000/00.t ...............\r\n# start swat for http://127.0.0.1:3000// | is swat package 0\r\n# swat version v0.1.19 | debug 0 | try num 2 | ignore http errors 0\r\nok 1 - successfull response from GET http://127.0.0.1:3000/\r\n# data file: /home/vagrant/.swat/reports/http://127.0.0.1:3000///content.GET.txt\r\nok 2 - GET / returns 200 OK\r\n1..2\r\nok\r\n/home/vagrant/.swat/reports/http://127.0.0.1:3000/foo/00.t ...........\r\n# start swat for http://127.0.0.1:3000//foo | is swat package 0\r\n# swat version v0.1.19 | debug 0 | try num 2 | ignore http errors 0\r\nok 1 - successfull response from GET http://127.0.0.1:3000/foo\r\n# data file: /home/vagrant/.swat/reports/http://127.0.0.1:3000//foo/content.GET.txt\r\nok 2 - GET /foo returns 200 OK\r\n1..2\r\nok\r\n/home/vagrant/.swat/reports/http://127.0.0.1:3000/foo/bar/00.post.t ..\r\n# start swat for http://127.0.0.1:3000//foo/bar | is swat package 0\r\n# swat version v0.1.19 | debug 0 | try num 2 | ignore http errors 0\r\nok 1 - successfull response from POST http://127.0.0.1:3000/foo/bar\r\n# data file: /home/vagrant/.swat/reports/http://127.0.0.1:3000//foo/bar/content.POST.txt\r\nok 2 - POST /foo/bar returns 200 OK\r\n1..2\r\nok\r\nAll tests successful.\r\nFiles=3, Tests=6,  0 wallclock secs ( 0.00 usr  0.01 sys +  0.04 cusr  0.01 csys =  0.06 CPU)\r\nResult: PASS\r\n\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/kraih/mojo/issues/comments/129909712","html_url":"https://github.com/kraih/mojo/pull/827#issuecomment-129909712","issue_url":"https://api.github.com/repos/kraih/mojo/issues/827","id":129909712,"user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T14:37:57Z","updated_at":"2015-08-11T14:37:57Z","body":"This looks interesting, but....\r\n\r\n1. There's no tests\r\n2. There's almost no documentation\r\n3. I don't consider this to be a core Mojo feature\r\n\r\nA :-1: from me"}}