3 use lib 'ex'; # Where BeerDB should live
4 BEGIN { if (eval { require BeerDB }) {
6 } else { Test::More->import(skip_all =>"SQLite not working or BeerDB module could not be loaded: $@") }
8 use Maypole::CLI qw(BeerDB);
9 use Maypole::Constants;
10 $ENV{MAYPOLE_TEMPLATES} = "t/templates";
12 isa_ok( (bless {},"BeerDB") , "Maypole");
14 like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, "Got the front page");
15 like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list");
16 my (%classdata)=split /\n/, BeerDB->call_url("http://localhost/beerdb/beer/classdata");
17 is ($classdata{plural},'beers','classdata.plural');
18 is ($classdata{moniker},'beer','classdata.moniker');
19 like ($classdata{cgi},qr/^HTML::Element/,'classdata.cgi');
20 is ($classdata{table},'beer','classdata.table');
21 is ($classdata{name},'BeerDB::Beer','classdata.name');
22 is ($classdata{colnames},'Abv','classdata.colnames');
23 is($classdata{columns}, 'abv brewery id name notes price score style url',
25 is($classdata{list_columns}, 'score name price style brewery url',
26 'classdata.list_columns');
27 is ($classdata{related_accessors},'pubs','classdata.related_accessors');