mutant 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/README.md +1 -1
  4. data/Rakefile +12 -8
  5. data/bin/mutant +5 -1
  6. data/config/flay.yml +1 -1
  7. data/lib/mutant.rb +18 -17
  8. data/lib/mutant/actor.rb +1 -7
  9. data/lib/mutant/actor/env.rb +0 -4
  10. data/lib/mutant/actor/mailbox.rb +0 -4
  11. data/lib/mutant/actor/receiver.rb +0 -4
  12. data/lib/mutant/actor/sender.rb +0 -2
  13. data/lib/mutant/ast.rb +1 -5
  14. data/lib/mutant/ast/meta/const.rb +0 -2
  15. data/lib/mutant/ast/meta/optarg.rb +0 -2
  16. data/lib/mutant/ast/meta/send.rb +0 -12
  17. data/lib/mutant/ast/named_children.rb +0 -10
  18. data/lib/mutant/ast/sexp.rb +1 -5
  19. data/lib/mutant/cli.rb +19 -38
  20. data/lib/mutant/color.rb +1 -7
  21. data/lib/mutant/config.rb +11 -7
  22. data/lib/mutant/context.rb +0 -4
  23. data/lib/mutant/context/scope.rb +0 -18
  24. data/lib/mutant/delegator.rb +0 -6
  25. data/lib/mutant/diff.rb +0 -18
  26. data/lib/mutant/env.rb +8 -24
  27. data/lib/mutant/env/bootstrap.rb +18 -41
  28. data/lib/mutant/expression.rb +0 -8
  29. data/lib/mutant/expression/method.rb +6 -7
  30. data/lib/mutant/expression/methods.rb +5 -9
  31. data/lib/mutant/expression/namespace.rb +0 -13
  32. data/lib/mutant/expression/parser.rb +0 -6
  33. data/lib/mutant/integration.rb +2 -20
  34. data/lib/mutant/isolation.rb +0 -4
  35. data/lib/mutant/loader.rb +20 -35
  36. data/lib/mutant/matcher.rb +1 -1
  37. data/lib/mutant/matcher/chain.rb +1 -3
  38. data/lib/mutant/matcher/compiler.rb +0 -8
  39. data/lib/mutant/matcher/config.rb +2 -10
  40. data/lib/mutant/matcher/filter.rb +1 -3
  41. data/lib/mutant/matcher/method.rb +4 -26
  42. data/lib/mutant/matcher/method/instance.rb +1 -7
  43. data/lib/mutant/matcher/method/singleton.rb +0 -12
  44. data/lib/mutant/matcher/methods.rb +1 -19
  45. data/lib/mutant/matcher/namespace.rb +1 -7
  46. data/lib/mutant/matcher/null.rb +1 -3
  47. data/lib/mutant/matcher/scope.rb +1 -5
  48. data/lib/mutant/matcher/static.rb +0 -2
  49. data/lib/mutant/meta.rb +0 -2
  50. data/lib/mutant/meta/example.rb +0 -28
  51. data/lib/mutant/meta/example/dsl.rb +2 -16
  52. data/lib/mutant/mutation.rb +9 -18
  53. data/lib/mutant/mutator.rb +0 -24
  54. data/lib/mutant/mutator/node.rb +1 -33
  55. data/lib/mutant/mutator/node/and_asgn.rb +0 -2
  56. data/lib/mutant/mutator/node/argument.rb +0 -10
  57. data/lib/mutant/mutator/node/arguments.rb +0 -12
  58. data/lib/mutant/mutator/node/begin.rb +0 -4
  59. data/lib/mutant/mutator/node/binary.rb +2 -11
  60. data/lib/mutant/mutator/node/block.rb +0 -6
  61. data/lib/mutant/mutator/node/break.rb +0 -2
  62. data/lib/mutant/mutator/node/case.rb +0 -6
  63. data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
  64. data/lib/mutant/mutator/node/const.rb +1 -3
  65. data/lib/mutant/mutator/node/define.rb +4 -11
  66. data/lib/mutant/mutator/node/defined.rb +0 -2
  67. data/lib/mutant/mutator/node/dstr.rb +0 -2
  68. data/lib/mutant/mutator/node/dsym.rb +0 -2
  69. data/lib/mutant/mutator/node/generic.rb +1 -3
  70. data/lib/mutant/mutator/node/if.rb +0 -8
  71. data/lib/mutant/mutator/node/kwbegin.rb +0 -2
  72. data/lib/mutant/mutator/node/literal/array.rb +0 -4
  73. data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
  74. data/lib/mutant/mutator/node/literal/fixnum.rb +0 -6
  75. data/lib/mutant/mutator/node/literal/float.rb +0 -6
  76. data/lib/mutant/mutator/node/literal/hash.rb +0 -6
  77. data/lib/mutant/mutator/node/literal/nil.rb +0 -2
  78. data/lib/mutant/mutator/node/literal/range.rb +0 -8
  79. data/lib/mutant/mutator/node/literal/regex.rb +0 -4
  80. data/lib/mutant/mutator/node/literal/string.rb +0 -2
  81. data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
  82. data/lib/mutant/mutator/node/masgn.rb +0 -2
  83. data/lib/mutant/mutator/node/match_current_line.rb +0 -2
  84. data/lib/mutant/mutator/node/mlhs.rb +0 -2
  85. data/lib/mutant/mutator/node/named_value/access.rb +0 -8
  86. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +1 -7
  87. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -4
  88. data/lib/mutant/mutator/node/next.rb +0 -2
  89. data/lib/mutant/mutator/node/noop.rb +0 -2
  90. data/lib/mutant/mutator/node/nthref.rb +0 -2
  91. data/lib/mutant/mutator/node/op_asgn.rb +0 -2
  92. data/lib/mutant/mutator/node/or_asgn.rb +0 -2
  93. data/lib/mutant/mutator/node/resbody.rb +0 -4
  94. data/lib/mutant/mutator/node/rescue.rb +0 -10
  95. data/lib/mutant/mutator/node/return.rb +0 -2
  96. data/lib/mutant/mutator/node/send.rb +4 -32
  97. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -6
  98. data/lib/mutant/mutator/node/send/binary.rb +0 -6
  99. data/lib/mutant/mutator/node/send/index.rb +0 -6
  100. data/lib/mutant/mutator/node/splat.rb +0 -2
  101. data/lib/mutant/mutator/node/super.rb +0 -2
  102. data/lib/mutant/mutator/node/when.rb +0 -10
  103. data/lib/mutant/mutator/node/yield.rb +0 -2
  104. data/lib/mutant/mutator/node/zsuper.rb +0 -2
  105. data/lib/mutant/mutator/registry.rb +0 -6
  106. data/lib/mutant/mutator/util.rb +0 -4
  107. data/lib/mutant/mutator/util/array.rb +0 -6
  108. data/lib/mutant/mutator/util/symbol.rb +0 -2
  109. data/lib/mutant/parallel.rb +21 -17
  110. data/lib/mutant/parallel/master.rb +0 -28
  111. data/lib/mutant/parallel/source.rb +0 -10
  112. data/lib/mutant/parallel/worker.rb +15 -10
  113. data/lib/mutant/parser.rb +23 -0
  114. data/lib/mutant/reporter.rb +5 -8
  115. data/lib/mutant/reporter/cli.rb +1 -15
  116. data/lib/mutant/reporter/cli/format.rb +3 -25
  117. data/lib/mutant/reporter/cli/printer.rb +0 -18
  118. data/lib/mutant/reporter/cli/printer/config.rb +0 -2
  119. data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -2
  120. data/lib/mutant/reporter/cli/printer/env_result.rb +0 -2
  121. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -4
  122. data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -16
  123. data/lib/mutant/reporter/cli/printer/status.rb +0 -6
  124. data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -4
  125. data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -8
  126. data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -2
  127. data/lib/mutant/reporter/cli/printer/test_result.rb +0 -2
  128. data/lib/mutant/reporter/cli/tput.rb +0 -4
  129. data/lib/mutant/repository.rb +4 -22
  130. data/lib/mutant/require_highjack.rb +0 -2
  131. data/lib/mutant/result.rb +23 -43
  132. data/lib/mutant/runner.rb +7 -20
  133. data/lib/mutant/runner/sink.rb +43 -86
  134. data/lib/mutant/selector.rb +0 -2
  135. data/lib/mutant/selector/expression.rb +0 -2
  136. data/lib/mutant/subject.rb +0 -22
  137. data/lib/mutant/subject/method.rb +2 -10
  138. data/lib/mutant/subject/method/instance.rb +0 -6
  139. data/lib/mutant/subject/method/singleton.rb +0 -2
  140. data/lib/mutant/test.rb +4 -3
  141. data/lib/mutant/version.rb +1 -1
  142. data/lib/mutant/warning_filter.rb +0 -10
  143. data/lib/mutant/zombifier.rb +5 -20
  144. data/meta/or_asgn.rb +6 -0
  145. data/meta/send.rb +29 -0
  146. data/mutant-rspec.gemspec +1 -1
  147. data/spec/integration/mutant/rspec_spec.rb +1 -1
  148. data/spec/integrations.yml +2 -3
  149. data/spec/shared/method_matcher_behavior.rb +7 -7
  150. data/spec/spec_helper.rb +2 -9
  151. data/spec/support/corpus.rb +37 -30
  152. data/spec/support/rb_bug.rb +1 -2
  153. data/spec/support/ruby_vm.rb +6 -3
  154. data/spec/support/shared_context.rb +19 -20
  155. data/spec/unit/mutant/actor/binding_spec.rb +6 -6
  156. data/spec/unit/mutant/actor/env_spec.rb +2 -2
  157. data/spec/unit/mutant/actor/mailbox_spec.rb +6 -6
  158. data/spec/unit/mutant/actor/message_spec.rb +2 -2
  159. data/spec/unit/mutant/actor/receiver_spec.rb +4 -4
  160. data/spec/unit/mutant/actor/sender_spec.rb +6 -6
  161. data/spec/unit/mutant/ast_spec.rb +9 -0
  162. data/spec/unit/mutant/cli_spec.rb +16 -10
  163. data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
  164. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -1
  165. data/spec/unit/mutant/context/scope_spec.rb +3 -3
  166. data/spec/unit/mutant/context_spec.rb +0 -22
  167. data/spec/unit/mutant/env/boostrap_spec.rb +34 -41
  168. data/spec/unit/mutant/env_spec.rb +74 -32
  169. data/spec/unit/mutant/integration/rspec_spec.rb +23 -17
  170. data/spec/unit/mutant/integration_spec.rb +4 -4
  171. data/spec/unit/mutant/isolation_spec.rb +4 -4
  172. data/spec/unit/mutant/loader_spec.rb +42 -0
  173. data/spec/unit/mutant/matcher/compiler_spec.rb +3 -3
  174. data/spec/unit/mutant/matcher/config_spec.rb +1 -1
  175. data/spec/unit/mutant/matcher/method/instance_spec.rb +8 -1
  176. data/spec/unit/mutant/matcher/method/singleton_spec.rb +8 -1
  177. data/spec/unit/mutant/matcher/namespace_spec.rb +7 -8
  178. data/spec/unit/mutant/matcher/null_spec.rb +3 -2
  179. data/spec/unit/mutant/mutation_spec.rb +11 -5
  180. data/spec/unit/mutant/mutator/registry_spec.rb +1 -1
  181. data/spec/unit/mutant/parallel/master_spec.rb +9 -9
  182. data/spec/unit/mutant/parallel/source/array_spec.rb +3 -3
  183. data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
  184. data/spec/unit/mutant/parallel_spec.rb +4 -4
  185. data/spec/unit/mutant/parser_spec.rb +24 -0
  186. data/spec/unit/mutant/reporter/cli/printer_spec.rb +3 -3
  187. data/spec/unit/mutant/reporter/cli/tput_spec.rb +2 -2
  188. data/spec/unit/mutant/reporter/cli_spec.rb +7 -7
  189. data/spec/unit/mutant/reporter/null_spec.rb +5 -4
  190. data/spec/unit/mutant/repository/diff_spec.rb +30 -18
  191. data/spec/unit/mutant/repository/subject_filter_spec.rb +5 -5
  192. data/spec/unit/mutant/require_highjack_spec.rb +1 -1
  193. data/spec/unit/mutant/result/env_spec.rb +9 -9
  194. data/spec/unit/mutant/result/subject_spec.rb +5 -5
  195. data/spec/unit/mutant/runner/driver_spec.rb +4 -4
  196. data/spec/unit/mutant/runner/{sink/mutation_spec.rb → sink_spec.rb} +16 -4
  197. data/spec/unit/mutant/runner_spec.rb +31 -31
  198. data/spec/unit/mutant/selector/expression_spec.rb +8 -8
  199. data/spec/unit/mutant/subject/method/instance_spec.rb +9 -3
  200. data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
  201. data/spec/unit/mutant/subject_spec.rb +1 -5
  202. data/spec/unit/mutant_spec.rb +3 -3
  203. metadata +9 -15
  204. data/config/mutant.yml +0 -14
  205. data/lib/mutant/cache.rb +0 -29
  206. data/lib/mutant/reporter/trace.rb +0 -36
  207. data/spec/support/rspec.rb +0 -21
  208. data/spec/unit/mutant/cache_spec.rb +0 -22
  209. data/spec/unit/mutant/loader/eval_spec.rb +0 -44
  210. data/spec/unit/mutant/reporter/trace_spec.rb +0 -21
  211. data/test_app/Gemfile.rspec3.2 +0 -7
@@ -6,8 +6,8 @@ RSpec.describe Mutant::Reporter::CLI::Tput do
6
6
  allow(Open3).to receive(:capture3).with(command).ordered.and_return(
7
7
  [
8
8
  stdout,
9
- double('Stderr'),
10
- double('Exitstatus', success?: success)
9
+ instance_double(IO),
10
+ instance_double(Process::Status, success?: success)
11
11
  ]
12
12
  )
13
13
  end
@@ -5,8 +5,8 @@ RSpec.describe Mutant::Reporter::CLI do
5
5
  let(:output) { StringIO.new }
6
6
 
7
7
  let(:tput) do
8
- double(
9
- 'tput',
8
+ instance_double(
9
+ Mutant::Reporter::CLI::Tput,
10
10
  restore: '[tput-restore]',
11
11
  prepare: '[tput-prepare]'
12
12
  )
@@ -61,9 +61,9 @@ RSpec.describe Mutant::Reporter::CLI do
61
61
  expect(ENV).to receive(:key?).with('CI').and_return(ci?)
62
62
  end
63
63
 
64
- let(:output) { double('Output', tty?: tty?) }
65
- let(:tty?) { true }
66
- let(:ci?) { false }
64
+ let(:output) { instance_double(IO, tty?: tty?) }
65
+ let(:tty?) { true }
66
+ let(:ci?) { false }
67
67
 
68
68
  context 'when not on CI and on a tty' do
69
69
  before do
@@ -92,8 +92,8 @@ RSpec.describe Mutant::Reporter::CLI do
92
92
  end
93
93
 
94
94
  context 'when output does not respond to #tty?' do
95
- let(:output) { double('Output') }
96
- let(:tty?) { false }
95
+ let(:output) { instance_double(IO) }
96
+ let(:tty?) { false }
97
97
 
98
98
  it { should eql(described_class.new(output, progressive_format)) }
99
99
  end
@@ -1,20 +1,21 @@
1
1
  RSpec.describe Mutant::Reporter::Null do
2
- let(:object) { described_class.new }
2
+ let(:object) { described_class.new }
3
+ let(:value) { instance_double(Object) }
3
4
 
4
5
  describe '#report' do
5
- subject { object.report(double('some input')) }
6
+ subject { object.report(value) }
6
7
 
7
8
  it_should_behave_like 'a command method'
8
9
  end
9
10
 
10
11
  describe '#warn' do
11
- subject { object.warn(double('some input')) }
12
+ subject { object.warn(value) }
12
13
 
13
14
  it_should_behave_like 'a command method'
14
15
  end
15
16
 
16
17
  describe '#progress' do
17
- subject { object.progress(double('some input')) }
18
+ subject { object.progress(value) }
18
19
 
19
20
  it_should_behave_like 'a command method'
20
21
  end
@@ -1,22 +1,34 @@
1
1
  describe Mutant::Repository::Diff do
2
- describe '.from_head' do
3
- subject { described_class.from_head(to_revision) }
4
-
5
- let(:to_revision) { double('to revision') }
2
+ describe '#touches?' do
3
+ let(:object) do
4
+ described_class.new(
5
+ config: config,
6
+ from: 'from_rev',
7
+ to: 'to_rev'
8
+ )
9
+ end
6
10
 
7
- it { should eql(described_class.new('HEAD', to_revision)) }
8
- end
11
+ let(:config) do
12
+ instance_double(
13
+ Mutant::Config,
14
+ kernel: kernel,
15
+ open3: open3,
16
+ pathname: pathname
17
+ )
18
+ end
9
19
 
10
- describe '#touches?' do
11
- let(:object) { described_class.new('from_rev', 'to_rev') }
12
- let(:path) { Pathname.pwd.join('foo.rb') }
13
- let(:line_range) { 1..2 }
20
+ let(:pathname) { instance_double(Pathname.singleton_class, pwd: pwd) }
21
+ let(:open3) { instance_double(Open3.singleton_class) }
22
+ let(:kernel) { instance_double(Kernel.singleton_class) }
23
+ let(:pwd) { Pathname.new('/foo') }
24
+ let(:path) { Pathname.new('/foo/bar.rb') }
25
+ let(:line_range) { 1..2 }
14
26
 
15
27
  subject { object.touches?(path, line_range) }
16
28
 
17
29
  shared_context 'test if git tracks the file' do
18
30
  before do
19
- expect(Kernel).to receive(:system)
31
+ expect(config.kernel).to receive(:system)
20
32
  .ordered
21
33
  .with(
22
34
  *%W[git ls-files --error-unmatch -- #{path}],
@@ -27,10 +39,10 @@ describe Mutant::Repository::Diff do
27
39
  end
28
40
 
29
41
  context 'when file is in a different subdirectory' do
30
- let(:path) { Pathname.new('/foo.rb') }
42
+ let(:path) { Pathname.new('/baz/bar.rb') }
31
43
 
32
44
  before do
33
- expect(Kernel).to_not receive(:system)
45
+ expect(config.kernel).to_not receive(:system)
34
46
  end
35
47
 
36
48
  it { should be(false) }
@@ -45,15 +57,15 @@ describe Mutant::Repository::Diff do
45
57
  end
46
58
 
47
59
  context 'when file is tracked in repository' do
48
- let(:git_ls_success?) { true }
49
- let(:status) { double('Status', success?: success?) }
50
- let(:stdout) { double('Stdout', empty?: stdout_empty?) }
51
- let(:stdout_empty?) { false }
60
+ let(:git_ls_success?) { true }
61
+ let(:status) { instance_double(Process::Status, success?: success?) }
62
+ let(:stdout) { instance_double(String, empty?: stdout_empty?) }
63
+ let(:stdout_empty?) { false }
52
64
 
53
65
  include_context 'test if git tracks the file'
54
66
 
55
67
  before do
56
- expect(Open3).to receive(:capture2)
68
+ expect(config.open3).to receive(:capture2)
57
69
  .ordered
58
70
  .with(*expected_git_log_command, binmode: true)
59
71
  .and_return([stdout, status])
@@ -2,9 +2,9 @@ RSpec.describe Mutant::Repository::SubjectFilter do
2
2
  context '#call' do
3
3
  subject { object.call(mutant_subject) }
4
4
 
5
- let(:object) { described_class.new(diff) }
6
- let(:diff) { double('Diff') }
7
- let(:return_value) { double('Return Value') }
5
+ let(:object) { described_class.new(diff) }
6
+ let(:diff) { instance_double(Mutant::Repository::Diff) }
7
+ let(:value) { instance_double(Object, 'value') }
8
8
 
9
9
  let(:mutant_subject) do
10
10
  double(
@@ -18,11 +18,11 @@ RSpec.describe Mutant::Repository::SubjectFilter do
18
18
  expect(diff).to receive(:touches?).with(
19
19
  mutant_subject.source_path,
20
20
  mutant_subject.source_lines
21
- ).and_return(return_value)
21
+ ).and_return(value)
22
22
  end
23
23
 
24
24
  it 'connects return value to repository diff API' do
25
- expect(subject).to be(return_value)
25
+ expect(subject).to be(value)
26
26
  end
27
27
  end
28
28
  end
@@ -17,7 +17,7 @@ RSpec.describe Mutant::RequireHighjack do
17
17
  end
18
18
 
19
19
  describe '.call' do
20
- let(:logical_name) { double('Logical Name') }
20
+ let(:logical_name) { instance_double(String) }
21
21
 
22
22
  def apply
23
23
  described_class.call(target_module, highjacked_calls.method(:<<))
@@ -1,31 +1,31 @@
1
1
  RSpec.describe Mutant::Result::Env do
2
2
  let(:object) do
3
3
  described_class.new(
4
- runtime: double('Runtime'),
4
+ runtime: instance_double(Float),
5
5
  env: env,
6
6
  subject_results: [subject_result]
7
7
  )
8
8
  end
9
9
 
10
10
  let(:env) do
11
- double(
12
- 'Env',
11
+ instance_double(
12
+ Mutant::Env,
13
13
  config: config,
14
- subjects: [double('Subject')],
15
- mutations: [double('Mutation')]
14
+ subjects: [instance_double(Mutant::Subject)],
15
+ mutations: [instance_double(Mutant::Mutation)]
16
16
  )
17
17
  end
18
18
 
19
19
  let(:config) do
20
- double(
21
- 'Config',
20
+ instance_double(
21
+ Mutant::Config,
22
22
  expected_coverage: Rational(1, 1)
23
23
  )
24
24
  end
25
25
 
26
26
  let(:subject_result) do
27
- double(
28
- 'Subject Result',
27
+ instance_double(
28
+ Mutant::Result::Subject,
29
29
  amount_mutation_results: results,
30
30
  amount_mutations_killed: killed,
31
31
  success?: true
@@ -7,7 +7,7 @@ RSpec.describe Mutant::Result::Subject do
7
7
  )
8
8
  end
9
9
 
10
- let(:mutation_subject) { double('Subject') }
10
+ let(:mutation_subject) { instance_double(Mutant::Subject) }
11
11
 
12
12
  describe '#continue?' do
13
13
  subject { object.continue? }
@@ -19,13 +19,13 @@ RSpec.describe Mutant::Result::Subject do
19
19
  end
20
20
 
21
21
  context 'with failing mutation result' do
22
- let(:mutation_results) { [double('Mutation Result', success?: false)] }
22
+ let(:mutation_results) { [instance_double(Mutant::Result::Mutation, success?: false)] }
23
23
 
24
24
  it { should be(false) }
25
25
  end
26
26
 
27
27
  context 'with successful mutation result' do
28
- let(:mutation_results) { [double('Mutation Result', success?: true)] }
28
+ let(:mutation_results) { [instance_double(Mutant::Result::Mutation, success?: true)] }
29
29
 
30
30
  it { should be(true) }
31
31
  end
@@ -33,8 +33,8 @@ RSpec.describe Mutant::Result::Subject do
33
33
  context 'with failed and successful mutation result' do
34
34
  let(:mutation_results) do
35
35
  [
36
- double('Mutation Result', success?: true),
37
- double('Mutation Result', success?: false)
36
+ instance_double(Mutant::Result::Mutation, success?: true),
37
+ instance_double(Mutant::Result::Mutation, success?: false)
38
38
  ]
39
39
  end
40
40
 
@@ -1,8 +1,8 @@
1
1
  RSpec.describe Mutant::Parallel::Driver do
2
2
  let(:object) { described_class.new(binding) }
3
3
 
4
- let(:binding) { double('Binding') }
5
- let(:result) { double('Result') }
4
+ let(:binding) { instance_double(Mutant::Actor::Binding) }
5
+ let(:value) { instance_double(Object, 'value') }
6
6
 
7
7
  describe '#stop' do
8
8
  subject { object.stop }
@@ -18,9 +18,9 @@ RSpec.describe Mutant::Parallel::Driver do
18
18
  subject { object.status }
19
19
 
20
20
  before do
21
- expect(binding).to receive(:call).with(:status).and_return(result)
21
+ expect(binding).to receive(:call).with(:status).and_return(value)
22
22
  end
23
23
 
24
- it { should be(result) }
24
+ it { should be(value) }
25
25
  end
26
26
  end
@@ -1,4 +1,4 @@
1
- describe Mutant::Runner::Sink::Mutation do
1
+ describe Mutant::Runner::Sink do
2
2
  setup_shared_context
3
3
 
4
4
  shared_context 'one result' do
@@ -43,7 +43,11 @@ describe Mutant::Runner::Sink::Mutation do
43
43
 
44
44
  context 'no results' do
45
45
  let(:expected_status) do
46
- Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: [])
46
+ Mutant::Result::Env.new(
47
+ env: env,
48
+ runtime: 0.0,
49
+ subject_results: []
50
+ )
47
51
  end
48
52
 
49
53
  it { should eql(expected_status) }
@@ -55,7 +59,11 @@ describe Mutant::Runner::Sink::Mutation do
55
59
  with(:subject_a_result) { { mutation_results: [mutation_a_result] } }
56
60
 
57
61
  let(:expected_status) do
58
- Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: [subject_a_result])
62
+ Mutant::Result::Env.new(
63
+ env: env,
64
+ runtime: 0.0,
65
+ subject_results: [subject_a_result]
66
+ )
59
67
  end
60
68
 
61
69
  it { should eql(expected_status) }
@@ -65,7 +73,11 @@ describe Mutant::Runner::Sink::Mutation do
65
73
  include_context 'two results'
66
74
 
67
75
  let(:expected_status) do
68
- Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: [subject_a_result])
76
+ Mutant::Result::Env.new(
77
+ env: env,
78
+ runtime: 0.0,
79
+ subject_results: [subject_a_result]
80
+ )
69
81
  end
70
82
 
71
83
  it { should eql(expected_status) }
@@ -1,45 +1,45 @@
1
1
  RSpec.describe Mutant::Runner do
2
- # setup_shared_context
3
- class FakeEnv
4
- def self.kill
5
- end
2
+ describe '.call' do
3
+ let(:integration) { instance_double(Mutant::Integration) }
4
+ let(:reporter) { instance_double(Mutant::Reporter, delay: delay) }
5
+ let(:driver) { instance_double(Mutant::Parallel::Driver) }
6
+ let(:delay) { instance_double(Float) }
7
+ let(:env_result) { instance_double(Mutant::Result::Env) }
8
+ let(:actor_env) { instance_double(Mutant::Actor::Env) }
9
+ let(:kernel) { instance_double(Kernel.singleton_class) }
10
+ let(:sleep) { instance_double(Method) }
6
11
 
7
- def self.mutations
8
- []
12
+ let(:env) do
13
+ instance_double(
14
+ Mutant::Env,
15
+ actor_env: actor_env,
16
+ config: config,
17
+ mutations: []
18
+ )
9
19
  end
10
- end
11
-
12
- describe '.call' do
13
- let(:integration) { double('Integration') }
14
- let(:reporter) { double('Reporter', delay: delay) }
15
- let(:driver) { double('Driver') }
16
- let(:delay) { double('Delay') }
17
- let(:env) { FakeEnv }
18
- let(:env_result) { double('Env Result') }
19
- let(:actor_env) { double('Actor ENV') }
20
20
 
21
21
  let(:config) do
22
- double(
23
- 'Config',
22
+ instance_double(
23
+ Mutant::Config,
24
24
  integration: integration,
25
- reporter: reporter,
26
- actor_env: actor_env,
27
- jobs: 1
25
+ jobs: 1,
26
+ kernel: kernel,
27
+ reporter: reporter
28
28
  )
29
29
  end
30
30
 
31
31
  before do
32
- allow(FakeEnv).to receive(:config).and_return(config)
33
- allow(FakeEnv).to receive(:actor_env).and_return(actor_env)
32
+ allow(env).to receive(:method).with(:kill).and_return(parallel_config.processor)
33
+ allow(kernel).to receive(:method).with(:sleep).and_return(sleep)
34
34
  end
35
35
 
36
36
  let(:parallel_config) do
37
37
  Mutant::Parallel::Config.new(
38
- jobs: 1,
39
38
  env: actor_env,
40
- source: Mutant::Parallel::Source::Array.new(env.mutations),
41
- sink: Mutant::Runner::Sink::Mutation.new(env),
42
- processor: env.method(:kill)
39
+ jobs: 1,
40
+ processor: ->(_object) { fail },
41
+ sink: Mutant::Runner::Sink.new(env),
42
+ source: Mutant::Parallel::Source::Array.new(env.mutations)
43
43
  )
44
44
  end
45
45
 
@@ -51,7 +51,7 @@ RSpec.describe Mutant::Runner do
51
51
  subject { described_class.call(env) }
52
52
 
53
53
  context 'when runner finishes immediately' do
54
- let(:status) { double('Status', done: true, payload: env_result) }
54
+ let(:status) { instance_double(Mutant::Parallel::Status, done: true, payload: env_result) }
55
55
 
56
56
  before do
57
57
  expect(driver).to receive(:status).and_return(status)
@@ -62,13 +62,13 @@ RSpec.describe Mutant::Runner do
62
62
  end
63
63
 
64
64
  context 'when report iterations are done' do
65
- let(:status_a) { double('Status A', done: false) }
66
- let(:status_b) { double('Status B', done: true, payload: env_result) }
65
+ let(:status_a) { instance_double(Mutant::Parallel::Status, done: false) }
66
+ let(:status_b) { instance_double(Mutant::Parallel::Status, done: true, payload: env_result) }
67
67
 
68
68
  before do
69
69
  expect(driver).to receive(:status).and_return(status_a).ordered
70
70
  expect(reporter).to receive(:progress).with(status_a).ordered
71
- expect(Kernel).to receive(:sleep).with(reporter.delay).ordered
71
+ expect(sleep).to receive(:call).with(reporter.delay).ordered
72
72
 
73
73
  expect(driver).to receive(:status).and_return(status_b).ordered
74
74
  expect(reporter).to receive(:progress).with(status_b).ordered
@@ -16,14 +16,14 @@ RSpec.describe Mutant::Selector::Expression do
16
16
  end
17
17
  end
18
18
 
19
- let(:mutation_subject) { subject_class.new(context, node) }
20
- let(:context) { double('Context') }
21
- let(:node) { double('Node') }
22
- let(:config) { Mutant::Config::DEFAULT.with(integration: integration) }
23
- let(:integration) { double('Integration', all_tests: all_tests) }
24
- let(:test_a) { double('test a', expression: parse_expression('SubjectA')) }
25
- let(:test_b) { double('test b', expression: parse_expression('SubjectB')) }
26
- let(:test_c) { double('test c', expression: parse_expression('SubjectC')) }
19
+ let(:mutation_subject) { subject_class.new(context, node) }
20
+ let(:context) { instance_double(Mutant::Context) }
21
+ let(:node) { instance_double(Parser::AST::Node) }
22
+ let(:config) { Mutant::Config::DEFAULT.with(integration: integration) }
23
+ let(:integration) { instance_double(Mutant::Integration, all_tests: all_tests) }
24
+ let(:test_a) { instance_double(Mutant::Test, expression: parse_expression('SubjectA')) }
25
+ let(:test_b) { instance_double(Mutant::Test, expression: parse_expression('SubjectB')) }
26
+ let(:test_c) { instance_double(Mutant::Test, expression: parse_expression('SubjectC')) }
27
27
 
28
28
  subject { object.call(mutation_subject) }
29
29