Fix integration coverage

This commit is contained in:
Markus Schirp 2016-01-10 18:44:01 +00:00
parent 0acf1ac087
commit 1714a9e92c
6 changed files with 34 additions and 34 deletions

View file

@ -1,3 +1,3 @@
---
threshold: 18
total_score: 1181
total_score: 1177

View file

@ -103,7 +103,7 @@ module Mutant
#
# @return [undefined]
def setup_integration(name)
with(integration: Integration.setup(name))
with(integration: Integration.setup(config.kernel, name))
rescue LoadError
raise Error, "Could not load integration #{name.inspect} (you may want to try installing the gem mutant-#{name})"
end

View file

@ -4,38 +4,23 @@ module Mutant
class Integration
include AbstractType, Adamantium::Flat, Concord.new(:config)
REGISTRY = {}
# Setup integration
#
# @param [String] name
# Integrations are supposed to define a constant under
# Mutant::Integration named after the capitalized +name+
# parameter.
#
# @return [Integration]
def self.setup(name)
require "mutant/integration/#{name}"
lookup(name)
# This avoids having to maintain a mutable registry.
#
# @param kernel [Kernel]
# @param name [String]
#
# @return [Class<Integration>]
def self.setup(kernel, name)
kernel.require("mutant/integration/#{name}")
const_get(name.capitalize)
end
# Lookup integration for name
#
# @param [String] name
#
# @return [Integration]
# if found
def self.lookup(name)
REGISTRY.fetch(name)
end
# Register integration
#
# @param [String] name
#
# @return [undefined]
def self.register(name)
REGISTRY[name] = self
end
private_class_method :register
# Perform integration setup
#
# @return [self]
@ -67,8 +52,6 @@ module Mutant
# Null integration that never kills a mutation
class Null < self
register('null')
# Available tests for integration
#
# @return [Enumerable<Test>]
@ -91,6 +74,5 @@ module Mutant
end
end # Null
end # Integration
end # Mutant

View file

@ -28,8 +28,6 @@ module Mutant
private_constant(*constants(false))
register 'rspec'
# Initialize rspec integration
#
# @return [undefined]

View file

@ -151,6 +151,12 @@ Options:
context 'when integration exists' do
let(:flags) { %w[--use rspec] }
before do
expect(Kernel).to receive(:require)
.with('mutant/integration/rspec')
.and_call_original
end
it_should_behave_like 'a cli parser'
let(:expected_integration) { Mutant::Integration::Rspec }

View file

@ -10,6 +10,20 @@ RSpec.describe Mutant::Integration do
subject { object.setup }
it_should_behave_like 'a command method'
end
describe '.setup' do
subject { described_class.setup(kernel, name) }
let(:name) { 'null' }
let(:kernel) { class_double(Kernel) }
before do
expect(kernel).to receive(:require)
.with('mutant/integration/null')
end
it { should be(Mutant::Integration::Null) }
end
end
RSpec.describe Mutant::Integration::Null do