App-Rssfilter

 view release on metacpan or  search on metacpan

t/lib/App/Rssfilter/FromHash/Test/CreateGroup.pm  view on Meta::CPAN

use strict;
use warnings;

package App::Rssfilter::FromHash::Test::CreateGroup;

use Test::Routine;
use Test::Exception;
use Test::More;
use namespace::autoclean;
use Method::Signatures;

requires 'from_hash';

has mock_rule => (
    is => 'ro',
    default => method {
        $self->_make_mock( 'App::Rssfilter::Rule' );
    },
);

has mock_feed => (
    is => 'ro',
    default => method {
        $self->_make_mock( 'App::Rssfilter::Feed' );
    },
);

method _make_mock( $class ) {
    use Test::MockObject;
    my $mock = Test::MockObject->new();
    $mock->set_isa( $class );
    return $mock;
}

test create_simple_group => method {
    my $group;
    lives_ok(
        sub {
            $group = $self->from_hash(
                name  => 'coil',
                feeds => [ $self->mock_feed ],
                rules => [ $self->mock_rule ],
            );
        },
        'can call from_hash without calamity'
    );

    is(
        $group->name,
        'coil',
        'group created with name from hash'
    );

    is_deeply(
        $group->feeds,
        [ $self->mock_feed ],
        'added feeds from the hash to the created group'
    );

    is_deeply(
        $group->rules,
        [ $self->mock_rule ],
        'added rules from the hash to the created group'
    );
};

test create_nested_group => method {
    my $group = $self->from_hash(
        group => 'coil',



( run in 0.484 second using v1.01-cache-2.11-cpan-39bf76dae61 )