t/unit/MGH_Biostat/TravEpi/SimpleRulesBase/Rules/new.t


#!/usr/bin/env perl
use Modern::Perl '2013';
use Test2::V0;
use Test2::Tools::Spec;

package t::unit::MGH_Biostat::TravEpi::SimpleRulesBase::Rules::new::rules {
    $INC{'t/unit/MGH_Biostat/TravEpi/SimpleRulesBase/Rules/new/rules.pm'} = 't/unit/MGH_Biostat/TravEpi/SimpleRulesBase/Rules/new.t';

    our $rule = { 'rule' => { 'tests' => [ { 'test' => 'true' } ] } };

    sub get_rules {
        return $rule;
    }
}

use MGH_Biostat::TravEpi::SimpleRulesBase::Rules;

describe 'new' => sub {
    tests 'object creation' => sub {
        my $r = MGH_Biostat::TravEpi::SimpleRulesBase::Rules->new('t::unit::MGH_Biostat::TravEpi::SimpleRulesBase::Rules::new::rules');
        is(
            $r,
            object {
                prop blessed => 'MGH_Biostat::TravEpi::SimpleRulesBase::Rules';
                field 'rule' => hash {
                    field 'key'           => 'rule';
                    field 'test-combiner' => 'any';
                    field 'tests'         => array {
                        item 0 => hash {
                            field 'test' => 'true';
                            end();
                        };
                        end();
                    };
                    end();
                };
                end();
            },
            'object correctly created'
        );
    };
};

done_testing();