free_mutant/spec/unit/mutant/subject/method/instance_spec.rb
Markus Schirp 41d9700473 Refactor runer infrastructure
* Nuke around 800 lock
* Honor LSP with not anymore squeezing something non LSP compatible in
  the same inheritance tree.
* Separate running from result tree.
* Clean up kill logic and early exits on already dead mutations.
* Fix #runnin? smell for reporters.
* Decouple config object from VM state. Makes it serializable to enable
  config loading.
* Fix sequence of global VM events to match PRIOR rspec infects VM with
  gazillions of classes / modules. Thix fixes a startup speed
  degeneration.
* Various fixes to enhance determinism.
* Replace some unneded manual double dispatch with single manual dispatch for
  reporter / runners.
2014-07-05 23:04:38 +00:00

116 lines
2.4 KiB
Ruby

# encoding: UTF-8
require 'spec_helper'
describe Mutant::Subject::Method::Instance do
let(:object) { described_class.new(config, context, node) }
let(:context) { double }
let(:config) { Mutant::Config::DEFAULT }
let(:node) do
s(:def, :foo, s(:args))
end
describe '#prepare' do
let(:context) do
Mutant::Context::Scope.new(scope, double('Source Path'))
end
let(:scope) do
Class.new do
attr_reader :bar
def initialize
@bar = :boo
end
def foo
end
end
end
subject { object.prepare }
context 'on non initialize methods' do
it 'undefines method on scope' do
expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
end
it_should_behave_like 'a command method'
end
context 'on initialize method' do
let(:node) do
s(:def, :initialize, s(:args))
end
it 'does not write warnings' do
warnings = Mutant::WarningFilter.use do
subject
end
expect(warnings).to eql([])
end
it 'undefines method on scope' do
subject
expect { scope.new }.to raise_error(NoMethodError)
end
it_should_behave_like 'a command method'
end
end
describe '#source' do
subject { object.source }
it { should eql("def foo\nend") }
end
end
describe Mutant::Subject::Method::Instance::Memoized do
let(:object) { described_class.new(config, context, node) }
let(:context) { double }
let(:config) { Mutant::Config::DEFAULT }
let(:node) do
s(:def, :foo, s(:args))
end
describe '#prepare' do
let(:context) do
Mutant::Context::Scope.new(scope, double('Source Path'))
end
let(:scope) do
Class.new do
include Memoizable
def foo
end
memoize :foo
end
end
subject { object.prepare }
it 'undefines memoizer' do
expect { subject }.to change { scope.memoized?(:foo) }.from(true).to(false)
end
it 'undefines method on scope' do
expect { subject }.to change { scope.instance_methods.include?(:foo) }.from(true).to(false)
end
it_should_behave_like 'a command method'
end
describe '#source' do
subject { object.source }
it { should eql("def foo\nend\nmemoize(:foo)") }
end
end