mutant 0.3.0.beta4 → 0.3.0.beta5

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +4 -4
  4. data/TODO +0 -9
  5. data/bin/mutant +2 -2
  6. data/bin/zombie +2 -2
  7. data/config/flay.yml +1 -1
  8. data/config/reek.yml +1 -2
  9. data/lib/mutant.rb +3 -0
  10. data/lib/mutant/cache.rb +30 -0
  11. data/lib/mutant/cli.rb +4 -1
  12. data/lib/mutant/cli/classifier.rb +17 -34
  13. data/lib/mutant/cli/classifier/method.rb +2 -2
  14. data/lib/mutant/cli/classifier/namespace.rb +1 -1
  15. data/lib/mutant/config.rb +1 -1
  16. data/lib/mutant/constants.rb +2 -0
  17. data/lib/mutant/differ.rb +3 -3
  18. data/lib/mutant/loader.rb +1 -1
  19. data/lib/mutant/matcher.rb +3 -3
  20. data/lib/mutant/matcher/method.rb +6 -73
  21. data/lib/mutant/matcher/method/finder.rb +72 -0
  22. data/lib/mutant/matcher/method/singleton.rb +2 -2
  23. data/lib/mutant/matcher/methods.rb +2 -2
  24. data/lib/mutant/matcher/namespace.rb +2 -2
  25. data/lib/mutant/matcher/scope.rb +2 -2
  26. data/lib/mutant/mutation.rb +4 -1
  27. data/lib/mutant/mutator/node.rb +1 -1
  28. data/lib/mutant/zombifier.rb +255 -0
  29. data/mutant.gemspec +3 -3
  30. data/spec/integration/mutant/zombie_spec.rb +3 -3
  31. data/spec/shared/method_matcher_behavior.rb +3 -4
  32. data/spec/spec_helper.rb +4 -0
  33. data/spec/unit/mutant/cli/class_methods/new_spec.rb +6 -6
  34. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +9 -8
  35. data/spec/unit/mutant/context/scope/root_spec.rb +3 -3
  36. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +7 -5
  37. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +8 -7
  38. data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +5 -4
  39. data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +5 -4
  40. data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +5 -4
  41. data/spec/unit/mutant/matcher/namespace/each_spec.rb +5 -3
  42. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +1 -1
  43. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +2 -2
  44. data/spec/unit/mutant/subject/context_spec.rb +2 -2
  45. data/spec/unit/mutant/subject/each_spec.rb +1 -1
  46. data/spec/unit/mutant/subject/node_spec.rb +2 -2
  47. metadata +9 -8
  48. data/spec/support/zombie.rb +0 -174
@@ -1,11 +1,10 @@
1
1
  shared_examples_for 'a method matcher' do
2
- before do
3
- subject
4
- end
2
+
3
+ before { subject }
5
4
 
6
5
  let(:node) { mutation_subject.node }
7
6
  let(:context) { mutation_subject.context }
8
- let(:mutation_subject) { yields.first }
7
+ let(:mutation_subject) { yields.first }
9
8
 
10
9
  it 'should return one subject' do
11
10
  yields.size.should be(1)
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,10 @@ $: << File.join(TestApp.root,'lib')
6
6
 
7
7
  require 'test_app'
8
8
 
9
+ module Fixtures
10
+ AST_CACHE = Mutant::Cache.new
11
+ end
12
+
9
13
  module ParserHelper
10
14
  def generate(node)
11
15
  Unparser.unparse(node)
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  shared_examples_for 'a cli parser' do
10
10
  subject { cli.config }
11
+
11
12
  its(:filter) { should eql(expected_filter) }
12
13
  its(:strategy) { should eql(expected_strategy) }
13
14
  its(:reporter) { should eql(expected_reporter) }
@@ -15,9 +16,8 @@ shared_examples_for 'a cli parser' do
15
16
  end
16
17
 
17
18
  describe Mutant::CLI, '.new' do
18
-
19
19
  let(:object) { described_class }
20
- let(:time) { Time.now }
20
+ let(:time) { Time.now }
21
21
 
22
22
  before do
23
23
  Time.stub(:now => time)
@@ -70,15 +70,15 @@ describe Mutant::CLI, '.new' do
70
70
  end
71
71
 
72
72
  context 'with explicit method matcher' do
73
- let(:arguments) { %w(--rspec-unit TestApp::Literal#float) }
74
- let(:expected_matcher) { Mutant::CLI::Classifier::Method.new('TestApp::Literal#float') }
73
+ let(:arguments) { %w(--rspec-unit TestApp::Literal#float) }
74
+ let(:expected_matcher) { Mutant::CLI::Classifier::Method.new(Mutant::Cache.new, 'TestApp::Literal#float') }
75
75
 
76
76
  it_should_behave_like 'a cli parser'
77
77
  end
78
78
 
79
79
  context 'with namespace matcher' do
80
80
  let(:arguments) { %w(--rspec-unit ::TestApp*) }
81
- let(:expected_matcher) { Mutant::CLI::Classifier::Namespace::Recursive.new('::TestApp*') }
81
+ let(:expected_matcher) { Mutant::CLI::Classifier::Namespace::Recursive.new(Mutant::Cache.new, '::TestApp*') }
82
82
 
83
83
  it_should_behave_like 'a cli parser'
84
84
  end
@@ -93,7 +93,7 @@ describe Mutant::CLI, '.new' do
93
93
  ]
94
94
  end
95
95
 
96
- let(:expected_matcher) { Mutant::CLI::Classifier::Method.new('TestApp::Literal#float') }
96
+ let(:expected_matcher) { Mutant::CLI::Classifier::Method.new(Mutant::Cache.new, 'TestApp::Literal#float') }
97
97
  let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters) }
98
98
 
99
99
  it_should_behave_like 'a cli parser'
@@ -1,35 +1,36 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::CLI::Classifier, '.build' do
4
- subject { described_class.build(input) }
4
+ subject { described_class.build(cache, input) }
5
+
6
+ let(:cache) { mock('Cache') }
5
7
 
6
8
  this_spec = 'Mutant::CLI::Classifier.build'
7
9
 
8
10
  shared_examples_for this_spec do
9
11
  it 'shoud return expected instance' do
10
- should eql(expected_class.new(expected_class::REGEXP.match(input)))
12
+ should eql(expected_class.new(cache, expected_class::REGEXP.match(input)))
11
13
  end
14
+
15
+ let(:expected_class) { Mutant::CLI::Classifier::Method }
12
16
  end
13
17
 
14
18
  context 'with explicit toplevel scope' do
15
19
 
16
- let(:input) { '::TestApp::Literal#string' }
17
- let(:expected_class) { Mutant::CLI::Classifier::Method }
20
+ let(:input) { '::TestApp::Literal#string' }
18
21
 
19
22
  it_should_behave_like this_spec
20
23
  end
21
24
 
22
25
  context 'with instance method notation' do
23
26
 
24
- let(:input) { 'TestApp::Literal#string' }
25
- let(:expected_class) { Mutant::CLI::Classifier::Method }
27
+ let(:input) { 'TestApp::Literal#string' }
26
28
 
27
29
  it_should_behave_like this_spec
28
30
  end
29
31
 
30
32
  context 'with singleton method notation' do
31
- let(:input) { 'TestApp::Literal.string' }
32
- let(:expected_class) { Mutant::CLI::Classifier::Method }
33
+ let(:input) { 'TestApp::Literal.string' }
33
34
 
34
35
  it_should_behave_like this_spec
35
36
  end
@@ -4,11 +4,11 @@ describe Mutant::Context::Scope, '#root' do
4
4
  subject { object.root(node) }
5
5
 
6
6
  let(:object) { described_class.new(TestApp::Literal, path) }
7
- let(:path) { mock('Path') }
8
- let(:node) { parse(':node') }
7
+ let(:path) { mock('Path') }
8
+ let(:node) { parse(':node') }
9
9
 
10
10
  let(:scope) { subject.body }
11
- let(:scope_body) { scope.body }
11
+ let(:scope_body) { scope.body }
12
12
 
13
13
  let(:expected_source) do
14
14
  generate(parse(<<-RUBY))
@@ -5,9 +5,9 @@ describe Mutant::Killer::Rspec, '.new' do
5
5
  subject { object.new(strategy, mutation) }
6
6
 
7
7
  let(:strategy) { mock('Strategy', :spec_files => ['foo'], :error_stream => $stderr, :output_stream => $stdout) }
8
- let(:context) { mock('Context') }
9
- let(:mutation) { mock('Mutation', :subject => mutation_subject) }
10
- let(:mutation_subject) { mock('Mutation Subject') }
8
+ let(:context) { mock('Context') }
9
+ let(:mutation) { mock('Mutation', :subject => mutation_subject) }
10
+ let(:mutation_subject) { mock('Mutation Subject') }
11
11
 
12
12
  let(:object) { described_class }
13
13
 
@@ -20,14 +20,16 @@ describe Mutant::Killer::Rspec, '.new' do
20
20
  context 'when run exits zero' do
21
21
  let(:exit_status) { 0 }
22
22
 
23
- its(:killed?) { should be(false) }
23
+ its(:killed?) { should be(false) }
24
+
24
25
  it { should be_a(described_class) }
25
26
  end
26
27
 
27
28
  context 'when run exits nonzero' do
28
29
  let(:exit_status) { 1 }
29
30
 
30
- its(:killed?) { should be(true) }
31
+ its(:killed?) { should be(true) }
32
+
31
33
  it { should be_a(described_class) }
32
34
  end
33
35
  end
@@ -1,8 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::Matcher::Method::Instance, '#each' do
4
- let(:object) { described_class.new(scope, method) }
5
- let(:method) { scope.instance_method(method_name) }
4
+ let(:cache) { Fixtures::AST_CACHE }
5
+ let(:object) { described_class.new(cache, scope, method) }
6
+ let(:method) { scope.instance_method(method_name) }
6
7
 
7
8
  let(:yields) { [] }
8
9
 
@@ -69,7 +70,7 @@ describe Mutant::Matcher::Method::Instance, '#each' do
69
70
  def self.bar; end; def bar(arg); end
70
71
  end
71
72
 
72
- let(:method_line) { 2 }
73
+ let(:method_line) { 2 }
73
74
  let(:method_arity) { 1 }
74
75
 
75
76
  it_should_behave_like 'a method matcher'
@@ -86,8 +87,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
86
87
  end
87
88
  end
88
89
 
89
- let(:method_line) { 3 }
90
- let(:method_name) { :baz }
90
+ let(:method_line) { 3 }
91
+ let(:method_name) { :baz }
91
92
  let(:scope) { self.class::Foo::Bar }
92
93
 
93
94
  it_should_behave_like 'a method matcher'
@@ -101,8 +102,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
101
102
  end
102
103
  end
103
104
 
104
- let(:method_line) { 3 }
105
- let(:method_name) { :baz }
105
+ let(:method_line) { 3 }
106
+ let(:method_name) { :baz }
106
107
  let(:scope) { self.class::Foo::Bar }
107
108
 
108
109
  it_should_behave_like 'a method matcher'
@@ -1,8 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::Matcher::Method::Singleton, '#each' do
4
- let(:object) { described_class.new(scope, method) }
5
- let(:method) { scope.method(method_name) }
4
+ let(:object) { described_class.new(cache, scope, method) }
5
+ let(:method) { scope.method(method_name) }
6
+ let(:cache) { Fixtures::AST_CACHE }
6
7
 
7
8
  let(:yields) { [] }
8
9
 
@@ -63,8 +64,8 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
63
64
  def Foo.bar; end
64
65
  end
65
66
 
66
- let(:method_name) { :bar }
67
- let(:method_line) { 3 }
67
+ let(:method_name) { :bar }
68
+ let(:method_line) { 3 }
68
69
  let(:scope) { self.class::Namespace::Foo }
69
70
 
70
71
  it_should_behave_like 'a method matcher'
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::Matcher::Methods::Instance, '#each' do
4
- let(:object) { described_class.new(Foo) }
4
+ let(:object) { described_class.new(cache, Foo) }
5
+ let(:cache) { Mutant::Cache.new }
5
6
 
6
7
  subject { object.each { |matcher| yields << matcher } }
7
8
 
@@ -45,9 +46,9 @@ describe Mutant::Matcher::Methods::Instance, '#each' do
45
46
 
46
47
  before do
47
48
  matcher = Mutant::Matcher::Method::Instance
48
- matcher.stub(:new).with(Foo, Foo.instance_method(:method_a)).and_return([subject_a])
49
- matcher.stub(:new).with(Foo, Foo.instance_method(:method_b)).and_return([subject_b])
50
- matcher.stub(:new).with(Foo, Foo.instance_method(:method_c)).and_return([subject_c])
49
+ matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_a)).and_return([subject_a])
50
+ matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_b)).and_return([subject_b])
51
+ matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_c)).and_return([subject_c])
51
52
  end
52
53
 
53
54
  it 'should yield expected subjects' do
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::Matcher::Methods::Singleton, '#each' do
4
- let(:object) { described_class.new(Foo) }
4
+ let(:object) { described_class.new(cache, Foo) }
5
+ let(:cache) { Mutant::Cache.new }
5
6
 
6
7
  subject { object.each { |matcher| yields << matcher } }
7
8
 
@@ -39,9 +40,9 @@ describe Mutant::Matcher::Methods::Singleton, '#each' do
39
40
 
40
41
  before do
41
42
  matcher = Mutant::Matcher::Method::Singleton
42
- matcher.stub(:new).with(Foo, Foo.method(:method_a)).and_return([subject_a])
43
- matcher.stub(:new).with(Foo, Foo.method(:method_b)).and_return([subject_b])
44
- matcher.stub(:new).with(Foo, Foo.method(:method_c)).and_return([subject_c])
43
+ matcher.stub(:new).with(cache, Foo, Foo.method(:method_a)).and_return([subject_a])
44
+ matcher.stub(:new).with(cache, Foo, Foo.method(:method_b)).and_return([subject_b])
45
+ matcher.stub(:new).with(cache, Foo, Foo.method(:method_c)).and_return([subject_c])
45
46
  end
46
47
 
47
48
  it 'should yield expected subjects' do
@@ -4,7 +4,9 @@ describe Mutant::Matcher::Namespace, '#each' do
4
4
  subject { object.each { |item| yields << item } }
5
5
 
6
6
  let(:yields) { [] }
7
- let(:object) { described_class.new(TestApp::Literal) }
7
+ let(:object) { described_class.new(cache, TestApp::Literal) }
8
+
9
+ let(:cache) { Mutant::Cache.new }
8
10
 
9
11
  let(:singleton_a) { mock('SingletonA', :name => 'TestApp::Literal') }
10
12
  let(:singleton_b) { mock('SingletonB', :name => 'TestApp::Foo') }
@@ -12,8 +14,8 @@ describe Mutant::Matcher::Namespace, '#each' do
12
14
  let(:subject_b) { mock('SubjectB') }
13
15
 
14
16
  before do
15
- Mutant::Matcher::Methods::Singleton.stub(:each).with(singleton_a).and_yield(subject_a)
16
- Mutant::Matcher::Methods::Instance.stub(:each).with(singleton_a).and_yield(subject_b)
17
+ Mutant::Matcher::Methods::Singleton.stub(:each).with(cache, singleton_a).and_yield(subject_a)
18
+ Mutant::Matcher::Methods::Instance.stub(:each).with(cache, singleton_a).and_yield(subject_b)
17
19
  ObjectSpace.stub(:each_object => [singleton_a, singleton_b])
18
20
  end
19
21
 
@@ -26,7 +26,7 @@ describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Instance, '#spec_files' d
26
26
  end
27
27
 
28
28
  context 'with public method' do
29
- let(:is_public) { true }
29
+ let(:is_public) { true }
30
30
  let(:expected_glob_expression) { 'spec/unit/foo/expanded_name_spec.rb' }
31
31
 
32
32
  it_should_behave_like this_example_group
@@ -27,14 +27,14 @@ describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton, '#spec_files'
27
27
  end
28
28
 
29
29
  context 'with public method' do
30
- let(:is_public) { true }
30
+ let(:is_public) { true }
31
31
  let(:expected_glob_expression) { 'spec/unit/foo/class_methods/expanded_name_spec.rb' }
32
32
 
33
33
  it_should_behave_like this_example_group
34
34
  end
35
35
 
36
36
  context 'with nonpublic method' do
37
- let(:is_public) { false }
37
+ let(:is_public) { false }
38
38
  let(:expected_glob_expression) { 'spec/unit/foo/class_methods/*_spec.rb' }
39
39
 
40
40
  it_should_behave_like this_example_group
@@ -8,8 +8,8 @@ describe Mutant::Subject, '#context' do
8
8
  end
9
9
 
10
10
  let(:object) { class_under_test.new(context, node) }
11
- let(:node) { mock('Node') }
12
- let(:context) { mock('Context') }
11
+ let(:node) { mock('Node') }
12
+ let(:context) { mock('Context') }
13
13
 
14
14
  it { should be(context) }
15
15
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Mutant::Subject, '#each' do
4
- subject { object.each { |item| yields << item } }
4
+ subject { object.each { |item| yields << item } }
5
5
 
6
6
  let(:class_under_test) do
7
7
  Class.new(described_class)
@@ -8,8 +8,8 @@ describe Mutant::Subject, '#node' do
8
8
  end
9
9
 
10
10
  let(:object) { class_under_test.new(context, node) }
11
- let(:node) { mock('Node') }
12
- let(:context) { mock('Context') }
11
+ let(:node) { mock('Node') }
12
+ let(:context) { mock('Context') }
13
13
 
14
14
  it { should be(node) }
15
15
 
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.0.beta4
4
+ version: 0.3.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2013-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.beta7
19
+ version: 2.0.beta9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.beta7
26
+ version: 2.0.beta9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: unparser
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.4
33
+ version: 0.0.6
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.4
40
+ version: 0.0.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ice_nine
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +179,7 @@ files:
179
179
  - config/reek.yml
180
180
  - config/yardstick.yml
181
181
  - lib/mutant.rb
182
+ - lib/mutant/cache.rb
182
183
  - lib/mutant/cli.rb
183
184
  - lib/mutant/cli/classifier.rb
184
185
  - lib/mutant/cli/classifier/method.rb
@@ -200,6 +201,7 @@ files:
200
201
  - lib/mutant/matcher.rb
201
202
  - lib/mutant/matcher/chain.rb
202
203
  - lib/mutant/matcher/method.rb
204
+ - lib/mutant/matcher/method/finder.rb
203
205
  - lib/mutant/matcher/method/instance.rb
204
206
  - lib/mutant/matcher/method/singleton.rb
205
207
  - lib/mutant/matcher/methods.rb
@@ -271,6 +273,7 @@ files:
271
273
  - lib/mutant/subject.rb
272
274
  - lib/mutant/subject/method.rb
273
275
  - lib/mutant/support/method_object.rb
276
+ - lib/mutant/zombifier.rb
274
277
  - mutant.gemspec
275
278
  - spec/integration/mutant/differ_spec.rb
276
279
  - spec/integration/mutant/rspec_killer_spec.rb
@@ -285,7 +288,6 @@ files:
285
288
  - spec/support/ice_nine_config.rb
286
289
  - spec/support/rspec.rb
287
290
  - spec/support/test_app.rb
288
- - spec/support/zombie.rb
289
291
  - spec/unit/mutant/cli/class_methods/new_spec.rb
290
292
  - spec/unit/mutant/cli/class_methods/run_spec.rb
291
293
  - spec/unit/mutant/cli/classifier/class_methods/build_spec.rb
@@ -390,7 +392,6 @@ test_files:
390
392
  - spec/support/ice_nine_config.rb
391
393
  - spec/support/rspec.rb
392
394
  - spec/support/test_app.rb
393
- - spec/support/zombie.rb
394
395
  - spec/unit/mutant/cli/class_methods/new_spec.rb
395
396
  - spec/unit/mutant/cli/class_methods/run_spec.rb
396
397
  - spec/unit/mutant/cli/classifier/class_methods/build_spec.rb