Remove Mutant::Delegator
* And inline its semantics into the only inclusion side * Add mutation covered specs
This commit is contained in:
parent
0542728818
commit
132aa8d99c
4 changed files with 52 additions and 51 deletions
|
@ -61,7 +61,6 @@ require 'mutant/actor/sender'
|
|||
require 'mutant/actor/mailbox'
|
||||
require 'mutant/actor/env'
|
||||
require 'mutant/parser'
|
||||
require 'mutant/delegator'
|
||||
require 'mutant/isolation'
|
||||
require 'mutant/parallel'
|
||||
require 'mutant/parallel/master'
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
module Mutant
|
||||
# A simple delegator with opinions
|
||||
module Delegator
|
||||
# Class level mixins
|
||||
module ClassMethods
|
||||
|
||||
private
|
||||
|
||||
# Create delegators to object
|
||||
#
|
||||
# @return [undefined]
|
||||
def delegate(*names)
|
||||
names.each(&method(:define_delegator))
|
||||
end
|
||||
|
||||
# Create delegator to object
|
||||
#
|
||||
# @param [Symbol] name
|
||||
#
|
||||
# @return [undefined]
|
||||
def define_delegator(name)
|
||||
fail "method #{name} already defined" if instance_methods.include?(name)
|
||||
define_method(name) do
|
||||
object.public_send(name)
|
||||
end
|
||||
private name
|
||||
end
|
||||
|
||||
end # ClassMethods
|
||||
|
||||
# Hook called when module is included
|
||||
#
|
||||
# @param [Class,Module] host
|
||||
#
|
||||
# @return [undefined]
|
||||
def self.included(host)
|
||||
super
|
||||
|
||||
host.extend(ClassMethods)
|
||||
end
|
||||
|
||||
end # Delegator
|
||||
end # Mutant
|
|
@ -3,10 +3,34 @@ module Mutant
|
|||
class CLI
|
||||
# CLI runner status printer base class
|
||||
class Printer
|
||||
include AbstractType, Delegator, Adamantium::Flat, Concord.new(:output, :object), Procto.call(:run)
|
||||
include AbstractType,
|
||||
Adamantium::Flat,
|
||||
Concord.new(:output, :object),
|
||||
Procto.call(:run)
|
||||
|
||||
private_class_method :new
|
||||
|
||||
# Create delegators to object
|
||||
#
|
||||
# @return [undefined]
|
||||
def self.delegate(*names)
|
||||
names.each(&method(:define_delegator))
|
||||
end
|
||||
private_class_method :delegate
|
||||
|
||||
# Create delegator to object
|
||||
#
|
||||
# @param [Symbol] name
|
||||
#
|
||||
# @return [undefined]
|
||||
def self.define_delegator(name)
|
||||
define_method(name) do
|
||||
object.public_send(name)
|
||||
end
|
||||
private(name)
|
||||
end
|
||||
private_class_method :define_delegator
|
||||
|
||||
delegate :success?
|
||||
|
||||
NL = "\n".freeze
|
||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
let(:tty?) { true }
|
||||
let(:success?) { true }
|
||||
|
||||
context '.call' do
|
||||
describe '.call' do
|
||||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
def run
|
||||
|
@ -30,7 +30,28 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
it_reports "foo\n"
|
||||
end
|
||||
|
||||
context '#status' do
|
||||
describe '.delegate' do
|
||||
let(:reportable) { double(foo: :bar, baz: :boz) }
|
||||
|
||||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
delegate :foo, :baz
|
||||
|
||||
def run
|
||||
puts(foo)
|
||||
puts(baz)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_reports "bar\nboz\n"
|
||||
|
||||
it 'sets delegation methods to private visibility' do
|
||||
expect(class_under_test.private_instance_methods).to include(:foo, :baz)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#status' do
|
||||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
def run
|
||||
|
@ -65,7 +86,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
end
|
||||
end
|
||||
|
||||
context '#visit_collection' do
|
||||
describe '#visit_collection' do
|
||||
let(:class_under_test) do
|
||||
reporter = nested_reporter
|
||||
Class.new(described_class) do
|
||||
|
@ -86,7 +107,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
it_reports "foo\nbar\n"
|
||||
end
|
||||
|
||||
context '#visit' do
|
||||
describe '#visit' do
|
||||
let(:class_under_test) do
|
||||
reporter = nested_reporter
|
||||
Class.new(described_class) do
|
||||
|
@ -107,7 +128,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
it_reports "foo\n"
|
||||
end
|
||||
|
||||
context '#info' do
|
||||
describe '#info' do
|
||||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
def run
|
||||
|
@ -119,7 +140,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
|
|||
it_reports "foo - bar\n"
|
||||
end
|
||||
|
||||
context '#colorize' do
|
||||
describe '#colorize' do
|
||||
let(:class_under_test) do
|
||||
Class.new(described_class) do
|
||||
def run
|
||||
|
|
Loading…
Add table
Reference in a new issue