[libdist-zilla-role-bootstrap-perl] 04/07: Basic interface tests
Axel Beckert
abe at deuxchevaux.org
Sat Aug 8 11:58:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to annotated tag 0.1.0-source
in repository libdist-zilla-role-bootstrap-perl.
commit 0275f01f430ab4c72ad46fce9c7a1469d3af0bcd
Author: Kent Fredric <kentfredric at gmail.com>
Date: Wed Sep 4 21:54:21 2013 +1200
Basic interface tests
---
corpus/fake_dist_01/lib/E.pm | 0
corpus/fake_dist_01/t/placeholder.txt | 0
lib/Dist/Zilla/Role/Bootstrap.pm | 12 +++----
t/01-basic.t | 62 ++++++++++++++++++++++++++++++-----
4 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/corpus/fake_dist_01/lib/E.pm b/corpus/fake_dist_01/lib/E.pm
new file mode 100644
index 0000000..e69de29
diff --git a/corpus/fake_dist_01/t/placeholder.txt b/corpus/fake_dist_01/t/placeholder.txt
new file mode 100644
index 0000000..e69de29
diff --git a/lib/Dist/Zilla/Role/Bootstrap.pm b/lib/Dist/Zilla/Role/Bootstrap.pm
index 848fe0a..e1b98e0 100644
--- a/lib/Dist/Zilla/Role/Bootstrap.pm
+++ b/lib/Dist/Zilla/Role/Bootstrap.pm
@@ -102,12 +102,12 @@ has _bootstrap_root => (
);
sub _add_inc {
- my ( $self, $import ) = @_;
- if ( not ref $import ) {
- require lib;
- return lib->import($import);
- }
- die "At this time, _add_inc(arg) only supports scalar values of arg";
+ my ( $self, $import ) = @_;
+ if ( not ref $import ) {
+ require lib;
+ return lib->import($import);
+ }
+ die "At this time, _add_inc(arg) only supports scalar values of arg";
}
requires 'bootstrap';
diff --git a/t/01-basic.t b/t/01-basic.t
index 7fe05a2..4e7a8a5 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -5,19 +5,65 @@ use warnings;
use Test::More;
{
- package Example;
- use Moose;
- with 'Dist::Zilla::Role::Bootstrap';
- sub bootstrap {
- 1;
- }
+ package Example;
+ use Moose;
+ with 'Dist::Zilla::Role::Bootstrap';
- __PACKAGE__->meta->make_immutable;
+ sub bootstrap {
1;
+ }
+
+ __PACKAGE__->meta->make_immutable;
+ 1;
}
pass("Role Composition Check Ok");
-ok( Example->bootstrap , 'invoke basic method on composed class');
+ok( Example->bootstrap, 'invoke basic method on composed class' );
+
+require Dist::Zilla::Chrome::Test;
+require Dist::Zilla::MVP::Section;
+require Dist::Zilla::Dist::Builder;
+require Dist::Zilla::MVP::Assembler::Zilla;
+
+my $chrome = Dist::Zilla::Chrome::Test->new();
+my $section = Dist::Zilla::MVP::Assembler::Zilla->new(
+ chrome => $chrome,
+ zilla_class => 'Dist::Zilla::Dist::Builder',
+ section_class => 'Dist::Zilla::MVP::Section',
+);
+use Path::FindDev qw( find_dev );
+use Path::Tiny qw( path );
+
+my $cwd = path('./')->absolute;
+my $scratch = find_dev('./')->child('corpus')->child('fake_dist_01');
+
+chdir $scratch->stringify;
+
+$section->current_section->payload->{chrome} = $chrome;
+$section->current_section->payload->{root} = $scratch->stringify;
+$section->current_section->payload->{name} = 'Example';
+$section->finalize;
+
+my $instance = Example->plugin_from_config( 'testing', {}, $section );
+
+is_deeply(
+ $instance->dump_config,
+ {
+ 'Dist::Zilla::Role::Bootstrap' => {
+ distname => 'Example',
+ fallback => 1,
+ try_built => undef,
+ }
+ },
+ 'dump_config is expected'
+);
+
+is( $instance->distname, 'Example', 'distname is Example' );
+is( $instance->_cwd, $scratch, 'cwd is project root/' );
+is( $instance->try_built, undef, 'try_built is off' );
+is( $instance->fallback, 1, 'fallback is on' );
+is( $instance->_bootstrap_root, $scratch, '_bootstrap_root == _cwd' );
+ok( $instance->can('_add_inc'), '_add_inc method exists' );
done_testing;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-role-bootstrap-perl.git
More information about the Pkg-perl-cvs-commits
mailing list