Expand tests, showing regex finder is broken
Tomas Doran [Tue, 11 Oct 2011 11:57:32 +0000 (12:57 +0100)]
lib/CatalystX/HelpText/Finder/TemplateToolkit/Regexp.pm
t/script.t

index 566fb9f..553a7b1 100644 (file)
@@ -7,8 +7,8 @@ sub find_helptext_keys_in_fn {
     my ($self, $fn) = @_;
     open(my $FILE, '<', $fn) or warn "Can't open $fn\n" && return;
     my @keys = ();
-    while (<$FILE>) {
-        if (my ($key) = m/help_text\(\s*['"](.*)['"]\s*\)/o) {
+    while (my $line = <$FILE>) {
+        if (my ($key) = $line =~ m/help_text\(\s*['"](.*)['"]\s*\)/) {
             push @keys, $key;
         }
     }
index 49390bf..3954eeb 100644 (file)
@@ -8,28 +8,35 @@ use Test::Exception;
 use FindBin qw($Bin);
 use lib "$Bin/lib";
 use Data::Dumper;
+use Moose::Autobox;
 my $path = "$Bin/lib/TestApp/root/";
 
 use_ok 'CatalystX::HelpText::Script::SearchUndocumentedHelpText';
-my $script;
-lives_ok {
-    $script = CatalystX::HelpText::Script::SearchUndocumentedHelpText
-        ->new_with_options(
+
+foreach my $suffix ('', '::Regexp') {
+
+    my $class = "CatalystX::HelpText::Finder::TemplateToolkit" . $suffix;
+    my $script;
+    lives_ok {
+        $script = CatalystX::HelpText::Script::SearchUndocumentedHelpText->new(
             help_files_path => "$path/helptext",
             template_search_dir => "$path",
-            finder_class => "CatalystX::HelpText::Finder::TemplateToolkit",
+            finder_class => $class,
             filename_pattern => '\W',
         );
-} "don't break";
+    } "don't break";
+
+    my @files = (
+        $path.'difficult',
+        $path.'undocumented',
+        $path.'main',
+        $path.'helptext/fnoo.html',
+    );
+    is_deeply [ sort $script->all_files->flatten ], [ sort @files ], "Files found";
+    is_deeply [ sort $script->all_keys->flatten ], [ sort 'undocumented', 'fnoo', 'fnar' ], "All keys found";
+    is_deeply [ sort $script->undocumented_keys->flatten ], [ sort 'undocumented', 'fnar' ], "undocumented keys found";
+    is_deeply [ sort $script->documented_keys->flatten ], [ sort 'fnoo' ], "documented keys found";
 
-my $files = [
-          $path.'undocumented',
-          $path.'main',
-          $path.'helptext/fnoo.html',
-        ];
-is_deeply $script->all_files, $files, "Files found";
-is_deeply $script->all_keys, [ 'undocumented', 'fnoo' ], "All keys found";
-is_deeply $script->undocumented_keys, [ 'undocumented' ], "undocumented keys found";
-is_deeply $script->documented_keys, [ 'fnoo' ], "documented keys found";
+}
 
 done_testing;