mutant 0.3.6 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/Changelog.md +13 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +7 -25
  6. data/LICENSE +1 -1
  7. data/README.md +16 -10
  8. data/config/flay.yml +1 -1
  9. data/config/reek.yml +11 -11
  10. data/config/rubocop.yml +1 -1
  11. data/lib/mutant.rb +3 -10
  12. data/lib/mutant/cli.rb +199 -80
  13. data/lib/mutant/config.rb +3 -3
  14. data/lib/mutant/killer.rb +20 -0
  15. data/lib/mutant/matcher/filter.rb +3 -8
  16. data/lib/mutant/matcher/method/instance.rb +1 -1
  17. data/lib/mutant/matcher/namespace.rb +31 -2
  18. data/lib/mutant/matcher/null.rb +26 -0
  19. data/lib/mutant/mutation.rb +0 -1
  20. data/lib/mutant/reporter/cli/printer.rb +29 -0
  21. data/lib/mutant/reporter/cli/printer/config.rb +16 -116
  22. data/lib/mutant/runner/config.rb +47 -1
  23. data/lib/mutant/strategy.rb +39 -1
  24. data/lib/mutant/version.rb +1 -1
  25. data/lib/mutant/walker.rb +51 -0
  26. data/mutant-rspec.gemspec +24 -0
  27. data/mutant.gemspec +7 -3
  28. data/spec/integration/mutant/rspec_spec.rb +11 -6
  29. data/spec/integration/mutant/zombie_spec.rb +2 -2
  30. data/spec/shared/method_matcher_behavior.rb +6 -6
  31. data/spec/spec_helper.rb +2 -2
  32. data/spec/unit/mutant/cli_new_spec.rb +49 -34
  33. data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
  34. data/spec/unit/mutant/loader/eval_spec.rb +2 -2
  35. data/spec/unit/mutant/matcher/chain_spec.rb +1 -1
  36. data/spec/unit/mutant/matcher/methods/instance_spec.rb +1 -1
  37. data/spec/unit/mutant/matcher/methods/singleton_spec.rb +1 -1
  38. data/spec/unit/mutant/matcher/namespace_spec.rb +1 -1
  39. data/spec/unit/mutant/mutation_spec.rb +1 -1
  40. data/spec/unit/mutant/{killer/rspec_spec.rb → rspec/killer_spec.rb} +2 -1
  41. data/spec/unit/mutant/runner/config_spec.rb +36 -21
  42. data/spec/unit/mutant_spec.rb +7 -9
  43. metadata +25 -22
  44. data/lib/mutant/cli/builder.rb +0 -167
  45. data/lib/mutant/killer/rspec.rb +0 -95
  46. data/lib/mutant/predicate.rb +0 -70
  47. data/lib/mutant/predicate/attribute.rb +0 -68
  48. data/lib/mutant/predicate/blacklist.rb +0 -27
  49. data/lib/mutant/predicate/matcher.rb +0 -38
  50. data/lib/mutant/predicate/whitelist.rb +0 -28
  51. data/lib/mutant/strategy/rspec.rb +0 -76
  52. data/spec/unit/mutant/cli/builder/rspec_spec.rb +0 -38
  53. data/spec/unit/mutant/matcher/filter_spec.rb +0 -19
  54. data/spec/unit/mutant/predicate_spec.rb +0 -135
@@ -52,7 +52,7 @@ describe Mutant::Matcher::Methods::Singleton, '#each' do
52
52
 
53
53
  it 'should yield expected subjects' do
54
54
  subject
55
- yields.should eql(subjects)
55
+ expect(yields).to eql(subjects)
56
56
  end
57
57
 
58
58
  it_should_behave_like 'an #each method'
@@ -34,7 +34,7 @@ describe Mutant::Matcher::Namespace, '#each' do
34
34
  pending 'FIX RBX rspec? BUG HERE'
35
35
  else
36
36
  it 'yields the expected values' do
37
- subject.to_a.should eql(object.to_a)
37
+ expect(subject.to_a).to eql(object.to_a)
38
38
  end
39
39
  end
40
40
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutation do
6
6
 
7
- let(:class_under_test) { Class.new(described_class) }
7
+ let(:class_under_test) { Class.new(described_class) { memoize :identification } }
8
8
  let(:object) { class_under_test.new(mutation_subject, Mutant::NodeHelpers::N_NIL) }
9
9
  let(:mutation_subject) { double('Subject', identification: 'subject', source: 'original') }
10
10
  let(:node) { double('Node') }
@@ -1,8 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'mutant-rspec'
4
5
 
5
- describe Mutant::Killer::Rspec, '.new' do
6
+ describe Mutant::Rspec::Killer, '.new' do
6
7
 
7
8
  before do
8
9
  pending 'dactivated'
@@ -5,15 +5,21 @@ require 'spec_helper'
5
5
  describe Mutant::Runner::Config do
6
6
 
7
7
  let(:config) do
8
- double(
9
- 'Config',
10
- class: Mutant::Config,
11
- subjects: [subject_a, subject_b],
12
- strategy: strategy,
13
- reporter: reporter
8
+ Mutant::Config.new(
9
+ matcher: [subject_a, subject_b],
10
+ cache: Mutant::Cache.new,
11
+ debug: false,
12
+ strategy: strategy,
13
+ reporter: reporter,
14
+ fail_fast: fail_fast,
15
+ expected_coverage: expected_coverage,
16
+ zombie: false
14
17
  )
15
18
  end
16
19
 
20
+ let(:fail_fast) { false }
21
+ let(:expected_coverage) { 100.0 }
22
+
17
23
  before do
18
24
  reporter.stub(report: reporter)
19
25
  strategy.stub(:setup)
@@ -59,30 +65,39 @@ describe Mutant::Runner::Config do
59
65
 
60
66
  let(:object) { described_class.new(config) }
61
67
 
68
+ let(:mutation_a) do
69
+ double('Mutation A', success?: false)
70
+ end
71
+
72
+ let(:mutation_b) do
73
+ double('Mutation B', success?: true)
74
+ end
75
+
62
76
  let(:runner_a) do
63
- double('Runner A', stop?: stop_a, success?: success_a)
77
+ double('Runner A', stop?: false, success?: false, mutations: [mutation_a])
64
78
  end
65
79
 
66
80
  let(:runner_b) do
67
- double('Runner B', stop?: stop_b, success?: success_b)
81
+ double('Runner B', stop?: false, success?: true, mutations: [mutation_b])
68
82
  end
69
83
 
70
- context 'without failed subjects' do
71
- let(:stop_a) { false }
72
- let(:stop_b) { false }
73
- let(:success_a) { true }
74
- let(:success_b) { true }
84
+ context 'without fail fast' do
75
85
 
76
- it { should be(true) }
77
- end
86
+ context 'when expected coverage equals actual coverage' do
87
+ let(:expected_coverage) { 50.0 }
88
+ it { should be(true) }
89
+ end
90
+
91
+ context 'when expected coverage closely equals actual coverage' do
92
+ let(:expected_coverage) { 50.01 }
93
+ it { should be(true) }
94
+ end
78
95
 
79
- context 'with failing subjects' do
80
- let(:stop_a) { false }
81
- let(:stop_b) { false }
82
- let(:success_a) { false }
83
- let(:success_b) { true }
96
+ context 'when expected coverage does not equal actual coverage' do
97
+ let(:expected_coverage) { 51.00 }
98
+ it { should be(false) }
99
+ end
84
100
 
85
- it { should be(false) }
86
101
  end
87
102
  end
88
103
  end
@@ -8,9 +8,7 @@ describe Mutant do
8
8
 
9
9
  subject { object.singleton_subclass_instance(name, superclass, &block) }
10
10
 
11
- before do
12
- subject
13
- end
11
+ before { subject }
14
12
 
15
13
  let(:name) { 'Test' }
16
14
  let(:block) { proc { def foo; end } }
@@ -22,22 +20,22 @@ describe Mutant do
22
20
 
23
21
  it 'sets expected name' do
24
22
  name = generated.class.name
25
- name.should eql("::#{self.name}")
26
- name.should be_frozen
23
+ expect(name).to eql("::#{self.name}")
24
+ expect(name).to be_frozen
27
25
  end
28
26
 
29
27
  it 'stores instance of subclass' do
30
- generated.should be_kind_of(superclass)
28
+ expect(generated).to be_kind_of(superclass)
31
29
  end
32
30
 
33
31
  it 'evaluates the context of proc inside subclass' do
34
- generated.should respond_to(:foo)
32
+ expect(generated).to respond_to(:foo)
35
33
  end
36
34
 
37
35
  it 'generates nice #inspect' do
38
36
  inspect = generated.inspect
39
- inspect.should eql("::#{self.name}")
40
- inspect.should be_frozen
37
+ expect(inspect).to eql("::#{self.name}")
38
+ expect(inspect).to be_frozen
41
39
  end
42
40
  end
43
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: morpher
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: procto
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - ~>
74
88
  - !ruby/object:Gem::Version
75
- version: 0.9.0
89
+ version: 0.11.0
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ~>
81
95
  - !ruby/object:Gem::Version
82
- version: 0.9.0
96
+ version: 0.11.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: descendants_tracker
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
103
- version: 0.1.0
117
+ version: 0.2.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ~>
109
123
  - !ruby/object:Gem::Version
110
- version: 0.1.0
124
+ version: 0.2.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: equalizer
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -235,7 +249,6 @@ files:
235
249
  - lib/mutant.rb
236
250
  - lib/mutant/cache.rb
237
251
  - lib/mutant/cli.rb
238
- - lib/mutant/cli/builder.rb
239
252
  - lib/mutant/cli/classifier.rb
240
253
  - lib/mutant/cli/classifier/method.rb
241
254
  - lib/mutant/cli/classifier/namespace.rb
@@ -248,7 +261,6 @@ files:
248
261
  - lib/mutant/killer.rb
249
262
  - lib/mutant/killer/forked.rb
250
263
  - lib/mutant/killer/forking.rb
251
- - lib/mutant/killer/rspec.rb
252
264
  - lib/mutant/killer/static.rb
253
265
  - lib/mutant/loader.rb
254
266
  - lib/mutant/matcher.rb
@@ -260,6 +272,7 @@ files:
260
272
  - lib/mutant/matcher/method/singleton.rb
261
273
  - lib/mutant/matcher/methods.rb
262
274
  - lib/mutant/matcher/namespace.rb
275
+ - lib/mutant/matcher/null.rb
263
276
  - lib/mutant/matcher/scope.rb
264
277
  - lib/mutant/mutation.rb
265
278
  - lib/mutant/mutation/evil.rb
@@ -317,11 +330,6 @@ files:
317
330
  - lib/mutant/mutator/util/array.rb
318
331
  - lib/mutant/mutator/util/symbol.rb
319
332
  - lib/mutant/node_helpers.rb
320
- - lib/mutant/predicate.rb
321
- - lib/mutant/predicate/attribute.rb
322
- - lib/mutant/predicate/blacklist.rb
323
- - lib/mutant/predicate/matcher.rb
324
- - lib/mutant/predicate/whitelist.rb
325
333
  - lib/mutant/random.rb
326
334
  - lib/mutant/reporter.rb
327
335
  - lib/mutant/reporter/cli.rb
@@ -337,14 +345,15 @@ files:
337
345
  - lib/mutant/runner/subject.rb
338
346
  - lib/mutant/singleton_methods.rb
339
347
  - lib/mutant/strategy.rb
340
- - lib/mutant/strategy/rspec.rb
341
348
  - lib/mutant/subject.rb
342
349
  - lib/mutant/subject/method.rb
343
350
  - lib/mutant/subject/method/instance.rb
344
351
  - lib/mutant/subject/method/singleton.rb
345
352
  - lib/mutant/version.rb
353
+ - lib/mutant/walker.rb
346
354
  - lib/mutant/zombifier.rb
347
355
  - lib/parser-node-list.rb
356
+ - mutant-rspec.gemspec
348
357
  - mutant.gemspec
349
358
  - spec/integration/mutant/rspec_spec.rb
350
359
  - spec/integration/mutant/test_mutator_handles_types_spec.rb
@@ -357,7 +366,6 @@ files:
357
366
  - spec/support/ice_nine_config.rb
358
367
  - spec/support/rspec.rb
359
368
  - spec/support/test_app.rb
360
- - spec/unit/mutant/cli/builder/rspec_spec.rb
361
369
  - spec/unit/mutant/cli/classifier/method_spec.rb
362
370
  - spec/unit/mutant/cli/classifier/namespace/flat_spec.rb
363
371
  - spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
@@ -369,11 +377,9 @@ files:
369
377
  - spec/unit/mutant/context/scope/unqualified_name_spec.rb
370
378
  - spec/unit/mutant/differ/diff_spec.rb
371
379
  - spec/unit/mutant/differ_spec.rb
372
- - spec/unit/mutant/killer/rspec_spec.rb
373
380
  - spec/unit/mutant/killer/success_predicate_spec.rb
374
381
  - spec/unit/mutant/loader/eval_spec.rb
375
382
  - spec/unit/mutant/matcher/chain_spec.rb
376
- - spec/unit/mutant/matcher/filter_spec.rb
377
383
  - spec/unit/mutant/matcher/method/instance_spec.rb
378
384
  - spec/unit/mutant/matcher/method/singleton_spec.rb
379
385
  - spec/unit/mutant/matcher/methods/instance_spec.rb
@@ -424,7 +430,7 @@ files:
424
430
  - spec/unit/mutant/mutator/node/super_spec.rb
425
431
  - spec/unit/mutant/mutator/node/yield_spec.rb
426
432
  - spec/unit/mutant/mutator_spec.rb
427
- - spec/unit/mutant/predicate_spec.rb
433
+ - spec/unit/mutant/rspec/killer_spec.rb
428
434
  - spec/unit/mutant/runner/config_spec.rb
429
435
  - spec/unit/mutant/runner/mutation/killer_spec.rb
430
436
  - spec/unit/mutant/runner/subject_spec.rb
@@ -477,7 +483,6 @@ test_files:
477
483
  - spec/integration/mutant/rspec_spec.rb
478
484
  - spec/integration/mutant/test_mutator_handles_types_spec.rb
479
485
  - spec/integration/mutant/zombie_spec.rb
480
- - spec/unit/mutant/cli/builder/rspec_spec.rb
481
486
  - spec/unit/mutant/cli/classifier/method_spec.rb
482
487
  - spec/unit/mutant/cli/classifier/namespace/flat_spec.rb
483
488
  - spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb
@@ -489,11 +494,9 @@ test_files:
489
494
  - spec/unit/mutant/context/scope/unqualified_name_spec.rb
490
495
  - spec/unit/mutant/differ/diff_spec.rb
491
496
  - spec/unit/mutant/differ_spec.rb
492
- - spec/unit/mutant/killer/rspec_spec.rb
493
497
  - spec/unit/mutant/killer/success_predicate_spec.rb
494
498
  - spec/unit/mutant/loader/eval_spec.rb
495
499
  - spec/unit/mutant/matcher/chain_spec.rb
496
- - spec/unit/mutant/matcher/filter_spec.rb
497
500
  - spec/unit/mutant/matcher/method/instance_spec.rb
498
501
  - spec/unit/mutant/matcher/method/singleton_spec.rb
499
502
  - spec/unit/mutant/matcher/methods/instance_spec.rb
@@ -544,7 +547,7 @@ test_files:
544
547
  - spec/unit/mutant/mutator/node/super_spec.rb
545
548
  - spec/unit/mutant/mutator/node/yield_spec.rb
546
549
  - spec/unit/mutant/mutator_spec.rb
547
- - spec/unit/mutant/predicate_spec.rb
550
+ - spec/unit/mutant/rspec/killer_spec.rb
548
551
  - spec/unit/mutant/runner/config_spec.rb
549
552
  - spec/unit/mutant/runner/mutation/killer_spec.rb
550
553
  - spec/unit/mutant/runner/subject_spec.rb
@@ -1,167 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Mutant
4
- class CLI
5
- # Abstract base class for strategy builders
6
- class Builder
7
- include AbstractType
8
-
9
- # Return cache
10
- #
11
- # @return [Cache]
12
- #
13
- # @api private
14
- #
15
- attr_reader :cache
16
- private :cache
17
-
18
- # Return parser
19
- #
20
- # @return [OptionParser]
21
- #
22
- # @api private
23
- #
24
- attr_reader :parser
25
- private :parser
26
-
27
- # Initialize builder
28
- #
29
- # @param [OptionParser] parser
30
- #
31
- # @api privateo
32
- #
33
- def initialize(cache, parser)
34
- @cache, @parser = cache, parser
35
- add_options
36
- end
37
-
38
- # Add cli options
39
- #
40
- # @param [OptionParser]
41
- #
42
- # @return [self]
43
- #
44
- # @api private
45
- #
46
- abstract_method :add_options
47
-
48
- # Return build output
49
- #
50
- # @return [Object]
51
- #
52
- # @api private
53
- #
54
- abstract_method :output
55
-
56
- # Rspec strategy builder
57
- class Rspec < self
58
-
59
- # Initialize object
60
- #
61
- # @return [undefined]
62
- #
63
- # @api private
64
- #
65
- def initialize(*)
66
- @level = 0
67
- @rspec = false
68
- super
69
- end
70
-
71
- # Return strategy
72
- #
73
- # @return [Strategy::Rspec]
74
- #
75
- # @api private
76
- #
77
- def output
78
- unless @rspec
79
- raise Error, 'No strategy given'
80
- end
81
-
82
- Strategy::Rspec.new(@level)
83
- end
84
-
85
- private
86
-
87
- # Add cli options
88
- #
89
- # @param [OptionParser] parser
90
- #
91
- # @return [undefined]
92
- #
93
- # @api private
94
- #
95
- def add_options
96
- parser.on('--rspec', 'kills mutations with rspec') do
97
- @rspec = true
98
- end
99
-
100
- parser.on('--rspec-level LEVEL', 'set rspec expansion level') do |level|
101
- @level = level.to_i
102
- end
103
- end
104
-
105
- end # Rspec
106
-
107
- # Abstract predicate builder
108
- class Predicate < self
109
-
110
- # Bubject predicate builder
111
- class Subject < self
112
-
113
- # Initialize object
114
- #
115
- # @api private
116
- #
117
- # @return [undefined]
118
- #
119
- def initialize(*)
120
- super
121
- @predicates = []
122
- end
123
-
124
- # Return predicate
125
- #
126
- # @api private
127
- #
128
- def output
129
- if @predicates.empty?
130
- Mutant::Predicate::CONTRADICTION
131
- else
132
- Mutant::Predicate::Whitelist.new(@predicates)
133
- end
134
- end
135
-
136
- private
137
-
138
- # Add cli options
139
- #
140
- # @return [undefined]
141
- #
142
- # @api private
143
- #
144
- def add_options
145
- parser.on('--ignore-subject MATCHER', 'ignores subjects that matches MATCHER') do |pattern|
146
- add_pattern(pattern)
147
- end
148
- end
149
-
150
- # Add matcher to predicates
151
- #
152
- # @param [String] pattern
153
- #
154
- # @api private
155
- #
156
- def add_pattern(pattern)
157
- matcher = Classifier.run(@cache, pattern)
158
- @predicates << Mutant::Predicate::Matcher.new(matcher)
159
- end
160
-
161
- end
162
-
163
- end # Predicate
164
-
165
- end # Builder
166
- end # CLI
167
- end # Mutant