From 8439096e113d797cb5070fc4631df93a445892b0 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 24 Jan 2016 21:16:43 +0000 Subject: [PATCH] Use class_double where appropriate --- spec/unit/mutant/actor/env_spec.rb | 4 ++-- spec/unit/mutant/env_spec.rb | 23 ++++++++++------------- spec/unit/mutant/loader_spec.rb | 2 +- spec/unit/mutant/repository/diff_spec.rb | 12 ++++++------ spec/unit/mutant/runner_spec.rb | 2 +- spec/unit/mutant/zombifier_spec.rb | 5 +---- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/spec/unit/mutant/actor/env_spec.rb b/spec/unit/mutant/actor/env_spec.rb index f3129017..cb0d98dd 100644 --- a/spec/unit/mutant/actor/env_spec.rb +++ b/spec/unit/mutant/actor/env_spec.rb @@ -1,6 +1,6 @@ RSpec.describe Mutant::Actor::Env do - let(:thread) { instance_double(Thread) } - let(:thread_root) { instance_double(Thread.singleton_class) } + let(:thread) { instance_double(Thread) } + let(:thread_root) { class_double(Thread) } let(:object) { described_class.new(thread_root) } diff --git a/spec/unit/mutant/env_spec.rb b/spec/unit/mutant/env_spec.rb index 21525531..79548d63 100644 --- a/spec/unit/mutant/env_spec.rb +++ b/spec/unit/mutant/env_spec.rb @@ -13,18 +13,15 @@ RSpec.describe Mutant::Env do ) end - let(:integration) { instance_double(Mutant::Integration) } - let(:wrapped_node) { instance_double(Parser::AST::Node) } - let(:context) { instance_double(Mutant::Context) } - let(:test_a) { instance_double(Mutant::Test) } - let(:test_b) { instance_double(Mutant::Test) } - let(:tests) { [test_a, test_b] } - let(:selector) { instance_double(Mutant::Selector) } - let(:integration_class) { Mutant::Integration::Null } - - let(:isolation) do - instance_double(Mutant::Isolation::Fork.singleton_class) - end + let(:integration) { instance_double(Mutant::Integration) } + let(:wrapped_node) { instance_double(Parser::AST::Node) } + let(:context) { instance_double(Mutant::Context) } + let(:test_a) { instance_double(Mutant::Test) } + let(:test_b) { instance_double(Mutant::Test) } + let(:tests) { [test_a, test_b] } + let(:selector) { instance_double(Mutant::Selector) } + let(:integration_class) { Mutant::Integration::Null } + let(:isolation) { class_double(Mutant::Isolation::Fork) } let(:mutation) do instance_double( @@ -37,7 +34,7 @@ RSpec.describe Mutant::Env do Mutant::Config::DEFAULT.with( isolation: isolation, integration: integration_class, - kernel: instance_double(Kernel.singleton_class) + kernel: class_double(Kernel) ) end diff --git a/spec/unit/mutant/loader_spec.rb b/spec/unit/mutant/loader_spec.rb index 1d550553..d6290d18 100644 --- a/spec/unit/mutant/loader_spec.rb +++ b/spec/unit/mutant/loader_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Mutant::Loader, '.call' do let(:path) { instance_double(Pathname, to_s: path_str) } let(:path_str) { instance_double(String) } let(:line) { instance_double(Fixnum) } - let(:kernel) { instance_double(Kernel.singleton_class) } + let(:kernel) { class_double(Kernel) } let(:binding) { instance_double(Binding) } let(:source) { instance_double(String) } let(:node) { instance_double(Parser::AST::Node) } diff --git a/spec/unit/mutant/repository/diff_spec.rb b/spec/unit/mutant/repository/diff_spec.rb index f821078f..eef3760f 100644 --- a/spec/unit/mutant/repository/diff_spec.rb +++ b/spec/unit/mutant/repository/diff_spec.rb @@ -17,12 +17,12 @@ describe Mutant::Repository::Diff do ) end - let(:pathname) { instance_double(Pathname.singleton_class, pwd: pwd) } - let(:open3) { instance_double(Open3.singleton_class) } - let(:kernel) { instance_double(Kernel.singleton_class) } - let(:pwd) { Pathname.new('/foo') } - let(:path) { Pathname.new('/foo/bar.rb') } - let(:line_range) { 1..2 } + let(:pathname) { class_double(Pathname, pwd: pwd) } + let(:open3) { class_double(Open3) } + let(:kernel) { class_double(Kernel) } + let(:pwd) { Pathname.new('/foo') } + let(:path) { Pathname.new('/foo/bar.rb') } + let(:line_range) { 1..2 } subject { object.touches?(path, line_range) } diff --git a/spec/unit/mutant/runner_spec.rb b/spec/unit/mutant/runner_spec.rb index bd9a584f..b827a097 100644 --- a/spec/unit/mutant/runner_spec.rb +++ b/spec/unit/mutant/runner_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Mutant::Runner do let(:delay) { instance_double(Float) } let(:env_result) { instance_double(Mutant::Result::Env) } let(:actor_env) { instance_double(Mutant::Actor::Env) } - let(:kernel) { instance_double(Kernel.singleton_class) } + let(:kernel) { class_double(Kernel) } let(:sleep) { instance_double(Method) } let(:env) do diff --git a/spec/unit/mutant/zombifier_spec.rb b/spec/unit/mutant/zombifier_spec.rb index 7dd5b3ef..98621a1a 100644 --- a/spec/unit/mutant/zombifier_spec.rb +++ b/spec/unit/mutant/zombifier_spec.rb @@ -1,9 +1,6 @@ RSpec.describe Mutant::Zombifier do let(:root_require) { Pathname.new('project') } - - let(:pathname) do - instance_double(::Pathname.singleton_class) - end + let(:pathname) { class_double(Pathname) } let(:require_highjack) do lambda do |block|