mutant 0.5.26 → 0.6.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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/Changelog.md +16 -3
- data/Gemfile +0 -2
- data/Gemfile.devtools +2 -2
- data/README.md +9 -15
- data/bin/mutant +0 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/mutant.yml +1 -1
- data/config/reek.yml +14 -11
- data/config/rubocop.yml +1 -1
- data/lib/mutant.rb +22 -21
- data/lib/mutant/ast.rb +47 -0
- data/lib/mutant/cli.rb +7 -4
- data/lib/mutant/config.rb +1 -0
- data/lib/mutant/context.rb +1 -1
- data/lib/mutant/diff.rb +38 -7
- data/lib/mutant/env.rb +22 -3
- data/lib/mutant/expression.rb +15 -4
- data/lib/mutant/integration.rb +1 -1
- data/lib/mutant/isolation.rb +2 -4
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/matcher/method.rb +1 -1
- data/lib/mutant/matcher/method/singleton.rb +1 -1
- data/lib/mutant/matcher/methods.rb +0 -2
- data/lib/mutant/meta/example.rb +0 -2
- data/lib/mutant/meta/example/dsl.rb +1 -1
- data/lib/mutant/mutator.rb +1 -1
- data/lib/mutant/mutator/node.rb +3 -3
- data/lib/mutant/mutator/node/begin.rb +1 -1
- data/lib/mutant/mutator/node/block.rb +16 -3
- data/lib/mutant/mutator/node/if.rb +1 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/send.rb +17 -7
- data/lib/mutant/mutator/node/send/index.rb +0 -2
- data/lib/mutant/mutator/registry.rb +1 -1
- data/lib/mutant/mutator/util.rb +1 -1
- data/lib/mutant/mutator/util/array.rb +1 -1
- data/lib/mutant/reporter.rb +13 -3
- data/lib/mutant/reporter/cli.rb +54 -8
- data/lib/mutant/reporter/cli/format.rb +197 -0
- data/lib/mutant/reporter/cli/printer.rb +402 -22
- data/lib/mutant/reporter/cli/tput.rb +27 -0
- data/lib/mutant/reporter/null.rb +4 -34
- data/lib/mutant/reporter/trace.rb +6 -38
- data/lib/mutant/result.rb +44 -56
- data/lib/mutant/runner.rb +99 -52
- data/lib/mutant/runner/collector.rb +134 -0
- data/lib/mutant/subject/method/instance.rb +12 -4
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_filter.rb +0 -2
- data/lib/mutant/zombifier/file.rb +1 -1
- data/meta/block.rb +17 -1
- data/meta/send.rb +123 -1
- data/mutant-rspec.gemspec +3 -3
- data/mutant.gemspec +1 -1
- data/spec/integration/mutant/corpus_spec.rb +4 -195
- data/spec/integration/mutant/null_spec.rb +1 -3
- data/spec/integration/mutant/rspec_spec.rb +1 -3
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -3
- data/spec/integration/mutant/zombie_spec.rb +1 -3
- data/spec/integrations.yml +7 -0
- data/spec/shared/method_matcher_behavior.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/compress_helper.rb +1 -0
- data/spec/support/corpus.rb +239 -0
- data/spec/support/mutation_verifier.rb +2 -4
- data/spec/unit/mutant/cli_spec.rb +20 -13
- data/spec/unit/mutant/context/root_spec.rb +1 -3
- data/spec/unit/mutant/context/scope/root_spec.rb +1 -3
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -3
- data/spec/unit/mutant/diff_spec.rb +37 -19
- data/spec/unit/mutant/expression/method_spec.rb +5 -7
- data/spec/unit/mutant/expression/methods_spec.rb +5 -7
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +6 -8
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +6 -7
- data/spec/unit/mutant/expression_spec.rb +14 -5
- data/spec/unit/mutant/integration_spec.rb +14 -3
- data/spec/unit/mutant/isolation_spec.rb +2 -4
- data/spec/unit/mutant/loader/eval_spec.rb +1 -3
- data/spec/unit/mutant/matcher/chain_spec.rb +1 -3
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +21 -0
- data/spec/unit/mutant/matcher/compiler_spec.rb +28 -3
- data/spec/unit/mutant/matcher/filter_spec.rb +1 -3
- data/spec/unit/mutant/matcher/method/instance_spec.rb +3 -5
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +22 -4
- data/spec/unit/mutant/matcher/methods/instance_spec.rb +7 -6
- data/spec/unit/mutant/matcher/methods/singleton_spec.rb +4 -6
- data/spec/unit/mutant/matcher/namespace_spec.rb +1 -3
- data/spec/unit/mutant/matcher/null_spec.rb +1 -3
- data/spec/unit/mutant/mutation_spec.rb +1 -3
- data/spec/unit/mutant/mutator/node_spec.rb +1 -3
- data/spec/unit/mutant/reporter/cli_spec.rb +444 -206
- data/spec/unit/mutant/reporter/null_spec.rb +1 -3
- data/spec/unit/mutant/require_highjack_spec.rb +1 -3
- data/spec/unit/mutant/runner_spec.rb +42 -28
- data/spec/unit/mutant/subject/context_spec.rb +1 -3
- data/spec/unit/mutant/subject/method/instance_spec.rb +27 -19
- data/spec/unit/mutant/subject/method/singleton_spec.rb +49 -17
- data/spec/unit/mutant/subject_spec.rb +1 -3
- data/spec/unit/mutant/test_spec.rb +1 -3
- data/spec/unit/mutant/warning_expectation.rb +1 -3
- data/spec/unit/mutant/warning_filter_spec.rb +1 -3
- data/spec/unit/mutant_spec.rb +13 -3
- data/test_app/Gemfile.devtools +2 -2
- data/test_app/spec/unit/test_app/literal/string_spec.rb +1 -1
- metadata +10 -21
- data/lib/mutant/matcher/method/finder.rb +0 -72
- data/lib/mutant/reporter/cli/progress.rb +0 -10
- data/lib/mutant/reporter/cli/progress/config.rb +0 -30
- data/lib/mutant/reporter/cli/progress/env.rb +0 -30
- data/lib/mutant/reporter/cli/progress/noop.rb +0 -27
- data/lib/mutant/reporter/cli/progress/result.rb +0 -12
- data/lib/mutant/reporter/cli/progress/result/mutation.rb +0 -45
- data/lib/mutant/reporter/cli/progress/result/subject.rb +0 -54
- data/lib/mutant/reporter/cli/progress/subject.rb +0 -27
- data/lib/mutant/reporter/cli/registry.rb +0 -81
- data/lib/mutant/reporter/cli/report.rb +0 -10
- data/lib/mutant/reporter/cli/report/env.rb +0 -92
- data/lib/mutant/reporter/cli/report/mutation.rb +0 -103
- data/lib/mutant/reporter/cli/report/subject.rb +0 -32
- data/lib/mutant/reporter/cli/report/test.rb +0 -28
- data/lib/mutant/walker.rb +0 -53
- data/spec/shared/mutator_behavior.rb +0 -55
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Diff do
|
|
1
|
+
RSpec.describe Mutant::Diff do
|
|
4
2
|
let(:object) { described_class }
|
|
5
3
|
|
|
6
4
|
describe '.build' do
|
|
@@ -14,27 +12,27 @@ describe Mutant::Diff do
|
|
|
14
12
|
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
describe '
|
|
18
|
-
let(:object) { described_class }
|
|
19
|
-
|
|
20
|
-
subject { object.colorize_line(line) }
|
|
21
|
-
|
|
22
|
-
context 'line beginning with "+"' do
|
|
23
|
-
let(:line) { '+line' }
|
|
15
|
+
describe '#colorized_diff' do
|
|
16
|
+
let(:object) { described_class.new(old, new) }
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
end
|
|
18
|
+
subject { object.colorized_diff }
|
|
27
19
|
|
|
28
|
-
context '
|
|
29
|
-
let(:
|
|
20
|
+
context 'when there is a diff at begin of hunk' do
|
|
21
|
+
let(:old) { %w[foo bar] }
|
|
22
|
+
let(:new) { %w[baz bar] }
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
let(:expectation) do
|
|
25
|
+
[
|
|
26
|
+
"@@ -1,3 +1,3 @@\n",
|
|
27
|
+
Mutant::Color::RED.format("-foo\n"),
|
|
28
|
+
Mutant::Color::GREEN.format("+baz\n"),
|
|
29
|
+
" bar\n"
|
|
30
|
+
].join
|
|
31
|
+
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
let(:line) { ' line' }
|
|
33
|
+
it { should eql(expectation) }
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
it_should_behave_like 'an idempotent method'
|
|
38
36
|
end
|
|
39
37
|
end
|
|
40
38
|
|
|
@@ -43,6 +41,26 @@ describe Mutant::Diff do
|
|
|
43
41
|
|
|
44
42
|
subject { object.diff }
|
|
45
43
|
|
|
44
|
+
context 'when there is a diff at begin and end' do
|
|
45
|
+
let(:old) { %w[foo bar foo] }
|
|
46
|
+
let(:new) { %w[baz bar baz] }
|
|
47
|
+
|
|
48
|
+
let(:expectation) do
|
|
49
|
+
strip_indent(<<-STR)
|
|
50
|
+
@@ -1,4 +1,4 @@
|
|
51
|
+
-foo
|
|
52
|
+
+baz
|
|
53
|
+
bar
|
|
54
|
+
-foo
|
|
55
|
+
+baz
|
|
56
|
+
STR
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it { should eql(expectation) }
|
|
60
|
+
|
|
61
|
+
it_should_behave_like 'an idempotent method'
|
|
62
|
+
end
|
|
63
|
+
|
|
46
64
|
context 'when there is a diff at begin of hunk' do
|
|
47
65
|
let(:old) { %w[foo bar] }
|
|
48
66
|
let(:new) { %w[baz bar] }
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Expression::Method do
|
|
1
|
+
RSpec.describe Mutant::Expression::Method do
|
|
4
2
|
|
|
5
3
|
let(:object) { described_class.parse(input) }
|
|
6
|
-
let(:
|
|
4
|
+
let(:env) { Fixtures::TEST_ENV }
|
|
7
5
|
let(:instance_method) { 'TestApp::Literal#string' }
|
|
8
6
|
let(:singleton_method) { 'TestApp::Literal.string' }
|
|
9
7
|
|
|
@@ -26,14 +24,14 @@ describe Mutant::Expression::Method do
|
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
describe '#matcher' do
|
|
29
|
-
subject { object.matcher(
|
|
27
|
+
subject { object.matcher(env) }
|
|
30
28
|
|
|
31
29
|
context 'with an instance method' do
|
|
32
30
|
let(:input) { instance_method }
|
|
33
31
|
|
|
34
32
|
it 'returns correct matcher' do
|
|
35
33
|
should eql(Mutant::Matcher::Method::Instance.new(
|
|
36
|
-
|
|
34
|
+
env,
|
|
37
35
|
TestApp::Literal, TestApp::Literal.instance_method(:string)
|
|
38
36
|
))
|
|
39
37
|
end
|
|
@@ -42,7 +40,7 @@ describe Mutant::Expression::Method do
|
|
|
42
40
|
context 'with a singleton method' do
|
|
43
41
|
let(:input) { singleton_method }
|
|
44
42
|
|
|
45
|
-
it { should eql(Mutant::Matcher::Method::Singleton.new(
|
|
43
|
+
it { should eql(Mutant::Matcher::Method::Singleton.new(env, TestApp::Literal, TestApp::Literal.method(:string))) }
|
|
46
44
|
end
|
|
47
45
|
end
|
|
48
46
|
end
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Expression::Methods do
|
|
1
|
+
RSpec.describe Mutant::Expression::Methods do
|
|
4
2
|
|
|
5
3
|
let(:object) { described_class.parse(input) }
|
|
6
|
-
let(:
|
|
4
|
+
let(:env) { Fixtures::TEST_ENV }
|
|
7
5
|
let(:instance_methods) { 'TestApp::Literal#' }
|
|
8
6
|
let(:singleton_methods) { 'TestApp::Literal.' }
|
|
9
7
|
|
|
@@ -26,18 +24,18 @@ describe Mutant::Expression::Methods do
|
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
describe '#matcher' do
|
|
29
|
-
subject { object.matcher(
|
|
27
|
+
subject { object.matcher(env) }
|
|
30
28
|
|
|
31
29
|
context 'with an instance method' do
|
|
32
30
|
let(:input) { instance_methods }
|
|
33
31
|
|
|
34
|
-
it { should eql(Mutant::Matcher::Methods::Instance.new(
|
|
32
|
+
it { should eql(Mutant::Matcher::Methods::Instance.new(env, TestApp::Literal)) }
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
context 'with a singleton method' do
|
|
38
36
|
let(:input) { singleton_methods }
|
|
39
37
|
|
|
40
|
-
it { should eql(Mutant::Matcher::Methods::Singleton.new(
|
|
38
|
+
it { should eql(Mutant::Matcher::Methods::Singleton.new(env, TestApp::Literal)) }
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
41
|
end
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
RSpec.describe Mutant::Expression::Namespace::Exact do
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let(:
|
|
6
|
-
let(:cache) { Mutant::Cache.new }
|
|
7
|
-
let(:input) { 'TestApp::Literal' }
|
|
3
|
+
let(:object) { described_class.parse(input) }
|
|
4
|
+
let(:env) { Fixtures::TEST_ENV }
|
|
5
|
+
let(:input) { 'TestApp::Literal' }
|
|
8
6
|
|
|
9
7
|
describe '#matcher' do
|
|
10
|
-
subject { object.matcher(
|
|
8
|
+
subject { object.matcher(env) }
|
|
11
9
|
|
|
12
|
-
it { should eql(Mutant::Matcher::Scope.new(
|
|
10
|
+
it { should eql(Mutant::Matcher::Scope.new(env, TestApp::Literal, object)) }
|
|
13
11
|
end
|
|
14
12
|
|
|
15
13
|
describe '#match_length' do
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Expression::Namespace::Recursive do
|
|
1
|
+
RSpec.describe Mutant::Expression::Namespace::Recursive do
|
|
4
2
|
|
|
5
3
|
let(:object) { described_class.parse(input) }
|
|
6
|
-
let(:
|
|
7
|
-
let(:
|
|
4
|
+
let(:input) { 'TestApp::Literal*' }
|
|
5
|
+
let(:env) { Fixtures::TEST_ENV }
|
|
8
6
|
|
|
9
7
|
describe '#matcher' do
|
|
10
|
-
subject { object.matcher(
|
|
11
|
-
|
|
8
|
+
subject { object.matcher(env) }
|
|
9
|
+
|
|
10
|
+
it { should eql(Mutant::Matcher::Namespace.new(env, object)) }
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
describe '#match_length' do
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Expression do
|
|
1
|
+
RSpec.describe Mutant::Expression do
|
|
4
2
|
let(:object) { described_class }
|
|
5
3
|
|
|
6
4
|
describe '.try_parse' do
|
|
@@ -18,7 +16,7 @@ describe Mutant::Expression do
|
|
|
18
16
|
it { should eql(Mutant::Expression::Namespace::Exact.new('Foo')) }
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
context 'on
|
|
19
|
+
context 'on ambiguous expression' do
|
|
22
20
|
class ExpressionA < Mutant::Expression
|
|
23
21
|
register(/\Atest-syntax\z/)
|
|
24
22
|
end
|
|
@@ -30,11 +28,22 @@ describe Mutant::Expression do
|
|
|
30
28
|
let(:input) { 'test-syntax' }
|
|
31
29
|
|
|
32
30
|
it 'raises an exception' do
|
|
33
|
-
expect { subject }.to raise_error(
|
|
31
|
+
expect { subject }.to raise_error(
|
|
32
|
+
Mutant::Expression::AmbiguousExpressionError,
|
|
33
|
+
'Ambiguous expression: "test-syntax"'
|
|
34
|
+
)
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
end
|
|
37
38
|
|
|
39
|
+
describe '#inspect' do
|
|
40
|
+
let(:object) { described_class.parse('Foo') }
|
|
41
|
+
subject { object.inspect }
|
|
42
|
+
|
|
43
|
+
it { should eql('<Mutant::Expression: Foo>') }
|
|
44
|
+
it_should_behave_like 'an idempotent method'
|
|
45
|
+
end
|
|
46
|
+
|
|
38
47
|
describe '.parse' do
|
|
39
48
|
subject { object.parse(input) }
|
|
40
49
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Integration do
|
|
1
|
+
RSpec.describe Mutant::Integration do
|
|
4
2
|
|
|
5
3
|
let(:class_under_test) do
|
|
6
4
|
Class.new(described_class)
|
|
@@ -13,3 +11,16 @@ describe Mutant::Integration do
|
|
|
13
11
|
it_should_behave_like 'a command method'
|
|
14
12
|
end
|
|
15
13
|
end
|
|
14
|
+
|
|
15
|
+
RSpec.describe Mutant::Integration::Null do
|
|
16
|
+
|
|
17
|
+
let(:object) { described_class.new }
|
|
18
|
+
|
|
19
|
+
describe '#setup' do
|
|
20
|
+
subject { object.all_tests }
|
|
21
|
+
|
|
22
|
+
it { should eql([]) }
|
|
23
|
+
|
|
24
|
+
it_should_behave_like 'an idempotent method'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Isolation::None do
|
|
1
|
+
RSpec.describe Mutant::Isolation::None do
|
|
4
2
|
before do
|
|
5
3
|
@initial = 1
|
|
6
4
|
end
|
|
@@ -24,7 +22,7 @@ describe Mutant::Isolation::None do
|
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
describe Mutant::Isolation::Fork do
|
|
25
|
+
RSpec.describe Mutant::Isolation::Fork do
|
|
28
26
|
before do
|
|
29
27
|
@initial = 1
|
|
30
28
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
RSpec.describe Mutant::Matcher::Compiler::SubjectPrefix do
|
|
2
|
+
let(:object) { described_class.new(Mutant::Expression.parse('Foo*')) }
|
|
3
|
+
|
|
4
|
+
let(:_subject) { double('Subject', expression: Mutant::Expression.parse(subject_expression)) }
|
|
5
|
+
|
|
6
|
+
describe '#call' do
|
|
7
|
+
subject { object.call(_subject) }
|
|
8
|
+
|
|
9
|
+
context 'when subject expression is prefixed by expression' do
|
|
10
|
+
let(:subject_expression) { 'Foo::Bar' }
|
|
11
|
+
|
|
12
|
+
it { should be(true) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'when subject expression is NOT prefixed by expression' do
|
|
16
|
+
let(:subject_expression) { 'Bar' }
|
|
17
|
+
|
|
18
|
+
it { should be(false) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Matcher::Compiler do
|
|
1
|
+
RSpec.describe Mutant::Matcher::Compiler do
|
|
4
2
|
let(:object) { described_class }
|
|
5
3
|
|
|
6
4
|
let(:env) { Fixtures::TEST_ENV }
|
|
@@ -82,6 +80,33 @@ describe Mutant::Matcher::Compiler do
|
|
|
82
80
|
|
|
83
81
|
it { should eql(expected_matcher) }
|
|
84
82
|
end
|
|
83
|
+
|
|
84
|
+
context 'and subject and attribute filter' do
|
|
85
|
+
let(:attributes) do
|
|
86
|
+
{
|
|
87
|
+
match_expressions: [expression_a],
|
|
88
|
+
subject_ignores: [expression_b],
|
|
89
|
+
subject_selects: [[:code, 'foo']]
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) }
|
|
94
|
+
|
|
95
|
+
let(:expected_predicate) do
|
|
96
|
+
Morpher::Evaluator::Predicate::Boolean::And.new([
|
|
97
|
+
Morpher::Evaluator::Predicate::Boolean::Or.new([
|
|
98
|
+
Morpher.compile(s(:eql, s(:attribute, :code), s(:static, 'foo')))
|
|
99
|
+
]),
|
|
100
|
+
Morpher::Evaluator::Predicate::Negation.new(
|
|
101
|
+
Morpher::Evaluator::Predicate::Boolean::Or.new([
|
|
102
|
+
described_class::SubjectPrefix.new(expression_b)
|
|
103
|
+
])
|
|
104
|
+
)
|
|
105
|
+
])
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it { should eql(expected_matcher) }
|
|
109
|
+
end
|
|
85
110
|
end
|
|
86
111
|
|
|
87
112
|
context 'on config with multiple match expressions' do
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
1
|
# rubocop:disable ClassAndModuleChildren
|
|
4
|
-
describe Mutant::Matcher::Method::Instance do
|
|
2
|
+
RSpec.describe Mutant::Matcher::Method::Instance do
|
|
5
3
|
|
|
6
4
|
let(:env) { Fixtures::TEST_ENV }
|
|
7
5
|
let(:reporter) { Fixtures::TEST_CONFIG.reporter }
|
|
@@ -68,7 +66,7 @@ describe Mutant::Matcher::Method::Instance do
|
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
context 'when method is defined multiple times' do
|
|
71
|
-
context 'on
|
|
69
|
+
context 'on different lines' do
|
|
72
70
|
let(:base) { __LINE__ }
|
|
73
71
|
class self::Foo
|
|
74
72
|
def bar
|
|
@@ -96,7 +94,7 @@ describe Mutant::Matcher::Method::Instance do
|
|
|
96
94
|
it_should_behave_like 'a method matcher'
|
|
97
95
|
end
|
|
98
96
|
|
|
99
|
-
context 'on the same line with
|
|
97
|
+
context 'on the same line with different scope' do
|
|
100
98
|
let(:base) { __LINE__ }
|
|
101
99
|
class self::Foo
|
|
102
100
|
def self.bar; end; def bar(_arg); end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
1
|
# rubocop:disable ClassAndModuleChildren
|
|
4
|
-
describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
2
|
+
RSpec.describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
5
3
|
subject { object.each { |subject| yields << subject } }
|
|
6
4
|
|
|
7
5
|
let(:object) { described_class.new(env, scope, method) }
|
|
@@ -23,6 +21,26 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
|
23
21
|
|
|
24
22
|
context 'on singleton methods' do
|
|
25
23
|
|
|
24
|
+
context 'when also defined on lvar' do
|
|
25
|
+
let(:base) { __LINE__ }
|
|
26
|
+
class self::Foo
|
|
27
|
+
a = Object.new
|
|
28
|
+
def a.bar; end; def self.bar; end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
let(:method_name) { :bar }
|
|
32
|
+
let(:method_line) { 3 }
|
|
33
|
+
|
|
34
|
+
it_should_behave_like 'a method matcher'
|
|
35
|
+
|
|
36
|
+
it 'warns about definition on non const/self' do
|
|
37
|
+
subject
|
|
38
|
+
expect(env.config.reporter.warn_calls).to(
|
|
39
|
+
include('Can only match :defs on :self or :const got :lvar unable to match')
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
26
44
|
context 'when defined on self' do
|
|
27
45
|
let(:base) { __LINE__ }
|
|
28
46
|
class self::Foo
|
|
@@ -72,7 +90,7 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
|
|
|
72
90
|
end
|
|
73
91
|
|
|
74
92
|
context 'when defined multiple times in the same line' do
|
|
75
|
-
context 'with method on
|
|
93
|
+
context 'with method on different scope' do
|
|
76
94
|
let(:base) { __LINE__ }
|
|
77
95
|
module self::Namespace
|
|
78
96
|
module Foo; end
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Mutant::Matcher::Methods::Instance, '#each' do
|
|
1
|
+
RSpec.describe Mutant::Matcher::Methods::Instance, '#each' do
|
|
4
2
|
let(:object) { described_class.new(env, Foo) }
|
|
5
3
|
let(:env) { Fixtures::TEST_ENV }
|
|
6
4
|
|
|
@@ -46,9 +44,12 @@ describe Mutant::Matcher::Methods::Instance, '#each' do
|
|
|
46
44
|
|
|
47
45
|
before do
|
|
48
46
|
matcher = Mutant::Matcher::Method::Instance
|
|
49
|
-
allow(matcher).to receive(:new)
|
|
50
|
-
|
|
51
|
-
allow(matcher).to receive(:new)
|
|
47
|
+
allow(matcher).to receive(:new)
|
|
48
|
+
.with(env, Foo, Foo.instance_method(:method_a)).and_return([subject_a])
|
|
49
|
+
allow(matcher).to receive(:new)
|
|
50
|
+
.with(env, Foo, Foo.instance_method(:method_b)).and_return([subject_b])
|
|
51
|
+
allow(matcher).to receive(:new)
|
|
52
|
+
.with(env, Foo, Foo.instance_method(:method_c)).and_return([subject_c])
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
it 'should yield expected subjects' do
|