Fix Matcher env arguments
* Due historical reasons Env#warn also existed and in specs we actually passed an Env object where runtime passes Env::Boostrap objects. * Fix documentation for runtime type * Fix specs to pass in the runtime type * Remove now unused Env#warn
This commit is contained in:
parent
bbc7991feb
commit
3cea008fcd
16 changed files with 32 additions and 38 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1222
|
||||
total_score: 1208
|
||||
|
|
|
@ -16,18 +16,6 @@ module Mutant
|
|||
"Fix your lib to follow normal ruby semantics!\n" \
|
||||
'{Module,Class}#name should return resolvable constant name as String or nil'.freeze
|
||||
|
||||
# Print warning message
|
||||
#
|
||||
# @param [String]
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
def warn(message)
|
||||
config.reporter.warn(message)
|
||||
self
|
||||
end
|
||||
|
||||
# Kill mutation
|
||||
#
|
||||
# @param [Mutation] mutation
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mutant
|
|||
|
||||
# Call matcher
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -6,7 +6,7 @@ module Mutant
|
|||
|
||||
# Call matcher
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -6,7 +6,7 @@ module Mutant
|
|||
|
||||
# Enumerate matches
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -18,7 +18,7 @@ module Mutant
|
|||
|
||||
# Matched subjects
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -14,7 +14,7 @@ module Mutant
|
|||
|
||||
# Enumerate subjects
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -6,7 +6,7 @@ module Mutant
|
|||
|
||||
# Enumerate subjects
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -6,7 +6,7 @@ module Mutant
|
|||
|
||||
# Enumerate subjects
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -18,7 +18,7 @@ module Mutant
|
|||
|
||||
# Matched subjects
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
|
|
|
@ -24,7 +24,7 @@ module Mutant
|
|||
|
||||
# Report start
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
|
|
|
@ -7,7 +7,7 @@ module Mutant
|
|||
|
||||
# Start representation
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
|
@ -116,7 +116,7 @@ module Mutant
|
|||
|
||||
# Format start
|
||||
#
|
||||
# @param [Env] env
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
|
|
|
@ -33,13 +33,13 @@ RSpec.shared_examples_for 'a method matcher' do
|
|||
end
|
||||
|
||||
RSpec.shared_examples_for 'skipped candidate' do
|
||||
before do
|
||||
expected_warnings.each do |warning|
|
||||
expect(env).to receive(:warn).with(warning).and_return(env)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not emit matcher' do
|
||||
expect(subject).to eql([])
|
||||
end
|
||||
|
||||
it 'does warn' do
|
||||
subject
|
||||
|
||||
expect(env.config.reporter.warn_calls).to eql(expected_warnings)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,12 +42,6 @@ module ParserHelper
|
|||
Unparser.unparse(node)
|
||||
end
|
||||
|
||||
def test_env
|
||||
Fixtures::TEST_ENV.with(
|
||||
config: Mutant::Config::DEFAULT.with(reporter: Mutant::Reporter::Trace.new)
|
||||
)
|
||||
end
|
||||
|
||||
def parse(string)
|
||||
Unparser::Preprocessor.run(Parser::CurrentRuby.parse(string))
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ RSpec.describe Mutant::Matcher::Method::Instance, '#call' do
|
|||
subject { object.call(env) }
|
||||
|
||||
let(:object) { described_class.new(scope, method) }
|
||||
let(:env) { test_env }
|
||||
let(:method_name) { :foo }
|
||||
let(:source_path) { MutantSpec::ROOT.join('test_app/lib/test_app.rb') }
|
||||
let(:method) { scope.instance_method(method_name) }
|
||||
|
@ -11,6 +10,13 @@ RSpec.describe Mutant::Matcher::Method::Instance, '#call' do
|
|||
let(:method_arity) { 0 }
|
||||
let(:base) { TestApp::InstanceMethodTests }
|
||||
|
||||
let(:env) do
|
||||
instance_double(
|
||||
Mutant::Env::Bootstrap,
|
||||
parser: Fixtures::TEST_ENV.parser
|
||||
)
|
||||
end
|
||||
|
||||
def name
|
||||
node.children.fetch(0)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ RSpec.describe Mutant::Matcher::Method::Singleton, '#call' do
|
|||
subject { object.call(env) }
|
||||
|
||||
let(:object) { described_class.new(scope, method) }
|
||||
let(:env) { test_env }
|
||||
let(:method) { scope.method(method_name) }
|
||||
let(:type) { :defs }
|
||||
let(:method_name) { :foo }
|
||||
|
@ -10,6 +9,13 @@ RSpec.describe Mutant::Matcher::Method::Singleton, '#call' do
|
|||
let(:base) { TestApp::SingletonMethodTests }
|
||||
let(:source_path) { MutantSpec::ROOT.join('test_app/lib/test_app.rb') }
|
||||
|
||||
let(:env) do
|
||||
instance_double(
|
||||
Mutant::Env::Bootstrap,
|
||||
parser: Fixtures::TEST_ENV.parser
|
||||
)
|
||||
end
|
||||
|
||||
def name
|
||||
node.children.fetch(1)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue