4 use File::Temp qw{tempfile};
6 use Tails::Persistence::Configuration;
8 describe 'A configuration object' => sub {
9 describe 'built with no arguments' => sub {
12 $configuration = Tails::Persistence::Configuration->new();
14 it 'is defined' => sub {
15 ok(defined($configuration));
17 it 'has defined presets' => sub {
18 ok(defined($configuration->presets));
20 it 'can return all presets' => sub {
21 ok($configuration->presets->all);
23 it 'has a GnuPG preset' => sub {
24 is(scalar(grep { $_->name eq 'GnuPG' } $configuration->presets->all), 1);
27 describe 'built with no argument and an empty configuration file' => sub {
28 my ($configuration, $config_fh, $config_filename);
30 ($config_fh, $config_filename) = tempfile();
33 $configuration = Tails::Persistence::Configuration->new(
34 config_file_path => file($config_filename)
37 it 'has 12 atoms' => sub {
38 is(scalar($configuration->all_atoms), 12);
40 it 'has 1 enabled atom' => sub {
41 is(scalar($configuration->all_enabled_atoms), 1);
43 it 'has 1 enabled line' => sub {
44 is(scalar($configuration->all_enabled_lines), 1);
47 describe 'built with no argument and a non-empty configuration file' => sub {
48 my ($configuration, $config_fh, $config_filename);
50 ($config_fh, $config_filename) = tempfile();
52 /home/amnesia link,source=dotfiles
53 /home/amnesia/.myapp source=myapp
54 /home/amnesia/.gnupg source=gnupg
58 $configuration = Tails::Persistence::Configuration->new(
59 config_file_path => file($config_filename)
62 it 'has 13 atoms' => sub {
63 is(scalar($configuration->all_atoms), 13);
65 it 'has 4 enabled atoms' => sub {
66 is(scalar($configuration->all_enabled_atoms), 4);
68 it 'has 4 enabled lines' => sub {
69 is(scalar($configuration->all_enabled_lines), 4);
74 runtests unless caller;