mutant 0.3.0.beta22 → 0.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -5
- data/Gemfile.devtools +1 -1
- data/README.md +22 -50
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +9 -2
- data/lib/mutant.rb +3 -4
- data/lib/mutant/cli.rb +41 -35
- data/lib/mutant/cli/classifier.rb +1 -1
- data/lib/mutant/config.rb +2 -1
- data/lib/mutant/context/scope.rb +14 -1
- data/lib/mutant/killer.rb +10 -0
- data/lib/mutant/killer/rspec.rb +52 -18
- data/lib/mutant/matcher/method.rb +4 -4
- data/lib/mutant/mutator/node/generic.rb +1 -1
- data/lib/mutant/mutator/node/literal/float.rb +2 -0
- data/lib/mutant/mutator/node/nthref.rb +29 -0
- data/lib/mutant/mutator/node/send.rb +17 -0
- data/lib/mutant/reporter/cli/printer/killer.rb +9 -3
- data/lib/mutant/strategy.rb +9 -9
- data/lib/mutant/strategy/rspec.rb +51 -41
- data/lib/mutant/subject.rb +16 -6
- data/lib/mutant/subject/method.rb +10 -10
- data/lib/mutant/version.rb +7 -0
- data/lib/mutant/zombifier.rb +2 -3
- data/mutant.gemspec +6 -4
- data/spec/integration/mutant/rspec_spec.rb +26 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +33 -8
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +4 -0
- data/spec/unit/mutant/mutator/node/nthref/mutation_spec.rb +19 -0
- data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +29 -0
- metadata +14 -20
- data/lib/mutant/strategy/method_expansion.rb +0 -53
- data/lib/mutant/strategy/rspec/dm2.rb +0 -24
- data/lib/mutant/strategy/rspec/dm2/lookup.rb +0 -63
- data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +0 -145
- data/spec/integration/mutant/rspec_killer_spec.rb +0 -29
- data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +0 -51
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +0 -73
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +0 -62
@@ -29,7 +29,7 @@ describe Mutant::CLI, '.new' do
|
|
29
29
|
|
30
30
|
# Defaults
|
31
31
|
let(:expected_filter) { Mutant::Mutation::Filter::ALL }
|
32
|
-
let(:expected_strategy) { Mutant::Strategy::Rspec
|
32
|
+
let(:expected_strategy) { Mutant::Strategy::Rspec.new }
|
33
33
|
let(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
|
34
34
|
|
35
35
|
let(:ns) { Mutant::CLI::Classifier }
|
@@ -56,9 +56,10 @@ describe Mutant::CLI, '.new' do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'with many strategy flags' do
|
59
|
-
let(:arguments) { %w(--
|
59
|
+
let(:arguments) { %w(--static-fail --rspec TestApp) }
|
60
|
+
let(:expected_matcher) { Mutant::CLI::Classifier::Namespace::Flat.new(Mutant::Cache.new, 'TestApp') }
|
60
61
|
|
61
|
-
|
62
|
+
it_should_behave_like 'a cli parser'
|
62
63
|
end
|
63
64
|
|
64
65
|
context 'without arguments' do
|
@@ -70,30 +71,54 @@ describe Mutant::CLI, '.new' do
|
|
70
71
|
end
|
71
72
|
|
72
73
|
context 'with code filter and missing argument' do
|
73
|
-
let(:arguments) { %w(--rspec
|
74
|
+
let(:arguments) { %w(--rspec --code) }
|
74
75
|
let(:expected_message) { 'missing argument: --code' }
|
75
76
|
|
76
77
|
it_should_behave_like 'an invalid cli run'
|
77
78
|
end
|
78
79
|
|
79
80
|
context 'with explicit method matcher' do
|
80
|
-
let(:arguments) { %w(--rspec
|
81
|
+
let(:arguments) { %w(--rspec TestApp::Literal#float) }
|
81
82
|
let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
|
82
83
|
|
83
84
|
it_should_behave_like 'a cli parser'
|
84
85
|
end
|
85
86
|
|
87
|
+
context 'with debug flag' do
|
88
|
+
let(:matcher) { '::TestApp*' }
|
89
|
+
let(:arguments) { %W(--debug --rspec #{matcher}) }
|
90
|
+
let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
|
91
|
+
|
92
|
+
it_should_behave_like 'a cli parser'
|
93
|
+
|
94
|
+
it 'should set the debug option' do
|
95
|
+
subject.config.debug.should be(true)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'with zombie flag' do
|
100
|
+
let(:matcher) { '::TestApp*' }
|
101
|
+
let(:arguments) { %W(--zombie --rspec #{matcher}) }
|
102
|
+
let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
|
103
|
+
|
104
|
+
it_should_behave_like 'a cli parser'
|
105
|
+
|
106
|
+
it 'should set the zombie option' do
|
107
|
+
subject.config.zombie.should be(true)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
86
111
|
context 'with namespace matcher' do
|
87
112
|
let(:matcher) { '::TestApp*' }
|
88
|
-
let(:arguments) { %W(--rspec
|
113
|
+
let(:arguments) { %W(--rspec #{matcher}) }
|
89
114
|
let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
|
90
115
|
|
91
116
|
it_should_behave_like 'a cli parser'
|
92
117
|
end
|
93
118
|
|
94
119
|
context 'with code filter' do
|
95
|
-
let(:matcher) { 'TestApp::Literal#float'
|
96
|
-
let(:arguments) { %W(--rspec
|
120
|
+
let(:matcher) { 'TestApp::Literal#float' }
|
121
|
+
let(:arguments) { %W(--rspec --code faa --code bbb #{matcher}) }
|
97
122
|
|
98
123
|
let(:filters) do
|
99
124
|
[
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Mutant::Mutator, 'nthref' do
|
6
|
+
context '$1' do
|
7
|
+
let(:source) { '$1' }
|
8
|
+
let(:mutations) { ['$2', '$0'] }
|
9
|
+
|
10
|
+
it_should_behave_like 'a mutator'
|
11
|
+
end
|
12
|
+
|
13
|
+
context '$2' do
|
14
|
+
let(:source) { '$2' }
|
15
|
+
let(:mutations) { ['$3', '$1'] }
|
16
|
+
|
17
|
+
it_should_behave_like 'a mutator'
|
18
|
+
end
|
19
|
+
end
|
@@ -5,6 +5,35 @@ require 'spec_helper'
|
|
5
5
|
# FIXME: This spec needs to be structured better!
|
6
6
|
describe Mutant::Mutator, 'send' do
|
7
7
|
|
8
|
+
context 'when using String#gsub' do
|
9
|
+
let(:source) { 'foo.gsub(a, b)' }
|
10
|
+
|
11
|
+
let(:mutations) do
|
12
|
+
mutations = []
|
13
|
+
mutations << 'foo'
|
14
|
+
mutations << 'foo.gsub(a)'
|
15
|
+
mutations << 'foo.gsub(b)'
|
16
|
+
mutations << 'foo.gsub'
|
17
|
+
mutations << 'foo.sub(a, b)'
|
18
|
+
end
|
19
|
+
|
20
|
+
it_should_behave_like 'a mutator'
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when using Kernel#send' do
|
24
|
+
let(:source) { 'foo.send(bar)' }
|
25
|
+
|
26
|
+
let(:mutations) do
|
27
|
+
mutations = []
|
28
|
+
mutations << 'foo.send'
|
29
|
+
mutations << 'foo.public_send(bar)'
|
30
|
+
mutations << 'bar'
|
31
|
+
mutations << 'foo'
|
32
|
+
end
|
33
|
+
|
34
|
+
it_should_behave_like 'a mutator'
|
35
|
+
end
|
36
|
+
|
8
37
|
context 'inside op assign' do
|
9
38
|
let(:source) { 'self.foo ||= expression' }
|
10
39
|
|
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.
|
4
|
+
version: 0.3.0.rc1
|
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-
|
11
|
+
date: 2013-08-05 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.0.
|
19
|
+
version: 2.0.0.pre6
|
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.0.
|
26
|
+
version: 2.0.0.pre6
|
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.
|
33
|
+
version: 0.0.14
|
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.
|
40
|
+
version: 0.0.14
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ice_nine
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.1.
|
131
|
+
version: 0.1.3
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.1.
|
138
|
+
version: 0.1.3
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- lib/mutant/mutator/node/named_value/constant_assignment.rb
|
267
267
|
- lib/mutant/mutator/node/named_value/variable_assignment.rb
|
268
268
|
- lib/mutant/mutator/node/noop.rb
|
269
|
+
- lib/mutant/mutator/node/nthref.rb
|
269
270
|
- lib/mutant/mutator/node/return.rb
|
270
271
|
- lib/mutant/mutator/node/send.rb
|
271
272
|
- lib/mutant/mutator/node/send/binary.rb
|
@@ -294,20 +295,17 @@ files:
|
|
294
295
|
- lib/mutant/runner/subject.rb
|
295
296
|
- lib/mutant/singleton_methods.rb
|
296
297
|
- lib/mutant/strategy.rb
|
297
|
-
- lib/mutant/strategy/method_expansion.rb
|
298
298
|
- lib/mutant/strategy/rspec.rb
|
299
|
-
- lib/mutant/strategy/rspec/dm2.rb
|
300
|
-
- lib/mutant/strategy/rspec/dm2/lookup.rb
|
301
|
-
- lib/mutant/strategy/rspec/dm2/lookup/method.rb
|
302
299
|
- lib/mutant/strategy/static.rb
|
303
300
|
- lib/mutant/subject.rb
|
304
301
|
- lib/mutant/subject/method.rb
|
305
302
|
- lib/mutant/subject/method/instance.rb
|
306
303
|
- lib/mutant/subject/method/singleton.rb
|
307
304
|
- lib/mutant/support/method_object.rb
|
305
|
+
- lib/mutant/version.rb
|
308
306
|
- lib/mutant/zombifier.rb
|
309
307
|
- mutant.gemspec
|
310
|
-
- spec/integration/mutant/
|
308
|
+
- spec/integration/mutant/rspec_spec.rb
|
311
309
|
- spec/integration/mutant/test_mutator_handles_types_spec.rb
|
312
310
|
- spec/integration/mutant/zombie_spec.rb
|
313
311
|
- spec/rcov.opts
|
@@ -378,6 +376,7 @@ files:
|
|
378
376
|
- spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
|
379
377
|
- spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
|
380
378
|
- spec/unit/mutant/mutator/node/next/mutation_spec.rb
|
379
|
+
- spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
|
381
380
|
- spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb
|
382
381
|
- spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb
|
383
382
|
- spec/unit/mutant/mutator/node/redo/mutation_spec.rb
|
@@ -393,9 +392,6 @@ files:
|
|
393
392
|
- spec/unit/mutant/runner/config/success_predicate_spec.rb
|
394
393
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|
395
394
|
- spec/unit/mutant/runner/subject/success_predicate_spec.rb
|
396
|
-
- spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb
|
397
|
-
- spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb
|
398
|
-
- spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb
|
399
395
|
- spec/unit/mutant/subject/context_spec.rb
|
400
396
|
- spec/unit/mutant/subject/mutations_spec.rb
|
401
397
|
- spec/unit/mutant/subject/node_spec.rb
|
@@ -437,7 +433,7 @@ signing_key:
|
|
437
433
|
specification_version: 4
|
438
434
|
summary: Mutation testing tool for ruby under MRI and Rubinius
|
439
435
|
test_files:
|
440
|
-
- spec/integration/mutant/
|
436
|
+
- spec/integration/mutant/rspec_spec.rb
|
441
437
|
- spec/integration/mutant/test_mutator_handles_types_spec.rb
|
442
438
|
- spec/integration/mutant/zombie_spec.rb
|
443
439
|
- spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb
|
@@ -500,6 +496,7 @@ test_files:
|
|
500
496
|
- spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
|
501
497
|
- spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
|
502
498
|
- spec/unit/mutant/mutator/node/next/mutation_spec.rb
|
499
|
+
- spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
|
503
500
|
- spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb
|
504
501
|
- spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb
|
505
502
|
- spec/unit/mutant/mutator/node/redo/mutation_spec.rb
|
@@ -515,9 +512,6 @@ test_files:
|
|
515
512
|
- spec/unit/mutant/runner/config/success_predicate_spec.rb
|
516
513
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|
517
514
|
- spec/unit/mutant/runner/subject/success_predicate_spec.rb
|
518
|
-
- spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb
|
519
|
-
- spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb
|
520
|
-
- spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb
|
521
515
|
- spec/unit/mutant/subject/context_spec.rb
|
522
516
|
- spec/unit/mutant/subject/mutations_spec.rb
|
523
517
|
- spec/unit/mutant/subject/node_spec.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Strategy
|
5
|
-
module MethodExpansion
|
6
|
-
|
7
|
-
# Run method name expansion
|
8
|
-
#
|
9
|
-
# @param [Symbol] name
|
10
|
-
#
|
11
|
-
# @return [Symbol]
|
12
|
-
#
|
13
|
-
# @api private
|
14
|
-
#
|
15
|
-
def self.run(name)
|
16
|
-
name = map(name) || expand(name)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return mapped name
|
20
|
-
#
|
21
|
-
# @param [Symbol] name
|
22
|
-
#
|
23
|
-
# @return [Symbol]
|
24
|
-
# if name was mapped
|
25
|
-
#
|
26
|
-
# @return [nil]
|
27
|
-
# otherwise
|
28
|
-
#
|
29
|
-
# @api private
|
30
|
-
#
|
31
|
-
def self.map(name)
|
32
|
-
OPERATOR_EXPANSIONS[name]
|
33
|
-
end
|
34
|
-
private_class_method :map
|
35
|
-
|
36
|
-
REGEXP = /#{Regexp.union(*METHOD_POSTFIX_EXPANSIONS.keys)}\z/.freeze
|
37
|
-
|
38
|
-
# Return expanded name
|
39
|
-
#
|
40
|
-
# @param [Symbol] name
|
41
|
-
#
|
42
|
-
# @return [Symbol]
|
43
|
-
#
|
44
|
-
# @api private
|
45
|
-
#
|
46
|
-
def self.expand(name)
|
47
|
-
name.to_s.gsub(REGEXP, METHOD_POSTFIX_EXPANSIONS).to_sym
|
48
|
-
end
|
49
|
-
private_class_method :expand
|
50
|
-
|
51
|
-
end # MethodExpansion
|
52
|
-
end # Strategy
|
53
|
-
end # Mutant
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Strategy
|
5
|
-
class Rspec
|
6
|
-
# DM2-style strategy
|
7
|
-
class DM2 < self
|
8
|
-
|
9
|
-
# Return filename pattern
|
10
|
-
#
|
11
|
-
# @param [Subject] subject
|
12
|
-
#
|
13
|
-
# @return [Enumerable<String>]
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
#
|
17
|
-
def self.spec_files(subject)
|
18
|
-
Lookup.run(subject)
|
19
|
-
end
|
20
|
-
|
21
|
-
end # DM2
|
22
|
-
end # Rspec
|
23
|
-
end # Strategy
|
24
|
-
end # Mutant
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Strategy
|
5
|
-
class Rspec
|
6
|
-
class DM2
|
7
|
-
|
8
|
-
# Example lookup for the rspec dm2
|
9
|
-
class Lookup
|
10
|
-
include AbstractType, Adamantium::Flat, Concord::Public.new(:subject)
|
11
|
-
|
12
|
-
# Return glob expression
|
13
|
-
#
|
14
|
-
# @return [String]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
abstract_method :spec_files
|
19
|
-
|
20
|
-
# Perform example lookup
|
21
|
-
#
|
22
|
-
# @param [Subject] subject
|
23
|
-
#
|
24
|
-
# @return [Enumerable<String>]
|
25
|
-
#
|
26
|
-
# @api private
|
27
|
-
#
|
28
|
-
def self.run(subject)
|
29
|
-
build(subject).spec_files
|
30
|
-
end
|
31
|
-
|
32
|
-
REGISTRY = {}
|
33
|
-
|
34
|
-
# Register subject hander
|
35
|
-
#
|
36
|
-
# @param [Class:Subject]
|
37
|
-
#
|
38
|
-
# @return [undefined]
|
39
|
-
#
|
40
|
-
# @api private
|
41
|
-
#
|
42
|
-
def self.handle(subject_class)
|
43
|
-
REGISTRY[subject_class] = self
|
44
|
-
end
|
45
|
-
private_class_method :handle
|
46
|
-
|
47
|
-
# Build lookup object
|
48
|
-
#
|
49
|
-
# @param [Subject] subject
|
50
|
-
#
|
51
|
-
# @return [Lookup]
|
52
|
-
#
|
53
|
-
# @api private
|
54
|
-
#
|
55
|
-
def self.build(subject)
|
56
|
-
REGISTRY.fetch(subject.class).new(subject)
|
57
|
-
end
|
58
|
-
|
59
|
-
end # Lookup
|
60
|
-
end # DM2
|
61
|
-
end # Rspec
|
62
|
-
end # Strategy
|
63
|
-
end # Mutant
|
@@ -1,145 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Strategy
|
5
|
-
class Rspec
|
6
|
-
class DM2
|
7
|
-
class Lookup
|
8
|
-
|
9
|
-
# Base class for dm2 style method lookup
|
10
|
-
class Method < self
|
11
|
-
|
12
|
-
# Return spec files
|
13
|
-
#
|
14
|
-
# @return [Enumerable<String>]
|
15
|
-
#
|
16
|
-
# @api private
|
17
|
-
#
|
18
|
-
def spec_files
|
19
|
-
Dir.glob(glob_expression)
|
20
|
-
end
|
21
|
-
memoize :spec_files
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
# Return base path
|
26
|
-
#
|
27
|
-
# @return [String]
|
28
|
-
#
|
29
|
-
# @api private
|
30
|
-
#
|
31
|
-
def base_path
|
32
|
-
"spec/unit/#{Inflecto.underscore(subject.context.name)}"
|
33
|
-
end
|
34
|
-
|
35
|
-
# Return method name
|
36
|
-
#
|
37
|
-
# @return [Symbol]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
#
|
41
|
-
def method_name
|
42
|
-
subject.name
|
43
|
-
end
|
44
|
-
|
45
|
-
# Test if method is public
|
46
|
-
#
|
47
|
-
# @return [true]
|
48
|
-
# if method is public
|
49
|
-
#
|
50
|
-
# @return [false]
|
51
|
-
#
|
52
|
-
# @api private
|
53
|
-
#
|
54
|
-
def public?
|
55
|
-
subject.public?
|
56
|
-
end
|
57
|
-
|
58
|
-
# Return expanded name
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
#
|
62
|
-
# @api private
|
63
|
-
#
|
64
|
-
def expanded_name
|
65
|
-
MethodExpansion.run(method_name)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Return glob expression
|
69
|
-
#
|
70
|
-
# @return [String]
|
71
|
-
#
|
72
|
-
# @api private
|
73
|
-
#
|
74
|
-
def glob_expression
|
75
|
-
public? ? public_glob_expression : private_glob_expression
|
76
|
-
end
|
77
|
-
|
78
|
-
# Return public glob expression
|
79
|
-
#
|
80
|
-
# @return [String]
|
81
|
-
#
|
82
|
-
# @api private
|
83
|
-
#
|
84
|
-
def public_glob_expression
|
85
|
-
"#{base_path}/#{expanded_name}_spec.rb"
|
86
|
-
end
|
87
|
-
|
88
|
-
# Return private glob expression
|
89
|
-
#
|
90
|
-
# @return [String]
|
91
|
-
#
|
92
|
-
# @api private
|
93
|
-
#
|
94
|
-
def private_glob_expression
|
95
|
-
"#{base_path}/*_spec.rb"
|
96
|
-
end
|
97
|
-
|
98
|
-
# Instance method dm2 style method lookup
|
99
|
-
class Instance < self
|
100
|
-
handle(Subject::Method::Instance)
|
101
|
-
handle(Subject::Method::Instance::Memoized)
|
102
|
-
|
103
|
-
private
|
104
|
-
|
105
|
-
# Return glob expression
|
106
|
-
#
|
107
|
-
# @return [String]
|
108
|
-
#
|
109
|
-
# @api private
|
110
|
-
#
|
111
|
-
def glob_expression
|
112
|
-
glob_expression = super
|
113
|
-
if method_name == :initialize and !public?
|
114
|
-
"{#{glob_expression},#{base_path}/class_methods/new_spec.rb}"
|
115
|
-
else
|
116
|
-
glob_expression
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end # Instance
|
121
|
-
|
122
|
-
# Singleton method dm2 style method lookup
|
123
|
-
class Singleton < self
|
124
|
-
handle(Subject::Method::Singleton)
|
125
|
-
|
126
|
-
private
|
127
|
-
|
128
|
-
# Return base path
|
129
|
-
#
|
130
|
-
# @return [String]
|
131
|
-
#
|
132
|
-
# @api private
|
133
|
-
#
|
134
|
-
def base_path
|
135
|
-
"#{super}/class_methods"
|
136
|
-
end
|
137
|
-
|
138
|
-
end # Singleton
|
139
|
-
|
140
|
-
end # Method
|
141
|
-
end # Lookup
|
142
|
-
end # DM2
|
143
|
-
end # Rspec
|
144
|
-
end # Strategy
|
145
|
-
end # Mutant
|