reek 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.md +40 -25
- data/Rakefile +2 -15
- data/bin/reek +1 -1
- data/features/{options.feature → command_line_interface/options.feature} +1 -3
- data/features/{stdin.feature → command_line_interface/stdin.feature} +2 -2
- data/features/{masking_smells.feature → configuration_files/masking_smells.feature} +23 -23
- data/features/{rake_task.feature → rake_task/rake_task.feature} +9 -9
- data/features/{reports.feature → reports/reports.feature} +10 -10
- data/features/{yaml.feature → reports/yaml.feature} +2 -2
- data/features/{api.feature → ruby_api/api.feature} +6 -6
- data/features/samples.feature +239 -247
- data/features/step_definitions/reek_steps.rb +15 -1
- data/features/support/env.rb +0 -1
- data/lib/reek.rb +1 -4
- data/lib/reek/cli/command_line.rb +6 -5
- data/lib/reek/cli/report.rb +1 -1
- data/lib/reek/core/hash_extensions.rb +29 -0
- data/lib/reek/core/method_context.rb +3 -16
- data/lib/reek/core/object_refs.rb +5 -22
- data/lib/reek/core/smell_repository.rb +65 -0
- data/lib/reek/core/sniffer.rb +7 -76
- data/lib/reek/core/warning_collector.rb +1 -5
- data/lib/reek/examiner.rb +3 -13
- data/lib/reek/rake/task.rb +10 -2
- data/lib/reek/smell_warning.rb +1 -0
- data/lib/reek/smells/smell_detector.rb +0 -3
- data/lib/reek/smells/uncommunicative_module_name.rb +6 -3
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
- data/lib/reek/source/config_file.rb +8 -2
- data/lib/reek/source/sexp_formatter.rb +1 -1
- data/lib/reek/source/source_repository.rb +31 -0
- data/lib/reek/source/tree_dresser.rb +1 -1
- data/lib/reek/spec/should_reek.rb +5 -2
- data/lib/reek/version.rb +3 -0
- data/lib/xp.reek +63 -0
- data/reek.gemspec +16 -28
- data/spec/gem/manifest_spec.rb +22 -0
- data/spec/gem/updates_spec.rb +26 -0
- data/spec/gem/yard_spec.rb +15 -0
- data/spec/matchers/smell_of_matcher.rb +0 -1
- data/spec/reek/cli/reek_command_spec.rb +1 -1
- data/spec/reek/core/method_context_spec.rb +2 -2
- data/spec/reek/core/object_refs_spec.rb +115 -118
- data/spec/reek/smell_warning_spec.rb +2 -2
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -0
- data/spec/reek/source/sexp_formatter_spec.rb +19 -0
- data/spec/reek/spec/should_reek_spec.rb +21 -3
- data/tasks/deployment.rake +69 -0
- data/tasks/develop.rake +29 -0
- data/tasks/test.rake +1 -6
- metadata +200 -138
@@ -56,15 +56,18 @@ module Reek
|
|
56
56
|
#
|
57
57
|
# @return [Array<SmellWarning>]
|
58
58
|
#
|
59
|
+
# :reek:Duplication { allow_calls: [ to_s ] }
|
59
60
|
def examine_context(ctx)
|
60
61
|
@reject_names = value(REJECT_KEY, ctx, DEFAULT_REJECT_SET)
|
61
62
|
@accept_names = value(ACCEPT_KEY, ctx, DEFAULT_ACCEPT_SET)
|
62
|
-
|
63
|
-
|
63
|
+
exp = ctx.exp
|
64
|
+
full_name = ctx.full_name
|
65
|
+
name = exp.simple_name
|
66
|
+
return [] if @accept_names.include?(full_name)
|
64
67
|
var = name.to_s.gsub(/^[@\*\&]*/, '')
|
65
68
|
return [] if @accept_names.include?(var)
|
66
69
|
return [] unless @reject_names.detect {|patt| patt === var}
|
67
|
-
smell = SmellWarning.new(SMELL_CLASS,
|
70
|
+
smell = SmellWarning.new(SMELL_CLASS, full_name, [exp.line],
|
68
71
|
"has the name '#{name}'",
|
69
72
|
@source, SMELL_SUBCLASS, {MODULE_NAME_KEY => name.to_s})
|
70
73
|
[smell]
|
@@ -50,9 +50,15 @@ module Reek
|
|
50
50
|
def load
|
51
51
|
unless @@bad_config_files.include?(@file_path)
|
52
52
|
begin
|
53
|
-
|
53
|
+
result = YAML.load_file(@file_path) || {}
|
54
|
+
if Hash === result
|
55
|
+
return result
|
56
|
+
else
|
57
|
+
@@bad_config_files << @file_path # poop
|
58
|
+
problem('Not a hash')
|
59
|
+
end
|
54
60
|
rescue Exception => err
|
55
|
-
@@bad_config_files << @file_path
|
61
|
+
@@bad_config_files << @file_path # poop
|
56
62
|
problem(err.to_s)
|
57
63
|
end
|
58
64
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'source')
|
2
|
+
|
3
|
+
module Reek
|
4
|
+
module Source
|
5
|
+
class SourceRepository
|
6
|
+
def self.parse source
|
7
|
+
case source
|
8
|
+
when Array
|
9
|
+
new 'dir', Source::SourceLocator.new(source).all_sources
|
10
|
+
when Source::SourceCode
|
11
|
+
new source.desc, [source]
|
12
|
+
else
|
13
|
+
src = source.to_reek_source
|
14
|
+
new src.desc, [src]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
include Enumerable
|
19
|
+
attr_reader :description
|
20
|
+
|
21
|
+
def initialize description, sources
|
22
|
+
@description = description
|
23
|
+
@sources = sources
|
24
|
+
end
|
25
|
+
|
26
|
+
def each &block
|
27
|
+
@sources.each &block
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -8,8 +8,11 @@ module Reek
|
|
8
8
|
# An rspec matcher that matches when the +actual+ has code smells.
|
9
9
|
#
|
10
10
|
class ShouldReek # :nodoc:
|
11
|
+
def initialize(config_files = [])
|
12
|
+
@config_files = config_files
|
13
|
+
end
|
11
14
|
def matches?(actual)
|
12
|
-
@examiner = Examiner.new(actual)
|
15
|
+
@examiner = Examiner.new(actual, @config_files)
|
13
16
|
@examiner.smelly?
|
14
17
|
end
|
15
18
|
def failure_message_for_should
|
@@ -25,7 +28,7 @@ module Reek
|
|
25
28
|
# Returns +true+ if and only if the target source code contains smells.
|
26
29
|
#
|
27
30
|
def reek
|
28
|
-
ShouldReek.new
|
31
|
+
ShouldReek.new(Dir['config/*.reek'])
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
data/lib/reek/version.rb
ADDED
data/lib/xp.reek
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
LargeClass:
|
3
|
+
max_methods: 25
|
4
|
+
exclude: []
|
5
|
+
enabled: true
|
6
|
+
max_instance_variables: 9
|
7
|
+
LongParameterList:
|
8
|
+
max_params: 3
|
9
|
+
exclude: []
|
10
|
+
enabled: true
|
11
|
+
overrides:
|
12
|
+
initialize:
|
13
|
+
max_params: 5
|
14
|
+
FeatureEnvy:
|
15
|
+
exclude:
|
16
|
+
- initialize
|
17
|
+
enabled: false
|
18
|
+
ClassVariable:
|
19
|
+
exclude: &id001 []
|
20
|
+
enabled: true
|
21
|
+
UncommunicativeVariableName:
|
22
|
+
accept:
|
23
|
+
- Inline::C
|
24
|
+
exclude: []
|
25
|
+
enabled: true
|
26
|
+
reject:
|
27
|
+
- !ruby/regexp /^.$/
|
28
|
+
- !ruby/regexp /[0-9]$/
|
29
|
+
NestedIterators:
|
30
|
+
exclude: *id001
|
31
|
+
enabled: false
|
32
|
+
LongMethod:
|
33
|
+
max_statements: 5
|
34
|
+
exclude:
|
35
|
+
- initialize
|
36
|
+
enabled: false
|
37
|
+
Duplication:
|
38
|
+
exclude: []
|
39
|
+
enabled: true
|
40
|
+
max_calls: 1
|
41
|
+
UtilityFunction:
|
42
|
+
max_helper_calls: 1
|
43
|
+
exclude: []
|
44
|
+
enabled: false
|
45
|
+
Attribute:
|
46
|
+
exclude: []
|
47
|
+
enabled: true
|
48
|
+
SimulatedPolymorphism:
|
49
|
+
exclude: []
|
50
|
+
enabled: true
|
51
|
+
max_ifs: 2
|
52
|
+
DataClump:
|
53
|
+
exclude: []
|
54
|
+
enabled: true
|
55
|
+
max_copies: 2
|
56
|
+
min_clump_size: 2
|
57
|
+
LongYieldList:
|
58
|
+
max_params: 2
|
59
|
+
exclude: []
|
60
|
+
enabled: true
|
61
|
+
overrides:
|
62
|
+
initialize:
|
63
|
+
max_params: 5
|
data/reek.gemspec
CHANGED
@@ -1,48 +1,36 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.join(File.dirname(__FILE__), 'lib/reek/version.rb')
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = %q{reek}
|
5
|
-
s.version =
|
6
|
+
s.version = Reek::VERSION
|
6
7
|
|
7
|
-
s.
|
8
|
-
s.authors = ["Kevin Rutherford"]
|
8
|
+
s.authors = ['Kevin Rutherford', 'Timo Roessner', 'Matijs van Zuijlen']
|
9
9
|
s.date = %q{2010-04-26}
|
10
10
|
s.default_executable = %q{reek}
|
11
11
|
s.description = %q{Reek is a tool that examines Ruby classes, modules and methods
|
12
12
|
and reports any code smells it finds.
|
13
13
|
}
|
14
|
-
s.email = ["
|
14
|
+
s.email = ["timo.roessner@googlemail.com"]
|
15
15
|
s.executables = ["reek"]
|
16
16
|
s.extra_rdoc_files = ["History.txt", "License.txt"]
|
17
|
-
s.files = [".yardopts", "History.txt", "License.txt", "README.md",
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
17
|
+
s.files = Dir[".yardopts", "History.txt", "License.txt", "README.md",
|
18
|
+
"Rakefile", "bin/reek", "config/defaults.reek",
|
19
|
+
"{features,lib,spec,tasks}/**/*",
|
20
|
+
"reek.gemspec" ] & `git ls-files -z`.split("\0")
|
21
|
+
s.homepage = %q{http://wiki.github.com/troessner/reek}
|
22
|
+
s.post_install_message = %q{Thank you for downloading Reek. For info see the reek wiki http://wiki.github.com/troessner/reek}
|
24
23
|
s.rdoc_options = ["--main", "README.md"]
|
25
24
|
s.require_paths = ["lib"]
|
26
25
|
s.rubyforge_project = %q{reek}
|
27
26
|
s.rubygems_version = %q{1.3.6}
|
28
27
|
s.summary = %q{Code smell detector for Ruby}
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
s.add_runtime_dependency(%q<ruby_parser>, ["~> 2.0"])
|
30
|
+
s.add_runtime_dependency(%q<ruby2ruby>, ["~> 1.2.5"])
|
31
|
+
s.add_runtime_dependency(%q<sexp_processor>, ["~> 3.0"])
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
s.add_runtime_dependency(%q<sexp_processor>, ["~> 3.0"])
|
38
|
-
else
|
39
|
-
s.add_dependency(%q<ruby_parser>, ["~> 2.0"])
|
40
|
-
s.add_dependency(%q<ruby2ruby>, ["~> 1.2"])
|
41
|
-
s.add_dependency(%q<sexp_processor>, ["~> 3.0"])
|
42
|
-
end
|
43
|
-
else
|
44
|
-
s.add_dependency(%q<ruby_parser>, ["~> 2.0"])
|
45
|
-
s.add_dependency(%q<ruby2ruby>, ["~> 1.2"])
|
46
|
-
s.add_dependency(%q<sexp_processor>, ["~> 3.0"])
|
47
|
-
end
|
33
|
+
s.add_development_dependency(%q<rake>)
|
34
|
+
s.add_development_dependency(%q<cucumber>)
|
35
|
+
s.add_development_dependency(%q<rspec>, ["= 1.3.2"])
|
48
36
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_helper')
|
2
|
+
require 'find'
|
3
|
+
|
4
|
+
describe 'gem manifest' do
|
5
|
+
before :each do
|
6
|
+
@current_files = []
|
7
|
+
Find.find '.' do |path|
|
8
|
+
next unless File.file? path
|
9
|
+
next if path =~ /\.git|\.idea|build|doc|gem\/|tmp|nbproject|quality|xp.reek|Manifest.txt|develop.rake|deployment.rake/
|
10
|
+
@current_files << path[2..-1]
|
11
|
+
end
|
12
|
+
@current_files.sort!
|
13
|
+
@manifest = IO.readlines('Manifest.txt').map {|path| path.chomp}.sort
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'lists every current file' do
|
17
|
+
(@current_files - @manifest).should == []
|
18
|
+
end
|
19
|
+
it 'lists no extra files' do
|
20
|
+
(@manifest - @current_files).should == []
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_helper')
|
2
|
+
require 'find'
|
3
|
+
|
4
|
+
release_timestamp_file = 'build/.last-release'
|
5
|
+
if test(?f, release_timestamp_file)
|
6
|
+
describe 'updates' do
|
7
|
+
before :each do
|
8
|
+
@release_time = File.stat(release_timestamp_file).mtime
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'version file' do
|
12
|
+
it 'has been updated since the last release' do
|
13
|
+
version_time = File.stat('lib/reek.rb').mtime
|
14
|
+
(version_time > @release_time).should be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'history file' do
|
19
|
+
it 'has been updated since the last release' do
|
20
|
+
history_time = File.stat('History.txt').mtime
|
21
|
+
(history_time > @release_time).should be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'spec_helper')
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
describe 'yardoc' do
|
5
|
+
before :each do
|
6
|
+
stderr_file = Tempfile.new('yardoc')
|
7
|
+
stderr_file.close
|
8
|
+
@stdout = `yardoc 2> #{stderr_file.path}`
|
9
|
+
@stderr = IO.read(stderr_file.path)
|
10
|
+
end
|
11
|
+
it 'raises no warnings' do
|
12
|
+
@stderr.should == ''
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -32,7 +32,7 @@ describe MethodContext do
|
|
32
32
|
|
33
33
|
it 'should count calls to self' do
|
34
34
|
mctx = MethodContext.new(StopContext.new, ast(:defn, :equals))
|
35
|
-
mctx.refs.
|
35
|
+
mctx.refs.record_reference_to([:lvar, :other])
|
36
36
|
mctx.record_call_to(ast(:call, s(:self), :thing))
|
37
37
|
mctx.envious_receivers.should be_empty
|
38
38
|
end
|
@@ -85,4 +85,4 @@ describe MethodParameters, 'default assignments' do
|
|
85
85
|
@defaults.length.should == 2
|
86
86
|
end
|
87
87
|
end
|
88
|
-
end
|
88
|
+
end
|
@@ -3,128 +3,125 @@ require File.join(File.dirname(File.dirname(File.dirname(File.dirname(File.expan
|
|
3
3
|
|
4
4
|
include Reek::Core
|
5
5
|
|
6
|
-
describe ObjectRefs
|
6
|
+
describe ObjectRefs do
|
7
7
|
before(:each) do
|
8
8
|
@refs = ObjectRefs.new
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
context 'when empty' do
|
12
|
+
it 'should report no refs to self' do
|
13
|
+
@refs.references_to(:self).should == 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with references to a, b, and a" do
|
18
|
+
context 'with no refs to self' do
|
19
|
+
before(:each) do
|
20
|
+
@refs.record_reference_to('a')
|
21
|
+
@refs.record_reference_to('b')
|
22
|
+
@refs.record_reference_to('a')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should report no refs to self' do
|
26
|
+
@refs.references_to(:self).should == 0
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should report :a as the max' do
|
30
|
+
@refs.max_keys.should == {'a' => 2}
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not report self as the max' do
|
34
|
+
@refs.self_is_max?.should == false
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with one reference to self" do
|
38
|
+
before(:each) do
|
39
|
+
@refs.record_reference_to(:self)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should report 1 ref to self' do
|
43
|
+
@refs.references_to(:self).should == 1
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should not report self among the max' do
|
47
|
+
@refs.max_keys.should include('a')
|
48
|
+
@refs.max_keys.should_not include(:self)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should not report self as the max' do
|
52
|
+
@refs.self_is_max?.should == false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with many refs to self' do
|
59
|
+
before(:each) do
|
60
|
+
@refs.record_reference_to(:self)
|
61
|
+
@refs.record_reference_to(:self)
|
62
|
+
@refs.record_reference_to('a')
|
63
|
+
@refs.record_reference_to(:self)
|
64
|
+
@refs.record_reference_to('b')
|
65
|
+
@refs.record_reference_to('a')
|
66
|
+
@refs.record_reference_to(:self)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should report all refs to self' do
|
70
|
+
@refs.references_to(:self).should == 4
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should report self among the max' do
|
74
|
+
@refs.max_keys.should == { :self => 4}
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should report self as the max' do
|
78
|
+
@refs.self_is_max?.should == true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when self is not the only max' do
|
83
|
+
before(:each) do
|
84
|
+
@refs.record_reference_to('a')
|
85
|
+
@refs.record_reference_to(:self)
|
86
|
+
@refs.record_reference_to(:self)
|
87
|
+
@refs.record_reference_to('b')
|
88
|
+
@refs.record_reference_to('a')
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should report all refs to self' do
|
92
|
+
@refs.references_to(:self).should == 2
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should report self among the max' do
|
96
|
+
@refs.max_keys.should include('a')
|
97
|
+
@refs.max_keys.should include(:self)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should report self as the max' do
|
101
|
+
@refs.self_is_max?.should == true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when self is not among the max' do
|
106
|
+
before(:each) do
|
107
|
+
@refs.record_reference_to('a')
|
108
|
+
@refs.record_reference_to('b')
|
109
|
+
@refs.record_reference_to('a')
|
110
|
+
@refs.record_reference_to('b')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should report all refs to self' do
|
114
|
+
@refs.references_to(:self).should == 0
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should not report self among the max' do
|
118
|
+
@refs.max_keys.should include('a')
|
119
|
+
@refs.max_keys.should include('b')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should not report self as the max' do
|
123
|
+
@refs.self_is_max?.should == false
|
124
|
+
end
|
13
125
|
end
|
14
126
|
end
|
15
127
|
|
16
|
-
describe ObjectRefs, 'with no refs to self' do
|
17
|
-
before(:each) do
|
18
|
-
@refs = ObjectRefs.new
|
19
|
-
@refs.record_ref('a')
|
20
|
-
@refs.record_ref('b')
|
21
|
-
@refs.record_ref('a')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should report no refs to self' do
|
25
|
-
@refs.refs_to_self.should == 0
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should report :a as the max' do
|
29
|
-
@refs.max_keys.should == {'a' => 2}
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should not report self as the max' do
|
33
|
-
@refs.self_is_max?.should == false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ObjectRefs, 'with one ref to self' do
|
38
|
-
before(:each) do
|
39
|
-
@refs = ObjectRefs.new
|
40
|
-
@refs.record_ref('a')
|
41
|
-
@refs.record_ref('b')
|
42
|
-
@refs.record_ref('a')
|
43
|
-
@refs.record_reference_to_self
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should report 1 ref to self' do
|
47
|
-
@refs.refs_to_self.should == 1
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should not report self among the max' do
|
51
|
-
@refs.max_keys.should be_include('a')
|
52
|
-
@refs.max_keys.should_not include(Sexp.from_array([:lit, :self]))
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should not report self as the max' do
|
56
|
-
@refs.self_is_max?.should == false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe ObjectRefs, 'with many refs to self' do
|
61
|
-
before(:each) do
|
62
|
-
@refs = ObjectRefs.new
|
63
|
-
@refs.record_reference_to_self
|
64
|
-
@refs.record_reference_to_self
|
65
|
-
@refs.record_ref('a')
|
66
|
-
@refs.record_reference_to_self
|
67
|
-
@refs.record_ref('b')
|
68
|
-
@refs.record_ref('a')
|
69
|
-
@refs.record_reference_to_self
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should report all refs to self' do
|
73
|
-
@refs.refs_to_self.should == 4
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should report self among the max' do
|
77
|
-
@refs.max_keys.should == {Sexp.from_array([:lit, :self]) => 4}
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should report self as the max' do
|
81
|
-
@refs.self_is_max?.should == true
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe ObjectRefs, 'when self is not the only max' do
|
86
|
-
before(:each) do
|
87
|
-
@refs = ObjectRefs.new
|
88
|
-
@refs.record_ref('a')
|
89
|
-
@refs.record_reference_to_self
|
90
|
-
@refs.record_reference_to_self
|
91
|
-
@refs.record_ref('b')
|
92
|
-
@refs.record_ref('a')
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should report all refs to self' do
|
96
|
-
@refs.refs_to_self.should == 2
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should report self among the max' do
|
100
|
-
@refs.max_keys.should be_include('a')
|
101
|
-
@refs.max_keys.should be_include(Sexp.from_array([:lit, :self]))
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should report self as the max' do
|
105
|
-
@refs.self_is_max?.should == true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe ObjectRefs, 'when self is not among the max' do
|
110
|
-
before(:each) do
|
111
|
-
@refs = ObjectRefs.new
|
112
|
-
@refs.record_ref('a')
|
113
|
-
@refs.record_ref('b')
|
114
|
-
@refs.record_ref('a')
|
115
|
-
@refs.record_ref('b')
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should report all refs to self' do
|
119
|
-
@refs.refs_to_self.should == 0
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should not report self among the max' do
|
123
|
-
@refs.max_keys.should be_include('a')
|
124
|
-
@refs.max_keys.should be_include('b')
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should not report self as the max' do
|
128
|
-
@refs.self_is_max?.should == false
|
129
|
-
end
|
130
|
-
end
|