-eval { App::Rgit->new(qw/foo bar baz/) };
-like($@, qr!Optional\s+arguments\s+must\s+be\s+passed\s+as\s+keys?\s*/\s*values?\s+pairs?!, 'App::Rgit->new(even): croaks');
-
-my $res = eval { App::Rgit->new() };
-is($@, '', 'App::Rgit->new(): no root: does not croak');
-is($res, undef, 'App::Rgit->new(): no root: returns undef');
-
-$res = eval { App::Rgit->new(root => $0) };
-is($@, '', 'App::Rgit->new(): wrong root: does not croak');
-is($res, undef, 'App::Rgit->new(): wrong root: returns undef');
-
-$res = eval { App::Rgit->new(root => 't') };
-is($@, '', 'App::Rgit->new(): no git: does not croak');
-is($res, undef, 'App::Rgit->new(): no git: returns undef');
-
-$res = eval { App::Rgit->new(root => 't', git => $0) };
-is($@, '', 'App::Rgit->new(): wrong git: does not croak');
-is($res, undef, 'App::Rgit->new(): wrong git: returns undef');
-
-$res = eval { App::Rgit->new(root => 't', git => 't/bin/git') };
-is($@, '', 'App::Rgit->new(): no cmd: does not croak');
-isa_ok($res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns an object');
-
-$res = eval { App::Rgit->new(root => 't', git => 't/bin/git', cmd => 'version'); };
-is($@, '', 'App::Rgit->new(): no args: does not croak');
-isa_ok($res, 'App::Rgit', 'App::Rgit->new(): no args: returns an object');
-
-$res = eval { $res->new(root => 't', git => 't/bin/git', cmd => 'version'); };
-is($@, '', '$ar->new(): no args: does not croak');
-isa_ok($res, 'App::Rgit', '$ar->new(): no args: returns an object');
-
-$res = eval { App::Rgit::new(undef, root => 't', git => 't/bin/git', cmd => 'version'); };
-is($@, '', 'undef->App::Rgit::new(): no args: does not croak');
-isa_ok($res, 'App::Rgit','undef->App::Rgit::new(): no args: returns an object');
+my $res = eval {
+ local $ENV{GIT_DIR};
+ App::Rgit->new(
+ git => 't/bin/git',
+ );
+};
+is $@, '', "App::Rgit->new(): no root, no GIT_DIR: doesn't croak";
+isa_ok $res,'App::Rgit','App::Rgit->new(): no root, no GIT_DIR: returns object';
+
+$res = eval {
+ local $ENV{GIT_DIR} = Cwd::cwd;
+ App::Rgit->new(
+ git => 't/bin/git',
+ );
+};
+is $@, '', "App::Rgit->new(): no root: doesn't croak";
+isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no root: returns object';
+
+$res = eval {
+ App::Rgit->new(
+ root => $0,
+ git => 't/bin/git',
+ );
+};
+like $@, qr/Invalid root directory/, 'App::Rgit->new(): wrong root: croaks';
+
+$res = eval {
+ local $ENV{GIT_EXEC_PATH};
+ local $ENV{PATH} = 't/bin';
+ App::Rgit->new(
+ root => 't',
+ );
+};
+is $@, '', "App::Rgit->new(): no git, no GIT_EXEC_PATH: doesn't croak";
+isa_ok $res, 'App::Rgit',
+ 'App::Rgit->new(): no git, no GIT_EXEC_PATH: returns object';
+
+$res = eval {
+ local $ENV{GIT_EXEC_PATH} = 't/bin/git';
+ App::Rgit->new(
+ root => 't',
+ );
+};
+is $@, '', "App::Rgit->new(): no git: doesn't croak";
+isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no git: returns object';
+
+$res = eval {
+ App::Rgit->new(
+ root => 't',
+ git => $0,
+ );
+};
+like $@, qr/Couldn't find a proper git executable/,
+ 'App::Rgit->new(): wrong git: croaks';
+
+$res = eval {
+ App::Rgit->new(
+ root => 't',
+ git => 't/bin/git',
+ );
+};
+is $@, '', "App::Rgit->new(): no cmd: doesn't croak";
+isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns object';
+
+$res = eval {
+ App::Rgit->new(
+ root => 't',
+ git => 't/bin/git',
+ cmd => 'version',
+ );
+};
+is $@, '', "App::Rgit->new(): no args: doesn't croak";
+isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no args: returns object';
+
+$res = eval {
+ $res->new(
+ root => 't',
+ git => 't/bin/git',
+ cmd => 'version',
+ );
+};
+is $@, '', '$ar->new(): no args: doesn\'t croak';
+isa_ok $res, 'App::Rgit', '$ar->new(): no args: returns object';