03-spec-coverage.t 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!perl
  2. use strict;
  3. use warnings;
  4. use Test::More;
  5. unless($ENV{RELEASE_TESTING}) {
  6. plan(skip_all=>"Author tests not required for installation.");
  7. }
  8. eval {use LWP::Simple;};
  9. skip_all("need LWP::Simple") if $@;
  10. use Selenium::Remote::Commands;
  11. my $uri = "http://selenium.googlecode.com/svn/wiki/JsonWireProtocol.wiki";
  12. my $data = get($uri);
  13. my $todo_list = {
  14. 'GET session/:sessionId/orientation' => 1,
  15. 'POST session/:sessionId/orientation' => 1,
  16. 'POST session/:sessionId/ime/deactivate' => 1,
  17. 'GET session/:sessionId/ime/activated' => 1,
  18. 'POST session/:sessionId/ime/activate' => 1,
  19. 'GET session/:sessionId/ime/active_engine' => 1,
  20. 'GET session/:sessionId/ime/available_engines' => 1,
  21. };
  22. my @lines = split(/\n/, $data);
  23. my @methods;
  24. for my $line (@lines) {
  25. if ($line =~
  26. /\|\|\s*(GET|POST|DELETE)\s*\|\|\s*\[\S*\s+\/([^\]]*)\]\s*\|\|\s*([^\|]*?)\s*\|\|/
  27. ) {
  28. my $method = {method => $1, path => $2, desc => $3};
  29. push @methods, $method;
  30. }
  31. }
  32. my $commands = Selenium::Remote::Commands->new;
  33. SOURCE_COMMAND: for my $method_source (@methods) {
  34. my $command = "$method_source->{method} $method_source->{path}";
  35. my $msg = "find $command";
  36. for my $method_local (values %{$commands}) {
  37. if ( $method_local->{url} eq $method_source->{path}
  38. and $method_local->{method} eq $method_source->{method}) {
  39. pass($msg);
  40. next SOURCE_COMMAND;
  41. }
  42. }
  43. TODO: {
  44. local $TODO = "need to create command" if $todo_list->{$command};
  45. fail($msg);
  46. }
  47. }
  48. LOCAL_COMMAND: for my $method_local (values %{$commands}) {
  49. my $msg = "extra command $method_local->{method} $method_local->{url}";
  50. for my $method_source (@methods) {
  51. if ( $method_local->{url} eq $method_source->{path}
  52. and $method_local->{method} eq $method_source->{method}) {
  53. next LOCAL_COMMAND;
  54. }
  55. }
  56. TODO: {
  57. local $TODO = "Investigate extra methods";
  58. fail($msg);
  59. }
  60. }
  61. done_testing;