jj.github.io/curso-tdd/temas/inversión
module Named
attr_reader :name
end
class Project
include Named
attr_reader :issues, :milestones, :logger
def initialize( name, logger )
@name = name
@logger = logger
@issues = []
@milestones = []
end
# ... más
end
unit class Project::Stored does Project;
has Project::Dator $!dator;
# Código de la clase aquí abajo
my $dator = Project::Data::JSON.new($data-file);
my $stored = Project::Stored.new($dator);
equire "project"
PROJECT_NAME = 'Foo'
class NoLogger
end
describe Project do
before do
@project = Project.new(PROJECT_NAME,NoLogger.new() )
end
# continúa
end
unit class Project::Data::Fake does Project::Dator;
has $!data = { "milestones" => [
{
"2" => [
{
"4" => "Closed"
},
{
"3" => "Open"
}
]
}
],
"name" => "Foo"
};
$dator = Project::Data::Fake.new;
$stored = Project::Stored.new($dator);