Fix integration coverage
This commit is contained in:
parent
0acf1ac087
commit
1714a9e92c
6 changed files with 34 additions and 34 deletions
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
threshold: 18
|
threshold: 18
|
||||||
total_score: 1181
|
total_score: 1177
|
||||||
|
|
|
@ -103,7 +103,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @return [undefined]
|
# @return [undefined]
|
||||||
def setup_integration(name)
|
def setup_integration(name)
|
||||||
with(integration: Integration.setup(name))
|
with(integration: Integration.setup(config.kernel, name))
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
raise Error, "Could not load integration #{name.inspect} (you may want to try installing the gem mutant-#{name})"
|
raise Error, "Could not load integration #{name.inspect} (you may want to try installing the gem mutant-#{name})"
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,38 +4,23 @@ module Mutant
|
||||||
class Integration
|
class Integration
|
||||||
include AbstractType, Adamantium::Flat, Concord.new(:config)
|
include AbstractType, Adamantium::Flat, Concord.new(:config)
|
||||||
|
|
||||||
REGISTRY = {}
|
|
||||||
|
|
||||||
# Setup integration
|
# Setup integration
|
||||||
#
|
#
|
||||||
# @param [String] name
|
# Integrations are supposed to define a constant under
|
||||||
|
# Mutant::Integration named after the capitalized +name+
|
||||||
|
# parameter.
|
||||||
#
|
#
|
||||||
# @return [Integration]
|
# This avoids having to maintain a mutable registry.
|
||||||
def self.setup(name)
|
#
|
||||||
require "mutant/integration/#{name}"
|
# @param kernel [Kernel]
|
||||||
lookup(name)
|
# @param name [String]
|
||||||
|
#
|
||||||
|
# @return [Class<Integration>]
|
||||||
|
def self.setup(kernel, name)
|
||||||
|
kernel.require("mutant/integration/#{name}")
|
||||||
|
const_get(name.capitalize)
|
||||||
end
|
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
|
# Perform integration setup
|
||||||
#
|
#
|
||||||
# @return [self]
|
# @return [self]
|
||||||
|
@ -67,8 +52,6 @@ module Mutant
|
||||||
# Null integration that never kills a mutation
|
# Null integration that never kills a mutation
|
||||||
class Null < self
|
class Null < self
|
||||||
|
|
||||||
register('null')
|
|
||||||
|
|
||||||
# Available tests for integration
|
# Available tests for integration
|
||||||
#
|
#
|
||||||
# @return [Enumerable<Test>]
|
# @return [Enumerable<Test>]
|
||||||
|
@ -91,6 +74,5 @@ module Mutant
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Null
|
end # Null
|
||||||
|
|
||||||
end # Integration
|
end # Integration
|
||||||
end # Mutant
|
end # Mutant
|
||||||
|
|
|
@ -28,8 +28,6 @@ module Mutant
|
||||||
|
|
||||||
private_constant(*constants(false))
|
private_constant(*constants(false))
|
||||||
|
|
||||||
register 'rspec'
|
|
||||||
|
|
||||||
# Initialize rspec integration
|
# Initialize rspec integration
|
||||||
#
|
#
|
||||||
# @return [undefined]
|
# @return [undefined]
|
||||||
|
|
|
@ -151,6 +151,12 @@ Options:
|
||||||
context 'when integration exists' do
|
context 'when integration exists' do
|
||||||
let(:flags) { %w[--use rspec] }
|
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'
|
it_should_behave_like 'a cli parser'
|
||||||
|
|
||||||
let(:expected_integration) { Mutant::Integration::Rspec }
|
let(:expected_integration) { Mutant::Integration::Rspec }
|
||||||
|
|
|
@ -10,6 +10,20 @@ RSpec.describe Mutant::Integration do
|
||||||
subject { object.setup }
|
subject { object.setup }
|
||||||
it_should_behave_like 'a command method'
|
it_should_behave_like 'a command method'
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
RSpec.describe Mutant::Integration::Null do
|
RSpec.describe Mutant::Integration::Null do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue