summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-06 10:09:34 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-06 10:09:34 +0200
commit20907d84f16d74874a61c61cb8698c79e96f04ff (patch)
tree6963ecdcaa6d9cd239a97a408e340712ea225305
parent2d2355dfd840a100a50b3d349be5d9c88d6de2f8 (diff)
Raps2.pm: new: Add no_cli option, removes Test::MockObject build dependency
-rw-r--r--Build.PL1
-rw-r--r--Changelog3
-rw-r--r--lib/App/Raps2.pm10
-rw-r--r--t/25-app-raps2-basic.t17
-rw-r--r--t/29-app-raps2-store.t13
5 files changed, 16 insertions, 28 deletions
diff --git a/Build.PL b/Build.PL
index 2d9c370..ebec2f1 100644
--- a/Build.PL
+++ b/Build.PL
@@ -8,7 +8,6 @@ my $build = Module::Build->new(
build_requires => {
'Test::Command' => 0,
'Test::Compile' => 0,
- 'Test::MockObject' => 0,
'Test::More' => 0,
'Test::Pod' => 0,
},
diff --git a/Changelog b/Changelog
index c70d749..f49054b 100644
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,7 @@
git HEAD
+ * Remove Test::MockObject dependency
+
[App::Raps2]
* Move cmd_* functions into raps2
* Rename pw_add t pw_save
@@ -10,6 +12,7 @@ git HEAD
* Add pw_load_info method
* The 'salt' argument to pw_add is now optional
* Add the 'master_password' option to the 'new' method
+ * Add the no_cli option to App::Raps2->new()
App::Raps2 0.4 - Sun Jul 03 2011
diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm
index d515548..891dc9c 100644
--- a/lib/App/Raps2.pm
+++ b/lib/App/Raps2.pm
@@ -20,7 +20,9 @@ sub new {
$self->{xdg_conf} = config_home('raps2');
$self->{xdg_data} = data_home('raps2');
- $self->{ui} = App::Raps2::UI->new();
+ if ( not $opt{no_cli} ) {
+ $self->{ui} = App::Raps2::UI->new();
+ }
$self->{default} = \%opt;
@@ -237,6 +239,12 @@ Accepted configuration parameters are:
B<cost> of key setup, passed on to App::Raps2::Password(3pm).
+=item B<no_cli> => I<bool>
+
+If set to true, App::Raps2 assumes it will not be used as a CLI. It won't
+initialize its Term::ReadLine object and won't try to read anything from the
+terminal.
+
=back
=item $raps2->get_master_password( [I<$password>] )
diff --git a/t/25-app-raps2-basic.t b/t/25-app-raps2-basic.t
index 53aa51d..127f904 100644
--- a/t/25-app-raps2-basic.t
+++ b/t/25-app-raps2-basic.t
@@ -3,26 +3,13 @@ use strict;
use warnings;
use 5.010;
-use Test::More;
-
-eval "use Test::MockObject";
-plan skip_all => 'Test::MockObject required' if $@;
-
-plan tests => 4;
-
-my $mock = Test::MockObject->new();
-$mock->fake_module(
- 'Term::ReadLine',
- new => sub { return bless({}, $_[0]) },
-);
+use Test::More tests => 3;
use_ok('App::Raps2');
-my $r2 = App::Raps2->new( dont_touch_fs => 1 );
+my $r2 = App::Raps2->new( dont_touch_fs => 1, no_cli => 1 );
isa_ok($r2, 'App::Raps2');
-isa_ok($r2->ui(), 'App::Raps2::UI');
-
is_deeply(
$r2->file_to_hash('t/in/hash'),
{ key => 'value', otherkey => 'othervalue' },
diff --git a/t/29-app-raps2-store.t b/t/29-app-raps2-store.t
index 759030d..026a529 100644
--- a/t/29-app-raps2-store.t
+++ b/t/29-app-raps2-store.t
@@ -3,23 +3,14 @@ use strict;
use warnings;
use 5.010;
-use Test::More;
-
-eval "use Test::MockObject";
-plan skip_all => 'Test::MockObject required' if $@;
+use Test::More tests => 9;
$ENV{XDG_CONFIG_HOME} = 't/config';
$ENV{XDG_DATA_HOME} = 't/data';
-plan tests => 9;
-
-my $mock = Test::MockObject->new();
-$mock->fake_module( 'Term::ReadLine', new => sub { return bless( {}, $_[0] ) },
-);
-
use_ok('App::Raps2');
-my $r2 = App::Raps2->new( master_password => 'sekrit' );
+my $r2 = App::Raps2->new( master_password => 'sekrit', no_cli => 1 );
isa_ok( $r2, 'App::Raps2' );
ok( -e 't/config/raps2/password', 'config file created' );