mutant 0.3.0.beta21 → 0.3.0.beta22
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.
- checksums.yaml +4 -4
- data/.gitignore +37 -6
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +13 -7
- data/Gemfile +8 -3
- data/Gemfile.devtools +2 -6
- data/Guardfile +22 -8
- data/README.md +3 -1
- data/Rakefile +3 -0
- data/bin/mutant +4 -3
- data/config/devtools.yml +1 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +7 -6
- data/config/rubocop.yml +55 -0
- data/lib/mutant.rb +3 -1
- data/lib/mutant/cache.rb +2 -0
- data/lib/mutant/cli.rb +14 -10
- data/lib/mutant/cli/classifier.rb +22 -10
- data/lib/mutant/cli/classifier/method.rb +14 -15
- data/lib/mutant/cli/classifier/namespace.rb +6 -2
- data/lib/mutant/cli/classifier/scope.rb +3 -1
- data/lib/mutant/color.rb +7 -3
- data/lib/mutant/config.rb +2 -0
- data/lib/mutant/constants.rb +5 -4
- data/lib/mutant/context.rb +2 -0
- data/lib/mutant/context/scope.rb +3 -1
- data/lib/mutant/differ.rb +10 -2
- data/lib/mutant/killer.rb +4 -1
- data/lib/mutant/killer/forked.rb +2 -0
- data/lib/mutant/killer/forking.rb +2 -0
- data/lib/mutant/killer/rspec.rb +19 -3
- data/lib/mutant/killer/static.rb +2 -0
- data/lib/mutant/loader.rb +8 -1
- data/lib/mutant/matcher.rb +2 -0
- data/lib/mutant/matcher/chain.rb +2 -0
- data/lib/mutant/matcher/method.rb +15 -3
- data/lib/mutant/matcher/method/finder.rb +2 -0
- data/lib/mutant/matcher/method/instance.rb +4 -1
- data/lib/mutant/matcher/method/singleton.rb +7 -1
- data/lib/mutant/matcher/methods.rb +3 -1
- data/lib/mutant/matcher/namespace.rb +4 -2
- data/lib/mutant/matcher/scope.rb +2 -0
- data/lib/mutant/mutation.rb +19 -5
- data/lib/mutant/mutation/evil.rb +12 -0
- data/lib/mutant/mutation/filter.rb +2 -0
- data/lib/mutant/mutation/filter/code.rb +3 -1
- data/lib/mutant/mutation/filter/regexp.rb +2 -0
- data/lib/mutant/mutation/filter/whitelist.rb +2 -0
- data/lib/mutant/mutation/neutral.rb +25 -0
- data/lib/mutant/mutator.rb +4 -6
- data/lib/mutant/mutator/node.rb +5 -1
- data/lib/mutant/mutator/node/argument.rb +2 -0
- data/lib/mutant/mutator/node/arguments.rb +2 -0
- data/lib/mutant/mutator/node/begin.rb +2 -0
- data/lib/mutant/mutator/node/block.rb +2 -0
- data/lib/mutant/mutator/node/case.rb +3 -1
- data/lib/mutant/mutator/node/connective/binary.rb +3 -1
- data/lib/mutant/mutator/node/const.rb +2 -0
- data/lib/mutant/mutator/node/define.rb +2 -0
- data/lib/mutant/mutator/node/generic.rb +4 -3
- data/lib/mutant/mutator/node/if.rb +2 -0
- data/lib/mutant/mutator/node/literal.rb +2 -0
- data/lib/mutant/mutator/node/literal/array.rb +2 -0
- data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
- data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
- data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
- data/lib/mutant/mutator/node/literal/float.rb +2 -0
- data/lib/mutant/mutator/node/literal/hash.rb +2 -0
- data/lib/mutant/mutator/node/literal/nil.rb +2 -0
- data/lib/mutant/mutator/node/literal/range.rb +2 -1
- data/lib/mutant/mutator/node/literal/regex.rb +2 -0
- data/lib/mutant/mutator/node/literal/string.rb +2 -0
- data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
- data/lib/mutant/mutator/node/masgn.rb +2 -0
- data/lib/mutant/mutator/node/mlhs.rb +2 -0
- data/lib/mutant/mutator/node/named_value/access.rb +2 -0
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
- data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
- data/lib/mutant/mutator/node/return.rb +2 -0
- data/lib/mutant/mutator/node/send.rb +2 -0
- data/lib/mutant/mutator/node/send/binary.rb +2 -0
- data/lib/mutant/mutator/node/splat.rb +2 -0
- data/lib/mutant/mutator/node/super.rb +2 -0
- data/lib/mutant/mutator/node/when.rb +3 -1
- data/lib/mutant/mutator/node/while.rb +2 -0
- data/lib/mutant/mutator/node/zsuper.rb +2 -0
- data/lib/mutant/mutator/registry.rb +55 -13
- data/lib/mutant/mutator/util.rb +2 -0
- data/lib/mutant/mutator/util/array.rb +3 -1
- data/lib/mutant/mutator/util/symbol.rb +2 -0
- data/lib/mutant/node_helpers.rb +10 -4
- data/lib/mutant/random.rb +2 -0
- data/lib/mutant/reporter.rb +2 -0
- data/lib/mutant/reporter/cli.rb +2 -0
- data/lib/mutant/reporter/cli/printer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/config.rb +5 -2
- data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
- data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
- data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
- data/lib/mutant/reporter/null.rb +2 -0
- data/lib/mutant/runner.rb +2 -0
- data/lib/mutant/runner/config.rb +2 -0
- data/lib/mutant/runner/mutation.rb +2 -0
- data/lib/mutant/runner/subject.rb +2 -0
- data/lib/mutant/singleton_methods.rb +5 -3
- data/lib/mutant/strategy.rb +2 -0
- data/lib/mutant/strategy/method_expansion.rb +2 -0
- data/lib/mutant/strategy/rspec.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2.rb +2 -0
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
- data/lib/mutant/strategy/static.rb +2 -0
- data/lib/mutant/subject.rb +4 -1
- data/lib/mutant/subject/method.rb +2 -0
- data/lib/mutant/subject/method/instance.rb +2 -0
- data/lib/mutant/subject/method/singleton.rb +2 -0
- data/lib/mutant/support/method_object.rb +2 -0
- data/lib/mutant/zombifier.rb +10 -6
- data/mutant.gemspec +11 -10
- data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
- data/spec/integration/mutant/zombie_spec.rb +2 -0
- data/spec/shared/method_matcher_behavior.rb +2 -0
- data/spec/shared/mutator_behavior.rb +16 -7
- data/spec/spec_helper.rb +26 -5
- data/spec/support/compress_helper.rb +5 -5
- data/spec/support/ice_nine_config.rb +2 -0
- data/spec/support/rspec.rb +2 -0
- data/spec/support/test_app.rb +2 -0
- data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
- data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
- data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
- data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
- data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
- data/spec/unit/mutant/context/root_spec.rb +5 -1
- data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
- data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
- data/spec/unit/mutant/differ/diff_spec.rb +67 -5
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
- data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
- data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
- data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
- data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
- data/spec/unit/mutant/matcher/each_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
- data/spec/unit/mutant/mutator/each_spec.rb +2 -0
- data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
- data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
- data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
- data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
- data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
- data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
- data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
- data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
- data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
- data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
- data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
- data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
- data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
- data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
- data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
- data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
- data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
- data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
- data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
- data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
- data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
- data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
- data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
- data/spec/unit/mutant/subject/context_spec.rb +2 -0
- data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
- data/spec/unit/mutant/subject/node_spec.rb +2 -0
- data/test_app/lib/test_app.rb +2 -0
- data/test_app/lib/test_app/literal.rb +2 -0
- data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
- data/test_app/spec/shared/method_match_behavior.rb +2 -0
- data/test_app/spec/spec_helper.rb +3 -1
- data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
- data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
- metadata +66 -18
- data/bin/zombie +0 -18
- data/test_app/spec/shared/mutator_behavior.rb +0 -44
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
shared_examples_for 'an invalid cli run' do
|
|
4
6
|
it 'should raise error' do
|
|
5
|
-
expect
|
|
7
|
+
expect do
|
|
8
|
+
subject
|
|
9
|
+
end.to raise_error(Mutant::CLI::Error, expected_message)
|
|
6
10
|
end
|
|
7
11
|
end
|
|
8
12
|
|
|
@@ -28,6 +32,9 @@ describe Mutant::CLI, '.new' do
|
|
|
28
32
|
let(:expected_strategy) { Mutant::Strategy::Rspec::Unit }
|
|
29
33
|
let(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
|
|
30
34
|
|
|
35
|
+
let(:ns) { Mutant::CLI::Classifier }
|
|
36
|
+
let(:cache) { Mutant::Cache.new }
|
|
37
|
+
|
|
31
38
|
let(:cli) { object.new(arguments) }
|
|
32
39
|
|
|
33
40
|
subject { cli }
|
|
@@ -70,21 +77,23 @@ describe Mutant::CLI, '.new' do
|
|
|
70
77
|
end
|
|
71
78
|
|
|
72
79
|
context 'with explicit method matcher' do
|
|
73
|
-
let(:arguments) { %w(--rspec-unit TestApp::Literal#float)
|
|
74
|
-
let(:expected_matcher) {
|
|
80
|
+
let(:arguments) { %w(--rspec-unit TestApp::Literal#float) }
|
|
81
|
+
let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
|
|
75
82
|
|
|
76
83
|
it_should_behave_like 'a cli parser'
|
|
77
84
|
end
|
|
78
85
|
|
|
79
86
|
context 'with namespace matcher' do
|
|
80
|
-
let(:
|
|
81
|
-
let(:
|
|
87
|
+
let(:matcher) { '::TestApp*' }
|
|
88
|
+
let(:arguments) { %W(--rspec-unit #{matcher}) }
|
|
89
|
+
let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
|
|
82
90
|
|
|
83
91
|
it_should_behave_like 'a cli parser'
|
|
84
92
|
end
|
|
85
93
|
|
|
86
94
|
context 'with code filter' do
|
|
87
|
-
let(:
|
|
95
|
+
let(:matcher) { 'TestApp::Literal#float' }
|
|
96
|
+
let(:arguments) { %W(--rspec-unit --code faa --code bbb #{matcher}) }
|
|
88
97
|
|
|
89
98
|
let(:filters) do
|
|
90
99
|
[
|
|
@@ -93,8 +102,8 @@ describe Mutant::CLI, '.new' do
|
|
|
93
102
|
]
|
|
94
103
|
end
|
|
95
104
|
|
|
96
|
-
let(:expected_matcher) {
|
|
97
|
-
let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters)
|
|
105
|
+
let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
|
|
106
|
+
let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters) }
|
|
98
107
|
|
|
99
108
|
it_should_behave_like 'a cli parser'
|
|
100
109
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::CLI, '.run' do
|
|
@@ -21,7 +23,10 @@ describe Mutant::CLI, '.run' do
|
|
|
21
23
|
it { should be(0) }
|
|
22
24
|
|
|
23
25
|
it 'should run with attributes' do
|
|
24
|
-
Mutant::Runner::Config
|
|
26
|
+
Mutant::Runner::Config
|
|
27
|
+
.should_receive(:run)
|
|
28
|
+
.with(config)
|
|
29
|
+
.and_return(runner)
|
|
25
30
|
should be(0)
|
|
26
31
|
end
|
|
27
32
|
end
|
|
@@ -32,7 +37,10 @@ describe Mutant::CLI, '.run' do
|
|
|
32
37
|
it { should be(1) }
|
|
33
38
|
|
|
34
39
|
it 'should run with attributes' do
|
|
35
|
-
Mutant::Runner::Config
|
|
40
|
+
Mutant::Runner::Config
|
|
41
|
+
.should_receive(:run)
|
|
42
|
+
.with(config)
|
|
43
|
+
.and_return(runner)
|
|
36
44
|
should be(1)
|
|
37
45
|
end
|
|
38
46
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::CLI::Classifier, '.build' do
|
|
@@ -9,7 +11,8 @@ describe Mutant::CLI::Classifier, '.build' do
|
|
|
9
11
|
|
|
10
12
|
shared_examples_for this_spec do
|
|
11
13
|
it 'shoud return expected instance' do
|
|
12
|
-
|
|
14
|
+
regexp = expected_class::REGEXP
|
|
15
|
+
should eql(expected_class.new(cache, regexp.match(input)))
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
let(:expected_class) { Mutant::CLI::Classifier::Method }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mutant::CLI::Classifier::Method, '#each' do
|
|
6
|
+
let(:object) { described_class.build(cache, input) }
|
|
7
|
+
let(:cache) { Mutant::Cache.new }
|
|
8
|
+
let(:instance_method) { '::TestApp::Literal#string' }
|
|
9
|
+
let(:singleton_method) { '::TestApp::Literal.string' }
|
|
10
|
+
let(:unknown_method) { '::TestApp::Literal#unknown' }
|
|
11
|
+
|
|
12
|
+
context 'with a block' do
|
|
13
|
+
subject { object.each {} }
|
|
14
|
+
|
|
15
|
+
context 'with an instance method name' do
|
|
16
|
+
let(:input) { instance_method }
|
|
17
|
+
|
|
18
|
+
it_behaves_like 'a command method'
|
|
19
|
+
|
|
20
|
+
it 'yield an instance subject' do
|
|
21
|
+
expect { |block| object.each(&block) }
|
|
22
|
+
.to yield_with_args(Mutant::Subject::Method::Instance)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'with an singleton method name' do
|
|
27
|
+
let(:input) { singleton_method }
|
|
28
|
+
|
|
29
|
+
it_behaves_like 'a command method'
|
|
30
|
+
|
|
31
|
+
it 'yield an instance subject' do
|
|
32
|
+
expect { |block| object.each(&block) }
|
|
33
|
+
.to yield_with_args(Mutant::Subject::Method::Singleton)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'with an unknown method' do
|
|
38
|
+
let(:input) { unknown_method }
|
|
39
|
+
|
|
40
|
+
it 'raises an exception' do
|
|
41
|
+
expect { subject }
|
|
42
|
+
.to raise_error(NameError, "Cannot find method #{input}")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'without a block' do
|
|
48
|
+
subject { object.each }
|
|
49
|
+
|
|
50
|
+
context 'with an instance method name' do
|
|
51
|
+
let(:input) { instance_method }
|
|
52
|
+
|
|
53
|
+
it 'returns an enumerator' do
|
|
54
|
+
should be_instance_of(to_enum.class)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'yield an instance subject' do
|
|
58
|
+
expect { |block| subject.each(&block) }
|
|
59
|
+
.to yield_with_args(Mutant::Subject::Method::Instance)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'with an singleton method name' do
|
|
64
|
+
let(:input) { singleton_method }
|
|
65
|
+
|
|
66
|
+
it 'returns an enumerator' do
|
|
67
|
+
should be_instance_of(to_enum.class)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'yield an instance subject' do
|
|
71
|
+
expect { |block| subject.each(&block) }
|
|
72
|
+
.to yield_with_args(Mutant::Subject::Method::Singleton)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context 'with an unknown method' do
|
|
77
|
+
let(:input) { unknown_method }
|
|
78
|
+
|
|
79
|
+
it 'returns an enumerator' do
|
|
80
|
+
should be_instance_of(to_enum.class)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'raises an exception when #each is called' do
|
|
84
|
+
expect { subject.each {} }
|
|
85
|
+
.to raise_error(NameError, "Cannot find method #{input}")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mutant::CLI::Classifier::Namespace::Flat, '#each' do
|
|
6
|
+
let(:object) { described_class.build(cache, input) }
|
|
7
|
+
let(:cache) { Mutant::Cache.new }
|
|
8
|
+
let(:known_namespace) { '::TestApp::Literal' }
|
|
9
|
+
let(:unknown_namespace) { '::TestApp::Object' }
|
|
10
|
+
|
|
11
|
+
context 'with a block' do
|
|
12
|
+
subject { object.each {} }
|
|
13
|
+
|
|
14
|
+
context 'with a known namespace' do
|
|
15
|
+
let(:input) { known_namespace }
|
|
16
|
+
|
|
17
|
+
it_behaves_like 'a command method'
|
|
18
|
+
|
|
19
|
+
it 'yield method subjects' do
|
|
20
|
+
expect { |block| object.each(&block) }
|
|
21
|
+
.to yield_control.exactly(7).times
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'with an unknown namespace' do
|
|
26
|
+
let(:input) { unknown_namespace }
|
|
27
|
+
|
|
28
|
+
it 'raises an exception' do
|
|
29
|
+
expect { subject }.to raise_error(NameError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'without a block' do
|
|
35
|
+
subject { object.each }
|
|
36
|
+
|
|
37
|
+
context 'with a known namespace' do
|
|
38
|
+
let(:input) { known_namespace }
|
|
39
|
+
|
|
40
|
+
it 'returns an enumerator' do
|
|
41
|
+
should be_instance_of(to_enum.class)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'yield an instance subject' do
|
|
45
|
+
expect { |block| object.each(&block) }
|
|
46
|
+
.to yield_control.exactly(7).times
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'with an unknown namespace' do
|
|
51
|
+
let(:input) { unknown_namespace }
|
|
52
|
+
|
|
53
|
+
it 'raises an exception when #each is called' do
|
|
54
|
+
expect { subject.each {} }.to raise_error(NameError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
|
|
6
|
+
let(:object) { described_class.build(cache, "#{input}*") }
|
|
7
|
+
let(:cache) { Mutant::Cache.new }
|
|
8
|
+
let(:known_namespace) { '::TestApp::Literal' }
|
|
9
|
+
let(:unknown_namespace) { '::TestApp::Object' }
|
|
10
|
+
|
|
11
|
+
context 'with a block' do
|
|
12
|
+
subject { object.each {} }
|
|
13
|
+
|
|
14
|
+
context 'with a known namespace' do
|
|
15
|
+
let(:input) { known_namespace }
|
|
16
|
+
|
|
17
|
+
it_behaves_like 'a command method'
|
|
18
|
+
|
|
19
|
+
it 'yield method subjects' do
|
|
20
|
+
expect { |block| object.each(&block) }
|
|
21
|
+
.to yield_control.exactly(7).times
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'with an unknown namespace' do
|
|
26
|
+
let(:input) { unknown_namespace }
|
|
27
|
+
|
|
28
|
+
it 'raises an exception' do
|
|
29
|
+
expect { subject }.to raise_error(NameError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'without a block' do
|
|
35
|
+
subject { object.each }
|
|
36
|
+
|
|
37
|
+
context 'with a known namespace' do
|
|
38
|
+
let(:input) { known_namespace }
|
|
39
|
+
|
|
40
|
+
it 'returns an enumerator' do
|
|
41
|
+
should be_instance_of(to_enum.class)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'yield an instance subject' do
|
|
45
|
+
expect { |block| object.each(&block) }
|
|
46
|
+
.to yield_control.exactly(7).times
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'with an unknown namespace' do
|
|
51
|
+
let(:input) { unknown_namespace }
|
|
52
|
+
|
|
53
|
+
it 'raises an exception when #each is called' do
|
|
54
|
+
expect { subject.each {} }.to raise_error(NameError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Mutant::CLI::Classifier::Scope, '#each' do
|
|
6
|
+
let(:object) { described_class.build(cache, input) }
|
|
7
|
+
let(:cache) { Mutant::Cache.new }
|
|
8
|
+
let(:input) { ::TestApp::Literal }
|
|
9
|
+
|
|
10
|
+
context 'with a block' do
|
|
11
|
+
subject { object.each {} }
|
|
12
|
+
|
|
13
|
+
it_behaves_like 'a command method'
|
|
14
|
+
|
|
15
|
+
it 'yield method subjects' do
|
|
16
|
+
expect { |block| object.each(&block) }
|
|
17
|
+
.to yield_control.exactly(7).times
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'without a block' do
|
|
22
|
+
subject { object.each }
|
|
23
|
+
|
|
24
|
+
it 'returns an enumerator' do
|
|
25
|
+
should be_instance_of(to_enum.class)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'yield an instance subject' do
|
|
29
|
+
expect { |block| object.each(&block) }
|
|
30
|
+
.to yield_control.exactly(7).times
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Context, '#root' do
|
|
@@ -6,6 +8,8 @@ describe Mutant::Context, '#root' do
|
|
|
6
8
|
let(:object) { described_class.allocate }
|
|
7
9
|
|
|
8
10
|
it 'should raise error' do
|
|
9
|
-
expect
|
|
11
|
+
expect do
|
|
12
|
+
subject
|
|
13
|
+
end.to raise_error('Mutant::Context#root is not implemented')
|
|
10
14
|
end
|
|
11
15
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mutant::Differ, '#diff' do
|
|
@@ -9,7 +11,16 @@ describe Mutant::Differ, '#diff' do
|
|
|
9
11
|
let(:old) { %w(foo bar) }
|
|
10
12
|
let(:new) { %w(baz bar) }
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
let(:expectation) do
|
|
15
|
+
strip_indent(<<-STR)
|
|
16
|
+
@@ -1,3 +1,3 @@
|
|
17
|
+
-foo
|
|
18
|
+
+baz
|
|
19
|
+
bar
|
|
20
|
+
STR
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it { should eql(expectation) }
|
|
13
24
|
|
|
14
25
|
it_should_behave_like 'an idempotent method'
|
|
15
26
|
end
|
|
@@ -18,7 +29,16 @@ describe Mutant::Differ, '#diff' do
|
|
|
18
29
|
let(:old) { %w(foo bar) }
|
|
19
30
|
let(:new) { %w(foo baz bar) }
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
let(:expectation) do
|
|
33
|
+
strip_indent(<<-STR)
|
|
34
|
+
@@ -1,3 +1,4 @@
|
|
35
|
+
foo
|
|
36
|
+
+baz
|
|
37
|
+
bar
|
|
38
|
+
STR
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it { should eql(expectation) }
|
|
22
42
|
|
|
23
43
|
it_should_behave_like 'an idempotent method'
|
|
24
44
|
end
|
|
@@ -27,7 +47,21 @@ describe Mutant::Differ, '#diff' do
|
|
|
27
47
|
let(:old) { %w(foo bar baz boz a b c) }
|
|
28
48
|
let(:new) { %w(foo bar baz boz a b c other) }
|
|
29
49
|
|
|
30
|
-
|
|
50
|
+
let(:expectation) do
|
|
51
|
+
strip_indent(<<-STR)
|
|
52
|
+
@@ -1,8 +1,9 @@
|
|
53
|
+
foo
|
|
54
|
+
bar
|
|
55
|
+
baz
|
|
56
|
+
boz
|
|
57
|
+
a
|
|
58
|
+
b
|
|
59
|
+
c
|
|
60
|
+
+other
|
|
61
|
+
STR
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it { should eql(expectation) }
|
|
31
65
|
|
|
32
66
|
it_should_behave_like 'an idempotent method'
|
|
33
67
|
end
|
|
@@ -36,7 +70,21 @@ describe Mutant::Differ, '#diff' do
|
|
|
36
70
|
let(:old) { %w(other foo bar baz boz a b c) }
|
|
37
71
|
let(:new) { %w(foo bar baz boz a b c) }
|
|
38
72
|
|
|
39
|
-
|
|
73
|
+
let(:expectation) do
|
|
74
|
+
strip_indent(<<-STR)
|
|
75
|
+
@@ -1,9 +1,8 @@
|
|
76
|
+
-other
|
|
77
|
+
foo
|
|
78
|
+
bar
|
|
79
|
+
baz
|
|
80
|
+
boz
|
|
81
|
+
a
|
|
82
|
+
b
|
|
83
|
+
c
|
|
84
|
+
STR
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it { should eql(expectation) }
|
|
40
88
|
|
|
41
89
|
it_should_behave_like 'an idempotent method'
|
|
42
90
|
end
|
|
@@ -45,7 +93,21 @@ describe Mutant::Differ, '#diff' do
|
|
|
45
93
|
let(:old) { %w(foo bar baz boz a b c) }
|
|
46
94
|
let(:new) { %w(other foo bar baz boz a b c) }
|
|
47
95
|
|
|
48
|
-
|
|
96
|
+
let(:expectation) do
|
|
97
|
+
strip_indent(<<-STR)
|
|
98
|
+
@@ -1,8 +1,9 @@
|
|
99
|
+
+other
|
|
100
|
+
foo
|
|
101
|
+
bar
|
|
102
|
+
baz
|
|
103
|
+
boz
|
|
104
|
+
a
|
|
105
|
+
b
|
|
106
|
+
c
|
|
107
|
+
STR
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it { should eql(expectation) }
|
|
49
111
|
|
|
50
112
|
it_should_behave_like 'an idempotent method'
|
|
51
113
|
end
|