George S. Baugh 2 år sedan
förälder
incheckning
7b82324588
2 ändrade filer med 7 tillägg och 4 borttagningar
  1. 4 0
      lib/Playwright/Base.pm
  2. 3 4
      t/Playwright-Base.t

+ 4 - 0
lib/Playwright/Base.pm

@@ -116,4 +116,8 @@ sub _do ( $self, %args ) {
         $self->{ua}, %args );
 }
 
+sub spec {
+    return $Playwright::spec;
+}
+
 1;

+ 3 - 4
t/Playwright-Base.t

@@ -41,13 +41,13 @@ no warnings qw{redefine once};
 local *Playwright::Fake::new = sub {
     my ($class,%options) = @_;
     return bless( {
-        spec => $Playwright::spec->{$options{type}}{members},
         type => $options{type},
         guid => $options{id},
         ua   => $options{handle}{ua},
         port => $options{handle}{port},
     }, $class);
 };
+local *Playwright::Fake::spec = sub { return $Playwright::spec->{Fake}{members} };
 use warnings;
 
 my $obj = CLASS()->new(
@@ -55,8 +55,7 @@ my $obj = CLASS()->new(
     id   => 666,
     handle => { ua => 'bogus', port => 420 },
 );
-
-is($obj->{spec}, $Playwright::spec->{Fake}{members}, "Spec correctly filed by constructor");
+is($obj->spec, $Playwright::spec, "Spec correctly filed by constructor");
 
 my %in = (
     command => 'tickle',
@@ -70,7 +69,7 @@ my %expected = (
     args    => [{ intense => JSON::true, tickler => 'bigtime' }, JSON::false, 'boom'],
 );
 
-my %out = Playwright::Base::_coerce($obj->{spec}, %in);
+my %out = Playwright::Base::_coerce($obj->spec->{Fake}{members}, %in);
 
 is(\%out, \%expected, "_coerce correctly transforms bools and leaves everything else alone");