mutant 0.2.20 → 0.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -11
- data/Changelog.md +93 -38
- data/Gemfile +3 -1
- data/Gemfile.devtools +16 -20
- data/Guardfile +1 -1
- data/README.md +36 -16
- data/Rakefile +21 -2
- data/TODO +11 -7
- data/bin/mutant +4 -0
- data/bin/zombie +4 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/{site.reek → reek.yml} +94 -70
- data/lib/mutant/cli/classifier/method.rb +100 -0
- data/lib/mutant/cli/classifier/namespace.rb +47 -0
- data/lib/mutant/cli/classifier/scope.rb +35 -0
- data/lib/mutant/cli/classifier.rb +141 -0
- data/lib/mutant/cli.rb +115 -162
- data/lib/mutant/color.rb +2 -2
- data/lib/mutant/config.rb +27 -0
- data/lib/mutant/constants.rb +32 -17
- data/lib/mutant/context/scope.rb +33 -51
- data/lib/mutant/context.rb +8 -19
- data/lib/mutant/differ.rb +5 -5
- data/lib/mutant/helper.rb +2 -17
- data/lib/mutant/killer/forked.rb +44 -0
- data/lib/mutant/killer/forking.rb +3 -57
- data/lib/mutant/killer/rspec.rb +16 -20
- data/lib/mutant/killer/static.rb +6 -7
- data/lib/mutant/killer.rb +48 -74
- data/lib/mutant/loader.rb +6 -6
- data/lib/mutant/matcher/chain.rb +4 -25
- data/lib/mutant/matcher/method/instance.rb +14 -24
- data/lib/mutant/matcher/method/singleton.rb +35 -46
- data/lib/mutant/matcher/method.rb +95 -83
- data/lib/mutant/matcher/{scope_methods.rb → methods.rb} +53 -76
- data/lib/mutant/matcher/namespace.rb +71 -0
- data/lib/mutant/matcher/scope.rb +34 -0
- data/lib/mutant/matcher.rb +24 -34
- data/lib/mutant/mutation/evil.rb +35 -0
- data/lib/mutant/mutation/filter/code.rb +7 -28
- data/lib/mutant/mutation/filter/regexp.rb +6 -18
- data/lib/mutant/mutation/filter/whitelist.rb +5 -4
- data/lib/mutant/mutation/filter.rb +10 -9
- data/lib/mutant/mutation/neutral.rb +35 -0
- data/lib/mutant/mutation.rb +21 -61
- data/lib/mutant/mutator/node/argument.rb +88 -0
- data/lib/mutant/mutator/node/arguments.rb +52 -0
- data/lib/mutant/mutator/node/assignment.rb +34 -38
- data/lib/mutant/mutator/node/begin.rb +33 -0
- data/lib/mutant/mutator/node/block.rb +14 -14
- data/lib/mutant/mutator/node/case.rb +59 -0
- data/lib/mutant/mutator/node/define.rb +26 -22
- data/lib/mutant/mutator/node/if.rb +31 -71
- data/lib/mutant/mutator/node/literal/array.rb +25 -9
- data/lib/mutant/mutator/node/literal/boolean.rb +13 -30
- data/lib/mutant/mutator/node/literal/dynamic.rb +6 -5
- data/lib/mutant/mutator/node/literal/fixnum.rb +18 -7
- data/lib/mutant/mutator/node/literal/float.rb +15 -8
- data/lib/mutant/mutator/node/literal/hash.rb +33 -52
- data/lib/mutant/mutator/node/literal/nil.rb +8 -7
- data/lib/mutant/mutator/node/literal/range.rb +25 -50
- data/lib/mutant/mutator/node/literal/regex.rb +15 -23
- data/lib/mutant/mutator/node/literal/string.rb +7 -6
- data/lib/mutant/mutator/node/literal/symbol.rb +7 -6
- data/lib/mutant/mutator/node/literal.rb +4 -46
- data/lib/mutant/mutator/node/mlhs.rb +27 -0
- data/lib/mutant/mutator/node/noop.rb +18 -43
- data/lib/mutant/mutator/node/return.rb +8 -8
- data/lib/mutant/mutator/node/send/binary.rb +31 -0
- data/lib/mutant/mutator/node/send.rb +106 -72
- data/lib/mutant/mutator/node/super.rb +15 -20
- data/lib/mutant/mutator/node/when.rb +32 -7
- data/lib/mutant/mutator/node/while.rb +9 -7
- data/lib/mutant/mutator/node.rb +116 -66
- data/lib/mutant/mutator/registry.rb +14 -11
- data/lib/mutant/mutator/util/array.rb +9 -9
- data/lib/mutant/mutator/util/symbol.rb +6 -20
- data/lib/mutant/mutator/util.rb +6 -3
- data/lib/mutant/mutator.rb +12 -28
- data/lib/mutant/node_helpers.rb +28 -0
- data/lib/mutant/random.rb +3 -2
- data/lib/mutant/reporter/cli/printer/config.rb +174 -0
- data/lib/mutant/reporter/cli/printer/killer.rb +42 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +55 -0
- data/lib/mutant/reporter/cli/printer/subject.rb +147 -0
- data/lib/mutant/reporter/cli/printer.rb +165 -0
- data/lib/mutant/reporter/cli.rb +9 -277
- data/lib/mutant/reporter/null.rb +6 -30
- data/lib/mutant/reporter.rb +6 -73
- data/lib/mutant/runner/config.rb +82 -0
- data/lib/mutant/runner/mutation.rb +58 -0
- data/lib/mutant/runner/subject.rb +81 -0
- data/lib/mutant/runner.rb +42 -92
- data/lib/mutant/singleton_methods.rb +2 -2
- data/lib/mutant/strategy/method_expansion.rb +51 -0
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +142 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +61 -0
- data/lib/mutant/strategy/rspec/dm2.rb +22 -0
- data/lib/mutant/strategy/rspec.rb +20 -22
- data/lib/mutant/strategy/static.rb +18 -0
- data/lib/mutant/strategy.rb +15 -50
- data/lib/mutant/subject/method.rb +100 -0
- data/lib/mutant/subject.rb +18 -49
- data/lib/mutant/support/method_object.rb +4 -2
- data/lib/mutant.rb +40 -35
- data/mutant.gemspec +9 -8
- data/spec/integration/mutant/rspec_killer_spec.rb +3 -3
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +9 -0
- data/spec/integration/mutant/zombie_spec.rb +1 -1
- data/spec/shared/method_matcher_behavior.rb +35 -0
- data/spec/shared/mutator_behavior.rb +63 -32
- data/spec/spec_helper.rb +13 -3
- data/spec/support/ice_nine_config.rb +8 -0
- data/spec/support/rspec.rb +1 -1
- data/spec/support/zombie.rb +1 -1
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +42 -28
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +15 -13
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +44 -0
- data/spec/unit/mutant/context/scope/root_spec.rb +4 -4
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -5
- data/spec/unit/mutant/killer/success_predicate_spec.rb +28 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/each_spec.rb +1 -1
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +112 -0
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +93 -0
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +59 -0
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +53 -0
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +37 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +33 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +42 -14
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +319 -0
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +31 -27
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +75 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -2
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +1 -3
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +1 -9
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +6 -2
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +111 -108
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +0 -33
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +2 -2
- data/spec/unit/mutant/runner/config/subjects_spec.rb +38 -0
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +53 -0
- data/spec/unit/mutant/runner/failed_predicte_spec.rb +33 -0
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +39 -0
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +49 -0
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +49 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +52 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +42 -0
- data/spec/unit/mutant/subject/context_spec.rb +6 -3
- data/spec/unit/mutant/subject/each_spec.rb +11 -8
- data/spec/unit/mutant/subject/node_spec.rb +6 -2
- data/test_app/spec/shared/method_filter_parse_behavior.rb +0 -2
- data/test_app/spec/shared/method_match_behavior.rb +1 -1
- data/test_app/spec/spec_helper.rb +4 -2
- metadata +101 -109
- data/config/roodi.yml +0 -26
- data/lib/mutant/matcher/method/classifier.rb +0 -141
- data/lib/mutant/matcher/object_space.rb +0 -114
- data/lib/mutant/mutator/node/actual_arguments.rb +0 -25
- data/lib/mutant/mutator/node/default_arguments.rb +0 -25
- data/lib/mutant/mutator/node/formal_arguments_19/default_mutations.rb +0 -33
- data/lib/mutant/mutator/node/formal_arguments_19/pattern_argument_expansion.rb +0 -35
- data/lib/mutant/mutator/node/formal_arguments_19/require_defaults.rb +0 -37
- data/lib/mutant/mutator/node/formal_arguments_19.rb +0 -41
- data/lib/mutant/mutator/node/iter_19.rb +0 -27
- data/lib/mutant/mutator/node/literal/empty_array.rb +0 -26
- data/lib/mutant/mutator/node/pattern_arguments.rb +0 -41
- data/lib/mutant/mutator/node/pattern_variable.rb +0 -23
- data/lib/mutant/mutator/node/receiver_case.rb +0 -122
- data/lib/mutant/mutator/node/send/binary_operator_method.rb +0 -61
- data/lib/mutant/mutator/node/send/with_arguments.rb +0 -81
- data/lib/mutant/reporter/stats.rb +0 -120
- data/lib/mutant/strategy/rspec/example_lookup.rb +0 -163
- data/spec/integration/mutant/method_matching_spec.rb +0 -269
- data/spec/shared/method_match_behavior.rb +0 -39
- data/spec/unit/mutant/killer/fail_ques_spec.rb +0 -39
- data/spec/unit/mutant/matcher/class_methods/from_string_spec.rb +0 -49
- data/spec/unit/mutant/matcher/class_methods/parse_spec.rb +0 -12
- data/spec/unit/mutant/matcher/method/class_methods/parse_spec.rb +0 -21
- data/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +0 -52
- data/spec/unit/mutant/matcher/object_space/class_methods/parse_spec.rb +0 -24
- data/spec/unit/mutant/matcher/object_space/each_spec.rb +0 -31
- data/spec/unit/mutant/mutator/node/if_statement/mutation_spec.rb +0 -60
- data/spec/unit/mutant/mutator/node/receiver_case/mutation_spec.rb +0 -27
- data/spec/unit/mutant/strategy/rspec/example_lookup/spec_file_spec.rb +0 -236
- data/spec/unit/mutant/subject/class_methods/new_spec.rb +0 -13
- data/tasks/metrics/ci.rake +0 -7
- data/tasks/metrics/flay.rake +0 -41
- data/tasks/metrics/flog.rake +0 -43
- data/tasks/metrics/heckle.rake +0 -216
- data/tasks/metrics/metric_fu.rake +0 -31
- data/tasks/metrics/reek.rake +0 -15
- data/tasks/metrics/roodi.rake +0 -15
- data/tasks/metrics/yardstick.rake +0 -23
- data/tasks/spec.rake +0 -45
- data/tasks/yard.rake +0 -9
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Matcher::Method::Classifier, '.run' do
|
4
|
-
subject { described_class.run(input) }
|
5
|
-
|
6
|
-
shared_examples_for 'Mutant::Matcher::Method::Classifier.run' do
|
7
|
-
before do
|
8
|
-
expected_class.stub(:new => response)
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:response) { :Response }
|
12
|
-
|
13
|
-
it { should be(response) }
|
14
|
-
|
15
|
-
it 'should initialize method filter with correct arguments' do
|
16
|
-
expected_class.should_receive(:new).with(TestApp::Literal, expected_method).and_return(response)
|
17
|
-
subject
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'with explicit toplevel scope' do
|
22
|
-
let(:input) { '::TestApp::Literal#string' }
|
23
|
-
let(:expected_class) { Mutant::Matcher::Method::Instance }
|
24
|
-
let(:expected_method) { TestApp::Literal.instance_method(:string) }
|
25
|
-
|
26
|
-
it_should_behave_like 'Mutant::Matcher::Method::Classifier.run'
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with instance method notation' do
|
30
|
-
let(:input) { 'TestApp::Literal#string' }
|
31
|
-
let(:expected_method) { TestApp::Literal.instance_method(:string) }
|
32
|
-
let(:expected_class) { Mutant::Matcher::Method::Instance }
|
33
|
-
|
34
|
-
it_should_behave_like 'Mutant::Matcher::Method::Classifier.run'
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with singleton method notation' do
|
38
|
-
let(:input) { 'TestApp::Literal.string' }
|
39
|
-
let(:expected_method) { TestApp::Literal.method(:string) }
|
40
|
-
let(:expected_class) { Mutant::Matcher::Method::Singleton }
|
41
|
-
|
42
|
-
it_should_behave_like 'Mutant::Matcher::Method::Classifier.run'
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'with invalid notation' do
|
46
|
-
let(:input) { 'Foo' }
|
47
|
-
|
48
|
-
it 'should return nil' do
|
49
|
-
should be(nil)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Matcher::ObjectSpace, '.parse' do
|
4
|
-
subject { object.parse(input) }
|
5
|
-
|
6
|
-
let(:object) { described_class }
|
7
|
-
|
8
|
-
let(:matcher) { mock('Matcher') }
|
9
|
-
|
10
|
-
context 'with valid notation' do
|
11
|
-
let(:input) { '::TestApp::Literal' }
|
12
|
-
|
13
|
-
it 'should return matcher' do
|
14
|
-
described_class.should_receive(:new).with(%r(\ATestApp::Literal(\z|::))).and_return(matcher)
|
15
|
-
should be(matcher)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with invalid notation' do
|
20
|
-
let(:input) { 'TestApp' }
|
21
|
-
|
22
|
-
it { should be(nil) }
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Matcher::ObjectSpace, '#each' do
|
4
|
-
before do
|
5
|
-
pending "defunct"
|
6
|
-
end
|
7
|
-
subject { object.each { |item| yields << item } }
|
8
|
-
|
9
|
-
let(:yields) { [] }
|
10
|
-
let(:object) { described_class.new(/\ATestApp::Literal(\z|::)/) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
Mutant::Matcher::Method::Singleton.stub(:each).and_yield(matcher_a)
|
14
|
-
Mutant::Matcher::Method::Instance.stub(:each).and_yield(matcher_b)
|
15
|
-
matcher_a.stub(:each).and_yield(subject_a)
|
16
|
-
matcher_b.stub(:each).and_yield(subject_b)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
let(:matcher_a) { mock('Matcher A') }
|
21
|
-
let(:matcher_b) { mock('Matcher B') }
|
22
|
-
|
23
|
-
let(:subject_a) { mock('Subject A') }
|
24
|
-
let(:subject_b) { mock('Subject B') }
|
25
|
-
|
26
|
-
it_should_behave_like 'an #each method'
|
27
|
-
|
28
|
-
it 'should yield subjects' do
|
29
|
-
expect { subject }.to change { yields }.from([]).to([subject_a, subject_b])
|
30
|
-
end
|
31
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Mutator, 'if statement' do
|
4
|
-
|
5
|
-
context 'if with two branches' do
|
6
|
-
let(:source) { 'if self.condition; true; else false; end' }
|
7
|
-
|
8
|
-
let(:mutations) do
|
9
|
-
mutants = []
|
10
|
-
|
11
|
-
# mutations of condition
|
12
|
-
mutants << 'if condition; true; else false; end'
|
13
|
-
|
14
|
-
mutants << 'if !self.condition; true; else false; end'
|
15
|
-
|
16
|
-
# Deleted else branch
|
17
|
-
mutants << 'if self.condition; true end'
|
18
|
-
|
19
|
-
# Deleted if branch with promoting else branch to if branch
|
20
|
-
mutants << 'if self.condition; false end'
|
21
|
-
|
22
|
-
# mutations of body
|
23
|
-
mutants << 'if self.condition; false; else false; end'
|
24
|
-
mutants << 'if self.condition; nil; else false; end'
|
25
|
-
|
26
|
-
# mutations of else body
|
27
|
-
mutants << 'if self.condition; true; else true; end'
|
28
|
-
mutants << 'if self.condition; true; else nil; end'
|
29
|
-
end
|
30
|
-
|
31
|
-
it_should_behave_like 'a mutator'
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'unless with one branch' do
|
35
|
-
let(:source) { 'unless condition; true; end' }
|
36
|
-
|
37
|
-
let(:mutations) do
|
38
|
-
mutants = []
|
39
|
-
mutants << 'unless !condition; true; end'
|
40
|
-
mutants << 'if condition; true; end'
|
41
|
-
mutants << 'unless condition; false; end'
|
42
|
-
mutants << 'unless condition; nil; end'
|
43
|
-
end
|
44
|
-
|
45
|
-
it_should_behave_like 'a mutator'
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'if with one branch' do
|
49
|
-
let(:source) { 'if condition; true; end' }
|
50
|
-
|
51
|
-
let(:mutations) do
|
52
|
-
mutants = []
|
53
|
-
mutants << 'if !condition; true; end'
|
54
|
-
mutants << 'if condition; false; end'
|
55
|
-
mutants << 'if condition; nil; end'
|
56
|
-
end
|
57
|
-
|
58
|
-
it_should_behave_like 'a mutator'
|
59
|
-
end
|
60
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Mutator::Node::ReceiverCase do
|
4
|
-
let(:source) { 'case self.condition; when true; true; when false; false; else raise; end' }
|
5
|
-
|
6
|
-
let(:mutations) do
|
7
|
-
mutations = []
|
8
|
-
|
9
|
-
# Delete each when once
|
10
|
-
mutations << 'case self.condition; when true; true; else raise; end'
|
11
|
-
mutations << 'case self.condition; when false; false; else raise; end'
|
12
|
-
|
13
|
-
# Mutate receiver
|
14
|
-
mutations << 'case condition; when true; true; when false; false; else raise; end'
|
15
|
-
|
16
|
-
# Remove else branch
|
17
|
-
mutations << 'case self.condition; when true; true; when false; false; end'
|
18
|
-
|
19
|
-
# Mutate when branch bodies
|
20
|
-
mutations << 'case self.condition; when true; nil; when false; false; else raise; end'
|
21
|
-
mutations << 'case self.condition; when true; false; when false; false; else raise; end'
|
22
|
-
mutations << 'case self.condition; when true; true; when false; nil; else raise; end'
|
23
|
-
mutations << 'case self.condition; when true; true; when false; true; else raise; end'
|
24
|
-
end
|
25
|
-
|
26
|
-
it_should_behave_like 'a mutator'
|
27
|
-
end
|
@@ -1,236 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
|
4
|
-
|
5
|
-
let(:object) { described_class.new(mutation) }
|
6
|
-
let(:mutation) { mock('Mutation', :subject => mutation_subject) }
|
7
|
-
let(:mutation_subject) { mock('Subject', :matcher => matcher) }
|
8
|
-
let(:matcher) { mock('Matcher', :method_name => method_name) }
|
9
|
-
|
10
|
-
subject { object.send(:spec_file) }
|
11
|
-
|
12
|
-
shared_examples_for 'Mutant::Strategy::Rspec::ExampleLookup#spec_file' do
|
13
|
-
it_should_behave_like 'an idempotent method'
|
14
|
-
|
15
|
-
it { should eql(expected_spec_file) }
|
16
|
-
it { should be_frozen }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'negation operator' do
|
20
|
-
let(:method_name) { :'!' }
|
21
|
-
let(:expected_spec_file) { 'negation_operator_spec.rb' }
|
22
|
-
|
23
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with unary match method' do
|
27
|
-
let(:method_name) { :~@ }
|
28
|
-
let(:expected_spec_file) { 'unary_match_operator_spec.rb' }
|
29
|
-
|
30
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with unary substraction method' do
|
34
|
-
let(:method_name) { :-@ }
|
35
|
-
let(:expected_spec_file) { 'unary_substraction_operator_spec.rb' }
|
36
|
-
|
37
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with unary addition method' do
|
41
|
-
let(:method_name) { :+@ }
|
42
|
-
let(:expected_spec_file) { 'unary_addition_operator_spec.rb' }
|
43
|
-
|
44
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with bitwise xor method' do
|
48
|
-
let(:method_name) { :^ }
|
49
|
-
let(:expected_spec_file) { 'bitwise_xor_operator_spec.rb' }
|
50
|
-
|
51
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'with bitwise or method' do
|
55
|
-
let(:method_name) { :| }
|
56
|
-
let(:expected_spec_file) { 'bitwise_or_operator_spec.rb' }
|
57
|
-
|
58
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'with bitwise and method' do
|
62
|
-
let(:method_name) { :& }
|
63
|
-
let(:expected_spec_file) { 'bitwise_and_operator_spec.rb' }
|
64
|
-
|
65
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'with spaceship method' do
|
69
|
-
let(:method_name) { :<=> }
|
70
|
-
let(:expected_spec_file) { 'spaceship_operator_spec.rb' }
|
71
|
-
|
72
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'with case equality operator method' do
|
76
|
-
let(:method_name) { :=== }
|
77
|
-
let(:expected_spec_file) { 'case_equality_operator_spec.rb' }
|
78
|
-
|
79
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'with modulo operator method' do
|
83
|
-
let(:method_name) { :% }
|
84
|
-
let(:expected_spec_file) { 'modulo_operator_spec.rb' }
|
85
|
-
|
86
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'with exponentation operator method' do
|
90
|
-
let(:method_name) { :** }
|
91
|
-
let(:expected_spec_file) { 'exponentation_operator_spec.rb' }
|
92
|
-
|
93
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'with substraction operator method' do
|
97
|
-
let(:method_name) { :- }
|
98
|
-
let(:expected_spec_file) { 'substraction_operator_spec.rb' }
|
99
|
-
|
100
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'with addition operator method' do
|
104
|
-
let(:method_name) { :+ }
|
105
|
-
let(:expected_spec_file) { 'addition_operator_spec.rb' }
|
106
|
-
|
107
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'with greater than or equal to operator method' do
|
111
|
-
let(:method_name) { :>= }
|
112
|
-
let(:expected_spec_file) { 'greater_than_or_equal_to_operator_spec.rb' }
|
113
|
-
|
114
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'with less than or equal to operator method' do
|
118
|
-
let(:method_name) { :<= }
|
119
|
-
let(:expected_spec_file) { 'less_than_or_equal_to_operator_spec.rb' }
|
120
|
-
|
121
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
122
|
-
end
|
123
|
-
|
124
|
-
context 'with greater than operator method' do
|
125
|
-
let(:method_name) { :> }
|
126
|
-
let(:expected_spec_file) { 'greater_than_operator_spec.rb' }
|
127
|
-
|
128
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'with less than operator method' do
|
132
|
-
let(:method_name) { :< }
|
133
|
-
let(:expected_spec_file) { 'less_than_operator_spec.rb' }
|
134
|
-
|
135
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'with right shift operator method' do
|
139
|
-
let(:method_name) { :>> }
|
140
|
-
let(:expected_spec_file) { 'right_shift_operator_spec.rb' }
|
141
|
-
|
142
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'with left shift operator method' do
|
146
|
-
let(:method_name) { :<< }
|
147
|
-
let(:expected_spec_file) { 'left_shift_operator_spec.rb' }
|
148
|
-
|
149
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'with division operator method' do
|
153
|
-
let(:method_name) { :/ }
|
154
|
-
let(:expected_spec_file) { 'division_operator_spec.rb' }
|
155
|
-
|
156
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
157
|
-
end
|
158
|
-
|
159
|
-
context 'with multiplication operator method' do
|
160
|
-
let(:method_name) { :* }
|
161
|
-
let(:expected_spec_file) { 'multiplication_operator_spec.rb' }
|
162
|
-
|
163
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
164
|
-
end
|
165
|
-
|
166
|
-
context 'with nomatch operator method' do
|
167
|
-
let(:method_name) { :'!~' }
|
168
|
-
let(:expected_spec_file) { 'nomatch_operator_spec.rb' }
|
169
|
-
|
170
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'with match operator method' do
|
174
|
-
let(:method_name) { :=~ }
|
175
|
-
let(:expected_spec_file) { 'match_operator_spec.rb' }
|
176
|
-
|
177
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'with inequality operator method' do
|
181
|
-
let(:method_name) { :'!=' }
|
182
|
-
let(:expected_spec_file) { 'inequality_operator_spec.rb' }
|
183
|
-
|
184
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
185
|
-
end
|
186
|
-
|
187
|
-
context 'with equality operator method' do
|
188
|
-
let(:method_name) { :== }
|
189
|
-
let(:expected_spec_file) { 'equality_operator_spec.rb' }
|
190
|
-
|
191
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'with element reader method' do
|
195
|
-
let(:method_name) { :[] }
|
196
|
-
let(:expected_spec_file) { 'element_reader_spec.rb' }
|
197
|
-
|
198
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
199
|
-
end
|
200
|
-
|
201
|
-
context 'with element writer method' do
|
202
|
-
let(:method_name) { :[]= }
|
203
|
-
|
204
|
-
let(:expected_spec_file) { 'element_writer_spec.rb' }
|
205
|
-
|
206
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
207
|
-
end
|
208
|
-
|
209
|
-
context 'with writer method' do
|
210
|
-
let(:method_name) { :foo= }
|
211
|
-
let(:expected_spec_file) { 'foo_writer_spec.rb' }
|
212
|
-
|
213
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
214
|
-
end
|
215
|
-
|
216
|
-
context 'with bang method' do
|
217
|
-
let(:method_name) { :foo! }
|
218
|
-
let(:expected_spec_file) { 'foo_bang_spec.rb' }
|
219
|
-
|
220
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'with predicate method' do
|
224
|
-
let(:method_name) { :foo? }
|
225
|
-
let(:expected_spec_file) { 'foo_predicate_spec.rb' }
|
226
|
-
|
227
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
228
|
-
end
|
229
|
-
|
230
|
-
context 'with regular method' do
|
231
|
-
let(:method_name) { :foo }
|
232
|
-
let(:expected_spec_file) { 'foo_spec.rb' }
|
233
|
-
|
234
|
-
it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
|
235
|
-
end
|
236
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mutant::Subject, '.new' do
|
4
|
-
subject { object.new(matcher, context, ast) }
|
5
|
-
|
6
|
-
let(:object) { described_class }
|
7
|
-
|
8
|
-
let(:matcher) { mock('Matcher') }
|
9
|
-
let(:context) { mock('Context') }
|
10
|
-
let(:ast) { mock('AST') }
|
11
|
-
|
12
|
-
it { should be_frozen }
|
13
|
-
end
|
data/tasks/metrics/ci.rake
DELETED
data/tasks/metrics/flay.rake
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'flay'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze
|
6
|
-
threshold = config.fetch('threshold').to_i
|
7
|
-
total_score = config.fetch('total_score').to_f
|
8
|
-
files = Flay.expand_dirs_to_files(config.fetch('path', 'lib'))
|
9
|
-
|
10
|
-
# original code by Marty Andrews:
|
11
|
-
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
12
|
-
desc 'Analyze for code duplication'
|
13
|
-
task :flay do
|
14
|
-
# run flay once without a threshold to ensure the max mass matches the threshold
|
15
|
-
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0)
|
16
|
-
flay.process(*files)
|
17
|
-
|
18
|
-
max = flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max
|
19
|
-
unless max >= threshold
|
20
|
-
raise "Adjust flay threshold down to #{max}"
|
21
|
-
end
|
22
|
-
|
23
|
-
total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) }
|
24
|
-
unless total == total_score
|
25
|
-
raise "Flay total is now #{total}, but expected #{total_score}"
|
26
|
-
end
|
27
|
-
|
28
|
-
# run flay a second time with the threshold set
|
29
|
-
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ)
|
30
|
-
flay.process(*files)
|
31
|
-
|
32
|
-
if flay.masses.any?
|
33
|
-
flay.report
|
34
|
-
raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
task :flay do
|
39
|
-
abort 'Flay is not available. In order to run flay, you must: gem install flay'
|
40
|
-
end
|
41
|
-
end
|
data/tasks/metrics/flog.rake
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'flog'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
class Float
|
6
|
-
def round_to(n)
|
7
|
-
(self * 10**n).round.to_f * 10**-n
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze
|
12
|
-
threshold = config.fetch('threshold').to_f.round_to(1)
|
13
|
-
|
14
|
-
# original code by Marty Andrews:
|
15
|
-
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
16
|
-
desc 'Analyze for code complexity'
|
17
|
-
task :flog do
|
18
|
-
flog = Flog.new
|
19
|
-
flog.flog Array(config.fetch('path', 'lib'))
|
20
|
-
|
21
|
-
totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }.
|
22
|
-
map { |name, score| [ name, score.round_to(1) ] }.
|
23
|
-
sort_by { |name, score| score }
|
24
|
-
|
25
|
-
max = totals.last[1]
|
26
|
-
unless max >= threshold
|
27
|
-
raise "Adjust flog score down to #{max}"
|
28
|
-
end
|
29
|
-
|
30
|
-
bad_methods = totals.select { |name, score| score > threshold }
|
31
|
-
if bad_methods.any?
|
32
|
-
bad_methods.reverse_each do |name, score|
|
33
|
-
puts '%8.1f: %s' % [ score, name ]
|
34
|
-
end
|
35
|
-
|
36
|
-
raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
rescue LoadError
|
40
|
-
task :flog do
|
41
|
-
abort 'Flog is not available. In order to run flog, you must: gem install flog'
|
42
|
-
end
|
43
|
-
end
|