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
@@ -3,8 +3,8 @@ require 'mutant/integration/rspec'
3
3
  RSpec.describe Mutant::Integration::Rspec do
4
4
  let(:object) { described_class.new(Mutant::Config::DEFAULT) }
5
5
 
6
- let(:options) { double('options') }
7
- let(:runner) { double('runner') }
6
+ let(:rspec_options) { instance_double(RSpec::Core::ConfigurationOptions) }
7
+ let(:rspec_runner) { instance_double(RSpec::Core::Runner) }
8
8
 
9
9
  let(:example_a) do
10
10
  double(
@@ -115,10 +115,16 @@ RSpec.describe Mutant::Integration::Rspec do
115
115
  end
116
116
 
117
117
  before do
118
- expect(RSpec::Core::ConfigurationOptions).to receive(:new).with(%w[spec --fail-fast]).and_return(options)
119
- expect(RSpec::Core::Runner).to receive(:new).with(options).and_return(runner)
120
- expect(RSpec).to receive(:world).with(no_args).and_return(world)
121
- allow(Time).to receive(:now).and_return(Time.now)
118
+ expect(RSpec::Core::ConfigurationOptions).to receive(:new)
119
+ .with(%w[spec --fail-fast])
120
+ .and_return(rspec_options)
121
+
122
+ expect(RSpec::Core::Runner).to receive(:new)
123
+ .with(rspec_options)
124
+ .and_return(rspec_runner)
125
+
126
+ expect(RSpec).to receive_messages(world: world)
127
+ allow(Time).to receive_messages(now: Time.now)
122
128
  end
123
129
 
124
130
  describe '#all_tests' do
@@ -131,7 +137,7 @@ RSpec.describe Mutant::Integration::Rspec do
131
137
  subject { object.setup }
132
138
 
133
139
  before do
134
- expect(runner).to receive(:setup) do |error, output|
140
+ expect(rspec_runner).to receive(:setup) do |error, output|
135
141
  expect(error).to be($stderr)
136
142
  output.write('foo')
137
143
  end
@@ -144,7 +150,7 @@ RSpec.describe Mutant::Integration::Rspec do
144
150
  subject { object.call(tests) }
145
151
 
146
152
  before do
147
- expect(runner).to receive(:setup) do |_errors, output|
153
+ expect(rspec_runner).to receive(:setup) do |_errors, output|
148
154
  output.write('the-test-output')
149
155
  end
150
156
 
@@ -157,7 +163,7 @@ RSpec.describe Mutant::Integration::Rspec do
157
163
  expect(world).to receive(:ordered_example_groups) do
158
164
  filtered_examples.values.flatten
159
165
  end
160
- expect(runner).to receive(:run_specs).with([example_a]).and_return(exit_status)
166
+ expect(rspec_runner).to receive(:run_specs).with([example_a]).and_return(exit_status)
161
167
  end
162
168
 
163
169
  context 'on unsuccessful exit' do
@@ -166,10 +172,10 @@ RSpec.describe Mutant::Integration::Rspec do
166
172
  it 'should return failed result' do
167
173
  expect(subject).to eql(
168
174
  Mutant::Result::Test.new(
169
- tests: tests,
170
- output: 'the-test-output',
171
- passed: false,
172
- runtime: 0.0
175
+ output: 'the-test-output',
176
+ passed: false,
177
+ runtime: 0.0,
178
+ tests: tests
173
179
  )
174
180
  )
175
181
  end
@@ -181,10 +187,10 @@ RSpec.describe Mutant::Integration::Rspec do
181
187
  it 'should return passed result' do
182
188
  expect(subject).to eql(
183
189
  Mutant::Result::Test.new(
184
- tests: tests,
185
- output: 'the-test-output',
186
- passed: true,
187
- runtime: 0.0
190
+ output: 'the-test-output',
191
+ passed: true,
192
+ runtime: 0.0,
193
+ tests: tests
188
194
  )
189
195
  )
190
196
  end
@@ -25,17 +25,17 @@ RSpec.describe Mutant::Integration::Null do
25
25
  end
26
26
 
27
27
  describe '#call' do
28
- let(:tests) { double('Tests') }
28
+ let(:tests) { instance_double(Array) }
29
29
 
30
30
  subject { object.call(tests) }
31
31
 
32
32
  it 'returns test result' do
33
33
  should eql(
34
34
  Mutant::Result::Test.new(
35
- tests: tests,
36
- runtime: 0.0,
35
+ output: '',
37
36
  passed: true,
38
- output: ''
37
+ runtime: 0.0,
38
+ tests: tests
39
39
  )
40
40
  )
41
41
  end
@@ -65,8 +65,8 @@ RSpec.describe Mutant::Isolation::Fork do
65
65
  end
66
66
 
67
67
  context 'uses primitives in correct order' do
68
- let(:reader) { double('reader') }
69
- let(:writer) { double('writer') }
68
+ let(:reader) { instance_double(IO) }
69
+ let(:writer) { instance_double(IO) }
70
70
 
71
71
  before do
72
72
  expect(IO).to receive(:pipe).with(binmode: true).ordered do |&block|
@@ -76,9 +76,9 @@ RSpec.describe Mutant::Isolation::Fork do
76
76
  end
77
77
 
78
78
  it 'when fork succeeds' do
79
- pid = double('PID')
79
+ pid = instance_double(Fixnum)
80
80
  expect(Process).to receive(:fork).ordered.and_yield.and_return(pid)
81
- file = double('file')
81
+ file = instance_double(File)
82
82
  expect(File).to receive(:open).ordered
83
83
  .with(File::NULL, File::WRONLY).and_yield(file)
84
84
  expect($stderr).to receive(:reopen).ordered.with(file)
@@ -0,0 +1,42 @@
1
+ RSpec.describe Mutant::Loader, '.call' do
2
+ subject do
3
+ described_class.call(
4
+ binding: binding,
5
+ kernel: kernel,
6
+ node: node,
7
+ subject: mutation_subject
8
+ )
9
+ end
10
+
11
+ let(:path) { instance_double(Pathname, to_s: path_str) }
12
+ let(:path_str) { instance_double(String) }
13
+ let(:line) { instance_double(Fixnum) }
14
+ let(:kernel) { instance_double(Kernel.singleton_class) }
15
+ let(:binding) { instance_double(Binding) }
16
+ let(:source) { instance_double(String) }
17
+ let(:node) { instance_double(Parser::AST::Node) }
18
+
19
+ let(:mutation_subject) do
20
+ instance_double(
21
+ Mutant::Subject,
22
+ source_path: path,
23
+ source_line: line
24
+ )
25
+ end
26
+
27
+ it 'performs expected kernel interaction' do
28
+ expect(Unparser).to receive(:unparse)
29
+ .with(node)
30
+ .and_return(source)
31
+
32
+ expect(kernel).to receive(:eval)
33
+ .with(
34
+ source,
35
+ binding,
36
+ path_str,
37
+ line
38
+ )
39
+
40
+ subject
41
+ end
42
+ end
@@ -62,14 +62,14 @@ RSpec.describe Mutant::Matcher::Compiler, '#call' do
62
62
  end
63
63
 
64
64
  context 'and subject filters' do
65
- let(:filter) { double('filter') }
65
+ let(:subject_filter) { instance_double(Mutant::Matcher) }
66
66
 
67
67
  let(:attributes) do
68
- super().merge(subject_filters: [filter])
68
+ super().merge(subject_filters: [subject_filter])
69
69
  end
70
70
 
71
71
  let(:subject_filter_predicates) do
72
- [filter]
72
+ [subject_filter]
73
73
  end
74
74
 
75
75
  it { should eql(expected_matcher) }
@@ -30,7 +30,7 @@ RSpec.describe Mutant::Matcher::Config do
30
30
  .add(:ignore_expressions, parse_expression('Bar'))
31
31
  end
32
32
 
33
- it { should eql('#<Mutant::Matcher::Config match_expressions: [Foo] ignore_expressions: [Bar]>') }
33
+ it { should eql('#<Mutant::Matcher::Config ignore_expressions: [Bar] match_expressions: [Foo]>') }
34
34
  end
35
35
 
36
36
  context 'with subject filter' do
@@ -2,7 +2,6 @@ RSpec.describe Mutant::Matcher::Method::Instance, '#call' do
2
2
  subject { object.call(env) }
3
3
 
4
4
  let(:object) { described_class.new(scope, method) }
5
- let(:env) { test_env }
6
5
  let(:method_name) { :foo }
7
6
  let(:source_path) { MutantSpec::ROOT.join('test_app/lib/test_app.rb') }
8
7
  let(:method) { scope.instance_method(method_name) }
@@ -11,6 +10,14 @@ RSpec.describe Mutant::Matcher::Method::Instance, '#call' do
11
10
  let(:method_arity) { 0 }
12
11
  let(:base) { TestApp::InstanceMethodTests }
13
12
 
13
+ let(:env) do
14
+ instance_double(
15
+ Mutant::Env::Bootstrap,
16
+ config: Mutant::Config::DEFAULT,
17
+ parser: Fixtures::TEST_ENV.parser
18
+ )
19
+ end
20
+
14
21
  def name
15
22
  node.children.fetch(0)
16
23
  end
@@ -2,7 +2,6 @@ RSpec.describe Mutant::Matcher::Method::Singleton, '#call' do
2
2
  subject { object.call(env) }
3
3
 
4
4
  let(:object) { described_class.new(scope, method) }
5
- let(:env) { test_env }
6
5
  let(:method) { scope.method(method_name) }
7
6
  let(:type) { :defs }
8
7
  let(:method_name) { :foo }
@@ -10,6 +9,14 @@ RSpec.describe Mutant::Matcher::Method::Singleton, '#call' do
10
9
  let(:base) { TestApp::SingletonMethodTests }
11
10
  let(:source_path) { MutantSpec::ROOT.join('test_app/lib/test_app.rb') }
12
11
 
12
+ let(:env) do
13
+ instance_double(
14
+ Mutant::Env::Bootstrap,
15
+ config: Mutant::Config::DEFAULT,
16
+ parser: Fixtures::TEST_ENV.parser
17
+ )
18
+ end
19
+
13
20
  def name
14
21
  node.children.fetch(1)
15
22
  end
@@ -1,12 +1,11 @@
1
1
  RSpec.describe Mutant::Matcher::Namespace, '#call' do
2
- let(:object) { described_class.new(parse_expression('TestApp*')) }
3
- let(:env) { instance_double(Mutant::Env) }
4
- let(:raw_scope_a) { double('SingletonA', name: 'TestApp::Literal') }
5
-
6
- let(:raw_scope_b) { double('SingletonB', name: 'TestApp::Foo') }
7
- let(:raw_scope_c) { double('SingletonC', name: 'TestAppOther') }
8
- let(:subject_a) { double('SubjectA') }
9
- let(:subject_b) { double('SubjectB') }
2
+ let(:object) { described_class.new(parse_expression('TestApp*')) }
3
+ let(:env) { instance_double(Mutant::Env) }
4
+ let(:raw_scope_a) { instance_double(Class, name: 'TestApp::Literal') }
5
+ let(:raw_scope_b) { instance_double(Class, name: 'TestApp::Foo') }
6
+ let(:raw_scope_c) { instance_double(Class, name: 'TestAppOther') }
7
+ let(:subject_a) { instance_double(Mutant::Subject) }
8
+ let(:subject_b) { instance_double(Mutant::Subject) }
10
9
 
11
10
  before do
12
11
  [
@@ -1,6 +1,7 @@
1
1
  RSpec.describe Mutant::Matcher::Null, '#call' do
2
- let(:object) { described_class.new }
3
- let(:env) { instance_double(Mutant::Env) }
2
+ let(:object) { described_class.new }
3
+ let(:env) { instance_double(Mutant::Env) }
4
+
4
5
  subject { object.call(env) }
5
6
 
6
7
  it 'returns no subjects' do
@@ -19,9 +19,10 @@ RSpec.describe Mutant::Mutation do
19
19
  let(:test_b) { instance_double(Mutant::Test) }
20
20
 
21
21
  describe '#insert' do
22
- subject { object.insert }
22
+ subject { object.insert(kernel) }
23
23
 
24
- let(:root_node) { s(:foo) }
24
+ let(:root_node) { s(:foo) }
25
+ let(:kernel) { instance_double(Kernel) }
25
26
 
26
27
  before do
27
28
  expect(context).to receive(:root)
@@ -32,10 +33,15 @@ RSpec.describe Mutant::Mutation do
32
33
  .ordered
33
34
  .and_return(mutation_subject)
34
35
 
35
- expect(Mutant::Loader::Eval).to receive(:call)
36
+ expect(Mutant::Loader).to receive(:call)
36
37
  .ordered
37
- .with(root_node, mutation_subject)
38
- .and_return(Mutant::Loader::Eval)
38
+ .with(
39
+ binding: TOPLEVEL_BINDING,
40
+ kernel: kernel,
41
+ node: root_node,
42
+ subject: mutation_subject
43
+ )
44
+ .and_return(Mutant::Loader)
39
45
  end
40
46
 
41
47
  it_should_behave_like 'a command method'
@@ -20,7 +20,7 @@ RSpec.describe Mutant::Mutator::Registry do
20
20
  describe '#register' do
21
21
  let(:object) { described_class.new }
22
22
 
23
- let(:mutator) { double('Mutator') }
23
+ let(:mutator) { instance_double(Mutant::Mutator) }
24
24
 
25
25
  subject { object.register(type, mutator) }
26
26
 
@@ -1,16 +1,16 @@
1
1
  RSpec.describe Mutant::Parallel::Master do
2
2
  let(:message_sequence) { FakeActor::MessageSequence.new }
3
3
  let(:actor_names) { %i[master worker_a worker_b] }
4
- let(:status) { double('Status') }
4
+ let(:status) { instance_double(Mutant::Result::Status) }
5
5
  let(:sink) { FakeSink.new }
6
- let(:processor) { double('Processor') }
6
+ let(:processor) { instance_double(Proc) }
7
7
  let(:worker_a) { actor_env.mailbox(:worker_a).sender }
8
8
  let(:worker_b) { actor_env.mailbox(:worker_b).sender }
9
9
  let(:parent) { actor_env.mailbox(:parent).sender }
10
- let(:job_payload_a) { double('Job Payload A') }
11
- let(:job_payload_b) { double('Job Payload B') }
12
- let(:job_result_payload_a) { double('Job Result Payload A') }
13
- let(:job_result_payload_b) { double('Job Result Payload B') }
10
+ let(:job_payload_a) { instance_double(Object) }
11
+ let(:job_payload_b) { instance_double(Object) }
12
+ let(:job_result_payload_a) { instance_double(Object) }
13
+ let(:job_result_payload_b) { instance_double(Object) }
14
14
  let(:job_a) { Mutant::Parallel::Job.new(index: 0, payload: job_payload_a) }
15
15
  let(:job_b) { Mutant::Parallel::Job.new(index: 1, payload: job_payload_b) }
16
16
  let(:job_result_a) { Mutant::Parallel::JobResult.new(job: job_a, payload: job_result_payload_a) }
@@ -36,11 +36,11 @@ RSpec.describe Mutant::Parallel::Master do
36
36
 
37
37
  let(:config) do
38
38
  Mutant::Parallel::Config.new(
39
- jobs: 1,
40
39
  env: actor_env,
41
- source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b]),
40
+ jobs: 1,
41
+ processor: processor,
42
42
  sink: sink,
43
- processor: processor
43
+ source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b])
44
44
  )
45
45
  end
46
46
 
@@ -1,9 +1,9 @@
1
1
  RSpec.describe Mutant::Parallel::Source::Array do
2
2
  let(:object) { described_class.new(jobs) }
3
3
 
4
- let(:job_a) { double('Job A') }
5
- let(:job_b) { double('Job B') }
6
- let(:job_c) { double('Job B') }
4
+ let(:job_a) { instance_double(Mutant::Parallel::Job) }
5
+ let(:job_b) { instance_double(Mutant::Parallel::Job) }
6
+ let(:job_c) { instance_double(Mutant::Parallel::Job) }
7
7
 
8
8
  let(:jobs) { [job_a, job_b, job_c] }
9
9
 
@@ -4,11 +4,11 @@ RSpec.describe Mutant::Parallel::Worker do
4
4
  end
5
5
 
6
6
  let(:message_sequence) { FakeActor::MessageSequence.new }
7
- let(:processor) { double('Processor') }
7
+ let(:processor) { instance_double(Proc) }
8
8
  let(:mailbox) { actor_env.mailbox(:worker) }
9
9
  let(:parent) { actor_env.mailbox(:parent).sender }
10
- let(:payload) { double('Payload') }
11
- let(:result_payload) { double('Result Payload') }
10
+ let(:payload) { instance_double(Object) }
11
+ let(:result_payload) { instance_double(Object) }
12
12
 
13
13
  let(:attributes) do
14
14
  {
@@ -38,8 +38,8 @@ RSpec.describe Mutant::Parallel::Worker do
38
38
  message_sequence.add(:worker, :stop)
39
39
  end
40
40
 
41
- let(:index) { double('Index') }
42
- let(:test_result) { double('Test Result') }
41
+ let(:index) { instance_double(Fixnum) }
42
+ let(:test_result) { instance_double(Mutant::Result::Test) }
43
43
  let(:job_result) { Mutant::Parallel::JobResult.new(job: job, payload: result_payload) }
44
44
  let(:job) { Mutant::Parallel::Job.new(index: index, payload: payload) }
45
45
 
@@ -2,10 +2,10 @@ RSpec.describe Mutant::Parallel do
2
2
  describe '.async' do
3
3
  subject { described_class.async(config) }
4
4
 
5
- let(:config) { double('Config', env: env) }
6
- let(:env) { double('ENV', new_mailbox: mailbox) }
7
- let(:mailbox) { Mutant::Actor::Mailbox.new }
8
- let(:master) { double('Master') }
5
+ let(:config) { instance_double(Mutant::Parallel::Config, env: env) }
6
+ let(:env) { instance_double(Mutant::Actor::Env, new_mailbox: mailbox) }
7
+ let(:mailbox) { Mutant::Actor::Mailbox.new }
8
+ let(:master) { instance_double(Mutant::Parallel::Master) }
9
9
 
10
10
  before do
11
11
  expect(described_class::Master).to receive(:call).with(config).and_return(master)
@@ -0,0 +1,24 @@
1
+ RSpec.describe Mutant::Parser do
2
+ let(:object) { described_class.new }
3
+
4
+ describe '#call' do
5
+ let(:path) { instance_double(Pathname) }
6
+
7
+ subject { object.call(path) }
8
+
9
+ before do
10
+ expect(path).to receive(:read)
11
+ .with(no_args)
12
+ .and_return(':source')
13
+ end
14
+
15
+ it 'returns parsed source' do
16
+ expect(subject).to eql(s(:sym, :source))
17
+ end
18
+
19
+ it 'is idempotent' do
20
+ source = object.call(path)
21
+ expect(subject).to be(source)
22
+ end
23
+ end
24
+ end
@@ -12,9 +12,9 @@ RSpec.describe Mutant::Reporter::CLI::Printer do
12
12
  end
13
13
  end
14
14
 
15
- let(:reportable) { double('Reportable', success?: success?) }
16
- let(:tty?) { true }
17
- let(:success?) { true }
15
+ let(:reportable) { instance_double(Mutant::Result::Env, success?: success?) }
16
+ let(:tty?) { true }
17
+ let(:success?) { true }
18
18
 
19
19
  context '.call' do
20
20
  let(:class_under_test) do