1
0

03-spec-coverage.t 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. plan 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. plan skip_all => "need internet connection to run spec test" if !$data;
  14. my $todo_list = {
  15. 'GET session/:sessionId/orientation' => 1,
  16. 'POST session/:sessionId/orientation' => 1,
  17. 'POST session/:sessionId/ime/deactivate' => 1,
  18. 'GET session/:sessionId/ime/activated' => 1,
  19. 'POST session/:sessionId/ime/activate' => 1,
  20. 'GET session/:sessionId/ime/active_engine' => 1,
  21. 'GET session/:sessionId/ime/available_engines' => 1,
  22. };
  23. my @lines = split(/\n/, $data);
  24. my @methods;
  25. for my $line (@lines) {
  26. if ($line =~
  27. /\|\|\s*(GET|POST|DELETE)\s*\|\|\s*\[\S*\s+\/([^\]]*)\]\s*\|\|\s*([^\|]*?)\s*\|\|/
  28. ) {
  29. my $method = {method => $1, path => $2, desc => $3};
  30. push @methods, $method;
  31. }
  32. }
  33. my $commands = Selenium::Remote::Commands->new;
  34. SOURCE_COMMAND: for my $method_source (@methods) {
  35. my $command = "$method_source->{method} $method_source->{path}";
  36. my $msg = "find $command";
  37. for my $method_local (values %{$commands}) {
  38. if ( $method_local->{url} eq $method_source->{path}
  39. and $method_local->{method} eq $method_source->{method}) {
  40. pass($msg);
  41. next SOURCE_COMMAND;
  42. }
  43. }
  44. TODO: {
  45. local $TODO = "need to create command" if $todo_list->{$command};
  46. fail($msg);
  47. }
  48. }
  49. LOCAL_COMMAND: for my $method_local (values %{$commands}) {
  50. my $msg = "extra command $method_local->{method} $method_local->{url}";
  51. for my $method_source (@methods) {
  52. if ( $method_local->{url} eq $method_source->{path}
  53. and $method_local->{method} eq $method_source->{method}) {
  54. next LOCAL_COMMAND;
  55. }
  56. }
  57. TODO: {
  58. local $TODO = "Investigate extra methods";
  59. fail($msg);
  60. }
  61. }
  62. done_testing;