mutant 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -0
  3. data/config/flay.yml +1 -1
  4. data/config/reek.yml +1 -0
  5. data/lib/mutant.rb +10 -3
  6. data/lib/mutant/actor.rb +2 -5
  7. data/lib/mutant/actor/env.rb +1 -3
  8. data/lib/mutant/actor/mailbox.rb +2 -4
  9. data/lib/mutant/actor/receiver.rb +0 -2
  10. data/lib/mutant/actor/sender.rb +0 -1
  11. data/lib/mutant/ast.rb +22 -28
  12. data/lib/mutant/ast/meta.rb +8 -88
  13. data/lib/mutant/ast/named_children.rb +1 -8
  14. data/lib/mutant/ast/sexp.rb +0 -2
  15. data/lib/mutant/cache.rb +1 -3
  16. data/lib/mutant/cli.rb +9 -19
  17. data/lib/mutant/color.rb +0 -3
  18. data/lib/mutant/config.rb +6 -2
  19. data/lib/mutant/context.rb +2 -4
  20. data/lib/mutant/context/scope.rb +10 -16
  21. data/lib/mutant/delegator.rb +0 -3
  22. data/lib/mutant/diff.rb +8 -17
  23. data/lib/mutant/env.rb +3 -5
  24. data/lib/mutant/env/bootstrap.rb +32 -39
  25. data/lib/mutant/expression.rb +14 -132
  26. data/lib/mutant/expression/method.rb +25 -42
  27. data/lib/mutant/expression/methods.rb +17 -29
  28. data/lib/mutant/expression/namespace.rb +33 -28
  29. data/lib/mutant/expression/parser.rb +71 -0
  30. data/lib/mutant/integration.rb +17 -16
  31. data/lib/mutant/isolation.rb +14 -14
  32. data/lib/mutant/loader.rb +2 -4
  33. data/lib/mutant/matcher.rb +1 -11
  34. data/lib/mutant/matcher/chain.rb +0 -1
  35. data/lib/mutant/matcher/compiler.rb +19 -52
  36. data/lib/mutant/matcher/config.rb +65 -5
  37. data/lib/mutant/matcher/filter.rb +11 -1
  38. data/lib/mutant/matcher/method.rb +11 -21
  39. data/lib/mutant/matcher/method/instance.rb +2 -16
  40. data/lib/mutant/matcher/method/singleton.rb +3 -20
  41. data/lib/mutant/matcher/methods.rb +11 -21
  42. data/lib/mutant/matcher/namespace.rb +0 -4
  43. data/lib/mutant/matcher/null.rb +0 -1
  44. data/lib/mutant/matcher/scope.rb +0 -12
  45. data/lib/mutant/meta.rb +0 -1
  46. data/lib/mutant/meta/example.rb +12 -26
  47. data/lib/mutant/meta/example/dsl.rb +1 -8
  48. data/lib/mutant/mutation.rb +6 -14
  49. data/lib/mutant/mutator.rb +2 -14
  50. data/lib/mutant/mutator/node.rb +6 -33
  51. data/lib/mutant/mutator/node/and_asgn.rb +0 -1
  52. data/lib/mutant/mutator/node/argument.rb +0 -5
  53. data/lib/mutant/mutator/node/arguments.rb +1 -7
  54. data/lib/mutant/mutator/node/begin.rb +0 -2
  55. data/lib/mutant/mutator/node/binary.rb +0 -3
  56. data/lib/mutant/mutator/node/block.rb +0 -2
  57. data/lib/mutant/mutator/node/break.rb +0 -1
  58. data/lib/mutant/mutator/node/case.rb +0 -3
  59. data/lib/mutant/mutator/node/conditional_loop.rb +0 -1
  60. data/lib/mutant/mutator/node/const.rb +0 -1
  61. data/lib/mutant/mutator/node/define.rb +0 -1
  62. data/lib/mutant/mutator/node/defined.rb +0 -1
  63. data/lib/mutant/mutator/node/dstr.rb +0 -1
  64. data/lib/mutant/mutator/node/dsym.rb +0 -1
  65. data/lib/mutant/mutator/node/generic.rb +0 -1
  66. data/lib/mutant/mutator/node/if.rb +0 -4
  67. data/lib/mutant/mutator/node/kwbegin.rb +0 -1
  68. data/lib/mutant/mutator/node/literal/array.rb +0 -2
  69. data/lib/mutant/mutator/node/literal/boolean.rb +0 -1
  70. data/lib/mutant/mutator/node/literal/fixnum.rb +2 -5
  71. data/lib/mutant/mutator/node/literal/float.rb +1 -4
  72. data/lib/mutant/mutator/node/literal/hash.rb +0 -3
  73. data/lib/mutant/mutator/node/literal/nil.rb +0 -1
  74. data/lib/mutant/mutator/node/literal/range.rb +1 -5
  75. data/lib/mutant/mutator/node/literal/regex.rb +1 -3
  76. data/lib/mutant/mutator/node/literal/string.rb +0 -1
  77. data/lib/mutant/mutator/node/literal/symbol.rb +0 -1
  78. data/lib/mutant/mutator/node/masgn.rb +0 -1
  79. data/lib/mutant/mutator/node/match_current_line.rb +0 -1
  80. data/lib/mutant/mutator/node/mlhs.rb +0 -1
  81. data/lib/mutant/mutator/node/named_value/access.rb +0 -1
  82. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
  83. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
  84. data/lib/mutant/mutator/node/next.rb +0 -1
  85. data/lib/mutant/mutator/node/noop.rb +0 -1
  86. data/lib/mutant/mutator/node/nthref.rb +0 -1
  87. data/lib/mutant/mutator/node/op_asgn.rb +0 -1
  88. data/lib/mutant/mutator/node/or_asgn.rb +1 -2
  89. data/lib/mutant/mutator/node/resbody.rb +0 -2
  90. data/lib/mutant/mutator/node/rescue.rb +1 -6
  91. data/lib/mutant/mutator/node/return.rb +0 -1
  92. data/lib/mutant/mutator/node/send.rb +16 -17
  93. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -3
  94. data/lib/mutant/mutator/node/send/binary.rb +0 -1
  95. data/lib/mutant/mutator/node/send/index.rb +0 -3
  96. data/lib/mutant/mutator/node/splat.rb +0 -1
  97. data/lib/mutant/mutator/node/super.rb +0 -1
  98. data/lib/mutant/mutator/node/when.rb +2 -7
  99. data/lib/mutant/mutator/node/yield.rb +0 -1
  100. data/lib/mutant/mutator/node/zsuper.rb +0 -1
  101. data/lib/mutant/mutator/registry.rb +1 -4
  102. data/lib/mutant/mutator/util.rb +0 -2
  103. data/lib/mutant/mutator/util/array.rb +0 -3
  104. data/lib/mutant/mutator/util/symbol.rb +0 -1
  105. data/lib/mutant/parallel.rb +3 -9
  106. data/lib/mutant/parallel/master.rb +7 -17
  107. data/lib/mutant/parallel/source.rb +2 -7
  108. data/lib/mutant/parallel/worker.rb +1 -5
  109. data/lib/mutant/reporter.rb +0 -4
  110. data/lib/mutant/reporter/cli.rb +1 -8
  111. data/lib/mutant/reporter/cli/format.rb +7 -18
  112. data/lib/mutant/reporter/cli/printer.rb +2 -12
  113. data/lib/mutant/reporter/cli/printer/config.rb +1 -4
  114. data/lib/mutant/reporter/cli/printer/env_progress.rb +3 -7
  115. data/lib/mutant/reporter/cli/printer/env_result.rb +0 -1
  116. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -2
  117. data/lib/mutant/reporter/cli/printer/mutation_result.rb +3 -11
  118. data/lib/mutant/reporter/cli/printer/status.rb +1 -4
  119. data/lib/mutant/reporter/cli/printer/status_progressive.rb +1 -3
  120. data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -5
  121. data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -1
  122. data/lib/mutant/reporter/cli/printer/test_result.rb +0 -1
  123. data/lib/mutant/reporter/cli/tput.rb +4 -1
  124. data/lib/mutant/reporter/trace.rb +2 -4
  125. data/lib/mutant/repository.rb +88 -0
  126. data/lib/mutant/require_highjack.rb +0 -1
  127. data/lib/mutant/result.rb +25 -48
  128. data/lib/mutant/runner.rb +7 -16
  129. data/lib/mutant/runner/sink.rb +3 -11
  130. data/lib/mutant/selector.rb +1 -2
  131. data/lib/mutant/selector/expression.rb +1 -2
  132. data/lib/mutant/subject.rb +10 -21
  133. data/lib/mutant/subject/method.rb +11 -12
  134. data/lib/mutant/subject/method/instance.rb +1 -5
  135. data/lib/mutant/subject/method/singleton.rb +1 -3
  136. data/lib/mutant/test.rb +1 -2
  137. data/lib/mutant/version.rb +2 -2
  138. data/lib/mutant/warning_filter.rb +2 -7
  139. data/lib/mutant/zombifier.rb +6 -10
  140. data/meta/send.rb +8 -0
  141. data/spec/spec_helper.rb +5 -1
  142. data/spec/support/corpus.rb +5 -9
  143. data/spec/support/rb_bug.rb +0 -1
  144. data/spec/support/rspec.rb +0 -1
  145. data/spec/support/ruby_vm.rb +0 -2
  146. data/spec/unit/mutant/ast/meta/send_spec.rb +42 -0
  147. data/spec/unit/mutant/ast/named_children_spec.rb +51 -0
  148. data/spec/unit/mutant/ast/sexp_spec.rb +36 -0
  149. data/spec/unit/mutant/ast_spec.rb +8 -0
  150. data/spec/unit/mutant/cli_spec.rb +34 -19
  151. data/spec/unit/mutant/context/scope_spec.rb +11 -0
  152. data/spec/unit/mutant/env/boostrap_spec.rb +5 -2
  153. data/spec/unit/mutant/env_spec.rb +14 -15
  154. data/spec/unit/mutant/expression/method_spec.rb +10 -14
  155. data/spec/unit/mutant/expression/methods_spec.rb +24 -11
  156. data/spec/unit/mutant/expression/namespace/flat_spec.rb +5 -6
  157. data/spec/unit/mutant/expression/namespace/recursive_spec.rb +16 -10
  158. data/spec/unit/mutant/expression/parser_spec.rb +67 -0
  159. data/spec/unit/mutant/expression_spec.rb +24 -57
  160. data/spec/unit/mutant/integration/rspec_spec.rb +7 -7
  161. data/spec/unit/mutant/integration_spec.rb +2 -2
  162. data/spec/unit/mutant/isolation_spec.rb +31 -29
  163. data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +2 -2
  164. data/spec/unit/mutant/matcher/compiler_spec.rb +27 -58
  165. data/spec/unit/mutant/matcher/config_spec.rb +45 -0
  166. data/spec/unit/mutant/matcher/filter_spec.rb +12 -5
  167. data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -1
  168. data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -1
  169. data/spec/unit/mutant/matcher/namespace_spec.rb +4 -4
  170. data/spec/unit/mutant/parallel/worker_spec.rb +1 -1
  171. data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +4 -4
  172. data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +7 -7
  173. data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +2 -2
  174. data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +2 -2
  175. data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +12 -12
  176. data/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb +1 -1
  177. data/spec/unit/mutant/reporter/cli_spec.rb +9 -10
  178. data/spec/unit/mutant/repository/diff_spec.rb +80 -0
  179. data/spec/unit/mutant/repository/subject_filter_spec.rb +28 -0
  180. data/spec/unit/mutant/result/env_spec.rb +1 -1
  181. data/spec/unit/mutant/runner_spec.rb +0 -1
  182. data/spec/unit/mutant/selector/expression_spec.rb +14 -14
  183. data/spec/unit/mutant/subject/method/instance_spec.rb +2 -2
  184. data/spec/unit/mutant/subject/method/singleton_spec.rb +2 -2
  185. data/spec/unit/mutant/subject_spec.rb +5 -2
  186. metadata +20 -3
  187. data/spec/support/mutation_verifier.rb +0 -96
@@ -1,10 +1,10 @@
1
1
  require 'mutant/integration/rspec'
2
2
 
3
3
  RSpec.describe Mutant::Integration::Rspec do
4
- let(:object) { described_class.new }
4
+ let(:object) { described_class.new(Mutant::Config::DEFAULT) }
5
5
 
6
- let(:options) { double('options') }
7
- let(:runner) { double('runner') }
6
+ let(:options) { double('options') }
7
+ let(:runner) { double('runner') }
8
8
 
9
9
  let(:example_a) do
10
10
  double(
@@ -97,19 +97,19 @@ RSpec.describe Mutant::Integration::Rspec do
97
97
  [
98
98
  Mutant::Test.new(
99
99
  id: 'rspec:0:example-a-location/example-a-full-description',
100
- expression: Mutant::Expression.parse('*')
100
+ expression: parse_expression('*')
101
101
  ),
102
102
  Mutant::Test.new(
103
103
  id: 'rspec:1:example-c-location/Example::C blah',
104
- expression: Mutant::Expression.parse('Example::C')
104
+ expression: parse_expression('Example::C')
105
105
  ),
106
106
  Mutant::Test.new(
107
107
  id: "rspec:2:example-d-location/Example::D\nblah",
108
- expression: Mutant::Expression.parse('*')
108
+ expression: parse_expression('*')
109
109
  ),
110
110
  Mutant::Test.new(
111
111
  id: 'rspec:3:example-e-location/Example::E',
112
- expression: Mutant::Expression.parse('Foo')
112
+ expression: parse_expression('Foo')
113
113
  )
114
114
  ]
115
115
  end
@@ -4,7 +4,7 @@ RSpec.describe Mutant::Integration do
4
4
  Class.new(described_class)
5
5
  end
6
6
 
7
- let(:object) { class_under_test.new }
7
+ let(:object) { class_under_test.new(Mutant::Config::DEFAULT) }
8
8
 
9
9
  describe '#setup' do
10
10
  subject { object.setup }
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  RSpec.describe Mutant::Integration::Null do
16
16
 
17
- let(:object) { described_class.new }
17
+ let(:object) { described_class.new(Mutant::Config::DEFAULT) }
18
18
 
19
19
  describe '#all_tests' do
20
20
  subject { object.all_tests }
@@ -64,37 +64,39 @@ RSpec.describe Mutant::Isolation::Fork do
64
64
  end
65
65
  end
66
66
 
67
- it 'uses primitives in correct order when fork succeeds' do
68
- reader, writer = double('reader'), double('writer')
69
- expect(IO).to receive(:pipe).ordered.and_return([reader, writer])
70
- expect(reader).to receive(:binmode).and_return(reader).ordered
71
- expect(writer).to receive(:binmode).and_return(writer).ordered
72
- pid = double('PID')
73
- expect(Process).to receive(:fork).ordered.and_yield.and_return(pid)
74
- file = double('file')
75
- expect(File).to receive(:open).ordered.with('/dev/null', 'w').and_yield(file)
76
- expect($stderr).to receive(:reopen).ordered.with(file)
77
- expect(reader).to receive(:close).ordered
78
- expect(writer).to receive(:write).ordered.with(Marshal.dump(:foo))
79
- expect(writer).to receive(:close).ordered
80
- expect(writer).to receive(:close).ordered
81
- expect(reader).to receive(:read).ordered.and_return(Marshal.dump(:foo))
82
- expect(Process).to receive(:waitpid).with(pid)
67
+ context 'uses primitives in correct order' do
68
+ let(:reader) { double('reader') }
69
+ let(:writer) { double('writer') }
83
70
 
84
- expect(object.call { :foo }).to be(:foo)
85
- end
71
+ before do
72
+ expect(IO).to receive(:pipe).with(binmode: true).ordered do |&block|
73
+ block.call([reader, writer])
74
+ end
75
+ end
86
76
 
87
- it 'uses primitives in correct order when fork fails' do
88
- reader, writer = double('reader'), double('writer')
89
- expect(IO).to receive(:pipe).ordered.and_return([reader, writer])
90
- expect(reader).to receive(:binmode).and_return(reader).ordered
91
- expect(writer).to receive(:binmode).and_return(writer).ordered
92
- expect(Process).to receive(:fork).ordered.and_return(nil)
93
- expect(Process).to_not receive(:waitpid)
94
-
95
- expect(writer).to receive(:close).ordered
96
- expect(reader).to receive(:read).ordered.and_return(Marshal.dump(:foo))
97
- expect(object.call).to be(:foo)
77
+ it 'when fork succeeds' do
78
+ pid = double('PID')
79
+ expect(Process).to receive(:fork).ordered.and_yield.and_return(pid)
80
+ file = double('file')
81
+ expect(File).to receive(:open).ordered.with('/dev/null', 'w').and_yield(file)
82
+ expect($stderr).to receive(:reopen).ordered.with(file)
83
+ expect(reader).to receive(:close).ordered
84
+ expect(writer).to receive(:write).ordered.with(Marshal.dump(:foo))
85
+ expect(writer).to receive(:close).ordered
86
+ expect(writer).to receive(:close).ordered
87
+ expect(reader).to receive(:read).ordered.and_return(Marshal.dump(:foo))
88
+ expect(Process).to receive(:waitpid).with(pid)
89
+
90
+ expect(object.call { :foo }).to be(:foo)
91
+ end
92
+
93
+ it 'when fork fails' do
94
+ expect(Process).to receive(:fork).ordered.and_return(nil)
95
+ expect(Process).to_not receive(:waitpid)
96
+ expect(writer).to receive(:close).ordered
97
+ expect(reader).to receive(:read).ordered.and_return(Marshal.dump(:foo))
98
+ expect(object.call).to be(:foo)
99
+ end
98
100
  end
99
101
  end
100
102
  end
@@ -1,7 +1,7 @@
1
1
  RSpec.describe Mutant::Matcher::Compiler::SubjectPrefix do
2
- let(:object) { described_class.new(Mutant::Expression.parse('Foo*')) }
2
+ let(:object) { described_class.new(parse_expression('Foo*')) }
3
3
 
4
- let(:_subject) { double('Subject', expression: Mutant::Expression.parse(subject_expression)) }
4
+ let(:_subject) { double('Subject', expression: parse_expression(subject_expression)) }
5
5
 
6
6
  describe '#call' do
7
7
  subject { object.call(_subject) }
@@ -3,8 +3,8 @@ RSpec.describe Mutant::Matcher::Compiler do
3
3
 
4
4
  let(:env) { Fixtures::TEST_ENV }
5
5
 
6
- let(:expression_a) { Mutant::Expression.parse('Foo*') }
7
- let(:expression_b) { Mutant::Expression.parse('Bar*') }
6
+ let(:expression_a) { parse_expression('Foo*') }
7
+ let(:expression_b) { parse_expression('Bar*') }
8
8
 
9
9
  let(:matcher_a) { expression_a.matcher(env) }
10
10
  let(:matcher_b) { expression_b.matcher(env) }
@@ -14,7 +14,7 @@ RSpec.describe Mutant::Matcher::Compiler do
14
14
  end
15
15
 
16
16
  let(:expected_predicate) do
17
- Morpher.compile(s(:true))
17
+ Morpher.compile(s(:and, s(:negate, s(:or)), s(:and)))
18
18
  end
19
19
 
20
20
  describe '.call' do
@@ -31,78 +31,47 @@ RSpec.describe Mutant::Matcher::Compiler do
31
31
  end
32
32
 
33
33
  context 'on config with match expression' do
34
- context 'and no filter' do
35
- let(:attributes) do
36
- { match_expressions: [expression_a] }
37
- end
38
-
39
- let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
40
-
41
- it { should eql(expected_matcher) }
34
+ let(:expected_predicate) do
35
+ Morpher::Evaluator::Predicate::Boolean::And.new(
36
+ [
37
+ Morpher::Evaluator::Predicate::Negation.new(
38
+ Morpher::Evaluator::Predicate::Boolean::Or.new(ignore_expression_predicates)
39
+ ),
40
+ Morpher::Evaluator::Predicate::Boolean::And.new(subject_filter_predicates)
41
+ ]
42
+ )
42
43
  end
43
44
 
44
- context 'and a subject filter' do
45
- let(:attributes) do
46
- {
47
- match_expressions: [expression_a],
48
- subject_ignores: [expression_b]
49
- }
50
- end
51
-
52
- let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
53
-
54
- let(:expected_predicate) do
55
- Morpher::Evaluator::Predicate::Negation.new(
56
- Morpher::Evaluator::Predicate::Boolean::Or.new([
57
- described_class::SubjectPrefix.new(expression_b)
58
- ])
59
- )
60
- end
45
+ let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
46
+ let(:attributes) { { match_expressions: [expression_a] } }
47
+ let(:ignore_expression_predicates) { [] }
48
+ let(:subject_filter_predicates) { [] }
61
49
 
50
+ context 'and no other constraints' do
62
51
  it { should eql(expected_matcher) }
63
52
  end
64
53
 
65
- context 'and an attribute filter' do
54
+ context 'and ignore expressions' do
66
55
  let(:attributes) do
67
- {
68
- match_expressions: [expression_a],
69
- subject_selects: [[:code, 'foo']]
70
- }
56
+ super().merge(ignore_expressions: [expression_b])
71
57
  end
72
58
 
73
- let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
74
-
75
- let(:expected_predicate) do
76
- Morpher::Evaluator::Predicate::Boolean::Or.new([
77
- Morpher.compile(s(:eql, s(:attribute, :code), s(:static, 'foo')))
78
- ])
59
+ let(:ignore_expression_predicates) do
60
+ [Mutant::Matcher::Compiler::SubjectPrefix.new(expression_b)]
79
61
  end
80
62
 
81
63
  it { should eql(expected_matcher) }
82
64
  end
83
65
 
84
- context 'and subject and attribute filter' do
66
+ context 'and subject filters' do
67
+ let(:filter) { double('filter') }
68
+
85
69
  let(:attributes) do
86
- {
87
- match_expressions: [expression_a],
88
- subject_ignores: [expression_b],
89
- subject_selects: [[:code, 'foo']]
90
- }
70
+ super().merge(subject_filters: [filter])
91
71
  end
92
72
 
93
- let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
94
-
95
- let(:expected_predicate) do
96
- Morpher::Evaluator::Predicate::Boolean::And.new([
97
- Morpher::Evaluator::Predicate::Boolean::Or.new([
98
- Morpher.compile(s(:eql, s(:attribute, :code), s(:static, 'foo')))
99
- ]),
100
- Morpher::Evaluator::Predicate::Negation.new(
101
- Morpher::Evaluator::Predicate::Boolean::Or.new([
102
- described_class::SubjectPrefix.new(expression_b)
103
- ])
104
- )
105
- ])
73
+ let(:subject_filter_predicates) do
74
+ [filter]
106
75
  end
107
76
 
108
77
  it { should eql(expected_matcher) }
@@ -0,0 +1,45 @@
1
+ RSpec.describe Mutant::Matcher::Config do
2
+ describe '#inspect' do
3
+ subject { object.inspect }
4
+
5
+ context 'on default config' do
6
+ let(:object) { described_class::DEFAULT }
7
+
8
+ it { should eql('#<Mutant::Matcher::Config empty>') }
9
+ end
10
+
11
+ context 'with one expression' do
12
+ let(:object) { described_class::DEFAULT.add(:match_expressions, parse_expression('Foo')) }
13
+ it { should eql('#<Mutant::Matcher::Config match_expressions: [Foo]>') }
14
+ end
15
+
16
+ context 'with many expressions' do
17
+ let(:object) do
18
+ described_class::DEFAULT
19
+ .add(:match_expressions, parse_expression('Foo'))
20
+ .add(:match_expressions, parse_expression('Bar'))
21
+ end
22
+
23
+ it { should eql('#<Mutant::Matcher::Config match_expressions: [Foo,Bar]>') }
24
+ end
25
+
26
+ context 'with match and ignore expression' do
27
+ let(:object) do
28
+ described_class::DEFAULT
29
+ .add(:match_expressions, parse_expression('Foo'))
30
+ .add(:ignore_expressions, parse_expression('Bar'))
31
+ end
32
+
33
+ it { should eql('#<Mutant::Matcher::Config match_expressions: [Foo] ignore_expressions: [Bar]>') }
34
+ end
35
+
36
+ context 'with subject filter' do
37
+ let(:object) do
38
+ described_class::DEFAULT
39
+ .add(:subject_filters, 'foo')
40
+ end
41
+
42
+ it { should eql('#<Mutant::Matcher::Config subject_filters: ["foo"]>') }
43
+ end
44
+ end
45
+ end
@@ -1,16 +1,15 @@
1
1
  RSpec.describe Mutant::Matcher::Filter do
2
- let(:object) { described_class.new(matcher, predicate) }
2
+ let(:object) { described_class.new(matcher, predicate) }
3
+ let(:matcher) { [subject_a, subject_b] }
4
+ let(:subject_a) { double('Subject A') }
5
+ let(:subject_b) { double('Subject B') }
3
6
 
4
7
  describe '#each' do
5
8
  let(:yields) { [] }
6
9
  subject { object.each { |entry| yields << entry } }
7
10
 
8
- let(:matcher) { [subject_a, subject_b] }
9
11
  let(:predicate) { ->(node) { node.eql?(subject_a) } }
10
12
 
11
- let(:subject_a) { double('Subject A') }
12
- let(:subject_b) { double('Subject B') }
13
-
14
13
  # it_should_behave_like 'an #each method'
15
14
  context 'with no block' do
16
15
  subject { object.each }
@@ -26,4 +25,12 @@ RSpec.describe Mutant::Matcher::Filter do
26
25
  expect { subject }.to change { yields }.from([]).to([subject_a])
27
26
  end
28
27
  end
28
+
29
+ describe '.build' do
30
+ subject { described_class.build(matcher, &predicate) }
31
+
32
+ let(:predicate) { ->(_subject) { false } }
33
+
34
+ its(:to_a) { should eql([]) }
35
+ end
29
36
  end
@@ -1,4 +1,3 @@
1
- # rubocop:disable ClassAndModuleChildren
2
1
  RSpec.describe Mutant::Matcher::Method::Instance do
3
2
 
4
3
  let(:env) { Fixtures::TEST_ENV }
@@ -1,4 +1,3 @@
1
- # rubocop:disable ClassAndModuleChildren
2
1
  RSpec.describe Mutant::Matcher::Method::Singleton, '#each' do
3
2
  subject { object.each(&yields.method(:<<)) }
4
3
 
@@ -1,7 +1,7 @@
1
1
  RSpec.describe Mutant::Matcher::Namespace do
2
- let(:object) { described_class.new(env, Mutant::Expression.parse('TestApp*')) }
3
- let(:yields) { [] }
4
- let(:env) { double('Env') }
2
+ let(:object) { described_class.new(env, parse_expression('TestApp*')) }
3
+ let(:yields) { [] }
4
+ let(:env) { double('Env') }
5
5
 
6
6
  subject { object.each { |item| yields << item } }
7
7
 
@@ -22,7 +22,7 @@ RSpec.describe Mutant::Matcher::Namespace do
22
22
 
23
23
  allow(env).to receive(:matchable_scopes).and_return(
24
24
  [singleton_a, singleton_b, singleton_c].map do |scope|
25
- Mutant::Matcher::Scope.new(env, scope, Mutant::Expression.parse(scope.name))
25
+ Mutant::Matcher::Scope.new(env, scope, parse_expression(scope.name))
26
26
  end
27
27
  )
28
28
  end
@@ -27,7 +27,7 @@ RSpec.describe Mutant::Parallel::Worker do
27
27
 
28
28
  let(:actor_names) { [:worker] }
29
29
 
30
- context 'when receving :job command' do
30
+ context 'when receiving :job command' do
31
31
 
32
32
  before do
33
33
  expect(processor).to receive(:call).with(payload).and_return(result_payload)
@@ -7,8 +7,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do
7
7
  context 'on default config' do
8
8
  it_reports(<<-REPORT)
9
9
  Mutant configuration:
10
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
11
- Integration: null
10
+ Matcher: #<Mutant::Matcher::Config empty>
11
+ Integration: Mutant::Integration::Null
12
12
  Expect Coverage: 100.00%
13
13
  Jobs: 1
14
14
  Includes: []
@@ -21,8 +21,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do
21
21
 
22
22
  it_reports(<<-REPORT)
23
23
  Mutant configuration:
24
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
25
- Integration: null
24
+ Matcher: #<Mutant::Matcher::Config empty>
25
+ Integration: Mutant::Integration::Null
26
26
  Expect Coverage: 10.00%
27
27
  Jobs: 1
28
28
  Includes: []
@@ -11,8 +11,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
11
11
 
12
12
  it_reports <<-'STR'
13
13
  Mutant configuration:
14
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
15
- Integration: null
14
+ Matcher: #<Mutant::Matcher::Config empty>
15
+ Integration: Mutant::Integration::Null
16
16
  Expect Coverage: 10.00%
17
17
  Jobs: 1
18
18
  Includes: []
@@ -24,7 +24,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
24
24
  Runtime: 4.00s
25
25
  Killtime: 0.00s
26
26
  Overhead: Inf%
27
- Coverage: 0.00%
27
+ Coverage: 100.00%
28
28
  Expected: 10.00%
29
29
  STR
30
30
  end
@@ -32,8 +32,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
32
32
  context 'on full coverage' do
33
33
  it_reports <<-'STR'
34
34
  Mutant configuration:
35
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
36
- Integration: null
35
+ Matcher: #<Mutant::Matcher::Config empty>
36
+ Integration: Mutant::Integration::Null
37
37
  Expect Coverage: 10.00%
38
38
  Jobs: 1
39
39
  Includes: []
@@ -55,8 +55,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
55
55
 
56
56
  it_reports <<-'STR'
57
57
  Mutant configuration:
58
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
59
- Integration: null
58
+ Matcher: #<Mutant::Matcher::Config empty>
59
+ Integration: Mutant::Integration::Null
60
60
  Expect Coverage: 10.00%
61
61
  Jobs: 1
62
62
  Includes: []
@@ -15,8 +15,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do
15
15
  +false
16
16
  -----------------------
17
17
  Mutant configuration:
18
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
19
- Integration: null
18
+ Matcher: #<Mutant::Matcher::Config empty>
19
+ Integration: Mutant::Integration::Null
20
20
  Expect Coverage: 100.00%
21
21
  Jobs: 1
22
22
  Includes: []