Hello! Ise use Dancer 1.3132 with perl 5.14.2. $ cat bin/app.pl #!/usr/bin/env perl use Dancer; use Trassa_REST; use Trassa_web; dance; $ cat lib/Trassa_REST.pm package Trassa_REST; use strict; use warnings; use 5.010001; use Dancer q/:syntax/; ........ get qr{/rest (/[\w.]+)? # resource, e.g. node (/[\w.]+)? # command, e.g. stat, or resource id, e.g. 1 (/[\w.]+)? # command for resource id, e.g. page (/[\w.]+)? # page with data, e.g. 1 /? }sx => sub { ......... } 1; $ cat t/002_rest_node_route.t use strict; use warnings; use Test::More q/no_plan/; use Trassa_REST; use Dancer::Test; my @url = ('/rest/node', '/rest/node/help', '/rest/node/status', '/rest/node/page', '/rest/node/page/5', '/rest/node/1/status', '/rest/node/1/page', '/rest/node/1/page/5'); foreach my $i (@url) { route_exists [GET => $i], "a route handler defined for $i"; response_status_is [GET => $i], 200, "response status is 200 for $i"; response_headers_are_deeply [GET => $i], ['Content-Type' => 'text/xml']; } After starting application I try test it: $ bin/app.pl [4366] core @0.000022> loading Dancer::Handler::Standalone handler in /usr/share/perl5/Dancer/Handler.pm l. 48 [4366] core @0.000608> loading handler 'Dancer::Handler::Standalone' in /usr/share/perl5/Dancer.pm l. 493
Dancer 1.3132 server 4366 listening on http://0.0.0.0:3000 Dancer::Plugin::Database::Core (0.08) Dancer::Plugin::Database::Core::Handle (0.02) Dancer::Plugin::Database (2.10) == Entering the development dance floor ...
$ prove t/ t/001_base.t ............. 1/1 # Failed test 'use Trassa_REST;' # at t/001_base.t line 5. # Tried to use 'Trassa_REST'. # Error: Can't locate Trassa_REST.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at (eval 4) line 2. # BEGIN failed--compilation aborted at (eval 4) line 2. # Looks like you failed 1 test of 1. t/001_base.t ............. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests t/002_rest_node_route.t .. Can't locate Trassa_REST.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at t/002_rest_node_route.t line 5. BEGIN failed--compilation aborted at t/002_rest_node_route.t line 5. t/002_rest_node_route.t .. Dubious, test returned 2 (wstat 512, 0x200) No subtests run Test Summary Report ------------------- t/001_base.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 t/002_rest_node_route.t (Wstat: 512 Tests: 0 Failed: 0) Non-zero exit status: 2 Parse errors: No plan found in TAP output Files=2, Tests=1, 0 wallclock secs ( 0.02 usr 0.02 sys + 0.03 cusr 0.01 csys = 0.08 CPU) Result: FAIL $ prove -I lib/ t/ t/001_base.t ............. ok t/002_rest_node_route.t .. 2/? # Failed test 'headers are as expected for GET /rest/node' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/help' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/status' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/page' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/page/5' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/1/status' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/1/page' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Failed test 'headers are as expected for GET /rest/node/1/page/5' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist # Tests were run but no plan was declared and done_testing() was not seen. t/002_rest_node_route.t .. Failed 8/24 subtests Test Summary Report ------------------- t/002_rest_node_route.t (Wstat: 0 Tests: 24 Failed: 8) Failed tests: 3, 6, 9, 12, 15, 18, 21, 24 Parse errors: No plan found in TAP output Files=2, Tests=25, 1 wallclock secs ( 0.04 usr 0.01 sys + 0.46 cusr 0.02 csys = 0.53 CPU) Result: FAIL Why test not found server? Thank you and excuse me for my bad english. -- Best regards, Brilliantov Kirill Vladimirovich
On 14-12-08 04:12 AM, Brilliantov Kirill Vladimirovich wrote:
$ prove t/ t/001_base.t ............. 1/1 # Failed test 'use Trassa_REST;' # at t/001_base.t line 5. # Tried to use 'Trassa_REST'. # Error: Can't locate Trassa_REST.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at (eval 4) line 2.
I think $ prove -l t will solve your problem... Joy, `/anick
Tere! 2014-12-08 11:12 GMT+02:00 Brilliantov Kirill Vladimirovich <brilliantov@byterg.ru>:
response_headers_are_deeply [GET => $i], ['Content-Type' => 'text/xml'];
...
# Failed test 'headers are as expected for GET /rest/node' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist
I never used *_deeply tests neither in Test::More or Dancer::Test, but I see contradiction in docs. Test::More says about is_deeply: "it does a deep comparison walking each data structure to see if they are equivalent. If the two structures are different, it will display the place where they start differing." Dancer::Test says about response_headers_are_deeply (uses is_deeply internally): "Asserts that the response headers data structure equals the one given" According to Test::More, your test should fail, because your expected data differs from what you got as response. -- Wbr, Kõike hääd, Gunnar
WK wrote on 12/09/2014 10:47 AM:
Tere!
2014-12-08 11:12 GMT+02:00 Brilliantov Kirill Vladimirovich <brilliantov@byterg.ru>:
response_headers_are_deeply [GET => $i], ['Content-Type' => 'text/xml'];
...
# Failed test 'headers are as expected for GET /rest/node' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist
I never used *_deeply tests neither in Test::More or Dancer::Test, but I see contradiction in docs. Test::More says about is_deeply:
"it does a deep comparison walking each data structure to see if they are equivalent. If the two structures are different, it will display the place where they start differing."
Dancer::Test says about response_headers_are_deeply (uses is_deeply internally):
"Asserts that the response headers data structure equals the one given"
According to Test::More, your test should fail, because your expected data differs from what you got as response.
Ok, this is correct for header test. But why I get error for roure test route_exists? -- Best regards, Brilliantov Kirill Vladimirovich
WK wrote on 12/09/2014 10:47 AM:
Tere!
2014-12-08 11:12 GMT+02:00 Brilliantov Kirill Vladimirovich <brilliantov@byterg.ru>:
response_headers_are_deeply [GET => $i], ['Content-Type' => 'text/xml'];
...
# Failed test 'headers are as expected for GET /rest/node' # at t/002_rest_node_route.t line 20. # Structures begin differing at: # $got->[2] = 'Server' # $expected->[2] = Does not exist
I never used *_deeply tests neither in Test::More or Dancer::Test, but I see contradiction in docs. Test::More says about is_deeply:
"it does a deep comparison walking each data structure to see if they are equivalent. If the two structures are different, it will display the place where they start differing."
Dancer::Test says about response_headers_are_deeply (uses is_deeply internally):
"Asserts that the response headers data structure equals the one given"
According to Test::More, your test should fail, because your expected data differs from what you got as response.
Ok, test success after change on response_headers_include -- Best regards, Brilliantov Kirill Vladimirovich
participants (3)
-
Brilliantov Kirill Vladimirovich -
WK -
Yanick Champoux