reek 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reek}
5
- s.version = "1.2.0"
5
+ s.version = "1.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Kevin Rutherford"]
9
- s.date = %q{2009-09-20}
9
+ s.date = %q{2009-10-03}
10
10
  s.default_executable = %q{reek}
11
11
  s.description = %q{Code smell detector for Ruby}
12
12
  s.email = ["kevin@rutherford-software.com"]
13
13
  s.executables = ["reek"]
14
14
  s.extra_rdoc_files = ["History.txt", "License.txt", "README.rdoc"]
15
- s.files = ["History.txt", "License.txt", "README.rdoc", "Rakefile", "bin/reek", "config/defaults.reek", "features/masking_smells.feature", "features/options.feature", "features/reports.feature", "features/samples.feature", "features/stdin.feature", "features/step_definitions/reek_steps.rb", "features/support/env.rb", "lib/reek.rb", "lib/reek/adapters/application.rb", "lib/reek/adapters/config_file.rb", "lib/reek/adapters/core_extras.rb", "lib/reek/adapters/object_source.rb", "lib/reek/adapters/rake_task.rb", "lib/reek/adapters/report.rb", "lib/reek/adapters/source.rb", "lib/reek/adapters/spec.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/command_line.rb", "lib/reek/configuration.rb", "lib/reek/detector_stack.rb", "lib/reek/exceptions.reek", "lib/reek/if_context.rb", "lib/reek/method_context.rb", "lib/reek/module_context.rb", "lib/reek/name.rb", "lib/reek/object_refs.rb", "lib/reek/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/data_clump.rb", "lib/reek/smells/duplication.rb", "lib/reek/smells/feature_envy.rb", "lib/reek/smells/large_class.rb", "lib/reek/smells/long_method.rb", "lib/reek/smells/long_parameter_list.rb", "lib/reek/smells/long_yield_list.rb", "lib/reek/smells/nested_iterators.rb", "lib/reek/smells/simulated_polymorphism.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/sniffer.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/quality/reek_source_spec.rb", "spec/reek/adapters/report_spec.rb", "spec/reek/adapters/should_reek_of_spec.rb", "spec/reek/adapters/should_reek_only_of_spec.rb", "spec/reek/adapters/should_reek_spec.rb", "spec/reek/block_context_spec.rb", "spec/reek/class_context_spec.rb", "spec/reek/code_context_spec.rb", "spec/reek/code_parser_spec.rb", "spec/reek/config_spec.rb", "spec/reek/configuration_spec.rb", "spec/reek/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/name_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/object_source_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smell_warning_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/data_clump_spec.rb", "spec/reek/smells/duplication_spec.rb", "spec/reek/smells/feature_envy_spec.rb", "spec/reek/smells/large_class_spec.rb", "spec/reek/smells/long_method_spec.rb", "spec/reek/smells/long_parameter_list_spec.rb", "spec/reek/smells/nested_iterators_spec.rb", "spec/reek/smells/simulated_polymorphism_spec.rb", "spec/reek/smells/smell_detector_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/sniffer_spec.rb", "spec/samples/all_but_one_masked/clean_one.rb", "spec/samples/all_but_one_masked/dirty.rb", "spec/samples/all_but_one_masked/masked.reek", "spec/samples/clean_due_to_masking/clean_one.rb", "spec/samples/clean_due_to_masking/clean_three.rb", "spec/samples/clean_due_to_masking/clean_two.rb", "spec/samples/clean_due_to_masking/dirty_one.rb", "spec/samples/clean_due_to_masking/dirty_two.rb", "spec/samples/clean_due_to_masking/masked.reek", "spec/samples/corrupt_config_file/corrupt.reek", "spec/samples/corrupt_config_file/dirty.rb", "spec/samples/empty_config_file/dirty.rb", "spec/samples/empty_config_file/empty.reek", "spec/samples/exceptions.reek", "spec/samples/inline.rb", "spec/samples/masked/dirty.rb", "spec/samples/masked/masked.reek", "spec/samples/mixed_results/clean_one.rb", "spec/samples/mixed_results/clean_three.rb", "spec/samples/mixed_results/clean_two.rb", "spec/samples/mixed_results/dirty_one.rb", "spec/samples/mixed_results/dirty_two.rb", "spec/samples/not_quite_masked/dirty.rb", "spec/samples/not_quite_masked/masked.reek", "spec/samples/optparse.rb", "spec/samples/overrides/masked/dirty.rb", "spec/samples/overrides/masked/lower.reek", "spec/samples/overrides/upper.reek", "spec/samples/redcloth.rb", "spec/samples/three_clean_files/clean_one.rb", "spec/samples/three_clean_files/clean_three.rb", "spec/samples/three_clean_files/clean_two.rb", "spec/samples/two_smelly_files/dirty_one.rb", "spec/samples/two_smelly_files/dirty_two.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/test.rake"]
15
+ s.files = ["History.txt", "License.txt", "README.rdoc", "Rakefile", "bin/reek", "config/defaults.reek", "features/masking_smells.feature", "features/options.feature", "features/reports.feature", "features/samples.feature", "features/stdin.feature", "features/step_definitions/reek_steps.rb", "features/support/env.rb", "lib/reek.rb", "lib/reek/adapters/application.rb", "lib/reek/adapters/command_line.rb", "lib/reek/adapters/config_file.rb", "lib/reek/adapters/core_extras.rb", "lib/reek/adapters/object_source.rb", "lib/reek/adapters/rake_task.rb", "lib/reek/adapters/report.rb", "lib/reek/adapters/source.rb", "lib/reek/adapters/spec.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/configuration.rb", "lib/reek/detector_stack.rb", "lib/reek/exceptions.reek", "lib/reek/if_context.rb", "lib/reek/method_context.rb", "lib/reek/module_context.rb", "lib/reek/name.rb", "lib/reek/object_refs.rb", "lib/reek/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/class_variable.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/data_clump.rb", "lib/reek/smells/duplication.rb", "lib/reek/smells/feature_envy.rb", "lib/reek/smells/large_class.rb", "lib/reek/smells/long_method.rb", "lib/reek/smells/long_parameter_list.rb", "lib/reek/smells/long_yield_list.rb", "lib/reek/smells/nested_iterators.rb", "lib/reek/smells/simulated_polymorphism.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/sniffer.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/quality/reek_source_spec.rb", "spec/reek/adapters/report_spec.rb", "spec/reek/adapters/should_reek_of_spec.rb", "spec/reek/adapters/should_reek_only_of_spec.rb", "spec/reek/adapters/should_reek_spec.rb", "spec/reek/block_context_spec.rb", "spec/reek/class_context_spec.rb", "spec/reek/code_context_spec.rb", "spec/reek/code_parser_spec.rb", "spec/reek/config_spec.rb", "spec/reek/configuration_spec.rb", "spec/reek/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/name_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/object_source_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smell_warning_spec.rb", "spec/reek/smells/class_variable_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/data_clump_spec.rb", "spec/reek/smells/duplication_spec.rb", "spec/reek/smells/feature_envy_spec.rb", "spec/reek/smells/large_class_spec.rb", "spec/reek/smells/long_method_spec.rb", "spec/reek/smells/long_parameter_list_spec.rb", "spec/reek/smells/nested_iterators_spec.rb", "spec/reek/smells/simulated_polymorphism_spec.rb", "spec/reek/smells/smell_detector_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/sniffer_spec.rb", "spec/reek/stop_context_spec.rb", "spec/samples/all_but_one_masked/clean_one.rb", "spec/samples/all_but_one_masked/dirty.rb", "spec/samples/all_but_one_masked/masked.reek", "spec/samples/clean_due_to_masking/clean_one.rb", "spec/samples/clean_due_to_masking/clean_three.rb", "spec/samples/clean_due_to_masking/clean_two.rb", "spec/samples/clean_due_to_masking/dirty_one.rb", "spec/samples/clean_due_to_masking/dirty_two.rb", "spec/samples/clean_due_to_masking/masked.reek", "spec/samples/corrupt_config_file/corrupt.reek", "spec/samples/corrupt_config_file/dirty.rb", "spec/samples/empty_config_file/dirty.rb", "spec/samples/empty_config_file/empty.reek", "spec/samples/exceptions.reek", "spec/samples/inline.rb", "spec/samples/masked/dirty.rb", "spec/samples/masked/masked.reek", "spec/samples/mixed_results/clean_one.rb", "spec/samples/mixed_results/clean_three.rb", "spec/samples/mixed_results/clean_two.rb", "spec/samples/mixed_results/dirty_one.rb", "spec/samples/mixed_results/dirty_two.rb", "spec/samples/not_quite_masked/dirty.rb", "spec/samples/not_quite_masked/masked.reek", "spec/samples/optparse.rb", "spec/samples/overrides/masked/dirty.rb", "spec/samples/overrides/masked/lower.reek", "spec/samples/overrides/upper.reek", "spec/samples/redcloth.rb", "spec/samples/three_clean_files/clean_one.rb", "spec/samples/three_clean_files/clean_three.rb", "spec/samples/three_clean_files/clean_two.rb", "spec/samples/two_smelly_files/dirty_one.rb", "spec/samples/two_smelly_files/dirty_two.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/test.rake"]
16
16
  s.homepage = %q{http://wiki.github.com/kevinrutherford/reek}
17
17
  s.post_install_message = %q{
18
18
  For more information on reek, see http://wiki.github.com/kevinrutherford/reek
19
19
  }
20
- s.rdoc_options = ["--main", "README.txt"]
20
+ s.rdoc_options = ["--main", "README.rdoc"]
21
21
  s.require_paths = ["lib"]
22
22
  s.rubyforge_project = %q{reek}
23
23
  s.rubygems_version = %q{1.3.5}
@@ -8,7 +8,7 @@ describe 'Reek source code' do
8
8
  nucleus = Dir['lib/reek/**.rb'] - Dir['lib/reek/adapters/**/*.rb']
9
9
  nucleus.each do |src|
10
10
  it "#{src} contains no references from the nucleus out to the adapters" do
11
- IO.readlines(src).grep(/adapters/).should be_empty
11
+ IO.readlines(src).grep(/adapters/).should == []
12
12
  end
13
13
  end
14
14
 
@@ -9,7 +9,7 @@ include Reek
9
9
 
10
10
  describe ReportSection, " when empty" do
11
11
  before(:each) do
12
- @rpt = ReportSection.new(''.sniff)
12
+ @rpt = ReportSection.new(''.sniff, '%m%c %w (%s)', false)
13
13
  end
14
14
 
15
15
  it 'has an empty quiet_report' do
@@ -19,7 +19,7 @@ end
19
19
 
20
20
  describe ReportSection, "smell_list" do
21
21
  before(:each) do
22
- rpt = ReportSection.new('def simple(a) a[3] end'.sniff)
22
+ rpt = ReportSection.new('def simple(a) a[3] end'.sniff, false, '%m%c %w (%s)')
23
23
  @lines = rpt.smell_list.split("\n")
24
24
  end
25
25
 
@@ -32,7 +32,7 @@ end
32
32
 
33
33
  describe ReportSection, " as a SortedSet" do
34
34
  it 'should only add a smell once' do
35
- rpt = ReportSection.new(''.sniff)
35
+ rpt = ReportSection.new(''.sniff, false, '%m%c %w (%s)')
36
36
  rpt << SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!', false)
37
37
  rpt << SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!', false)
38
38
  lines = rpt.smell_list.split("\n")
@@ -40,7 +40,7 @@ describe ReportSection, " as a SortedSet" do
40
40
  end
41
41
 
42
42
  it 'should not count an identical masked smell' do
43
- rpt = ReportSection.new(''.sniff)
43
+ rpt = ReportSection.new(''.sniff, false, '%m%c %w (%s)')
44
44
  # SMELL: Duplication -- the SmellWarning knows whether to call << or record_masked_smell
45
45
  rpt << SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!', false)
46
46
  rpt.record_masked_smell(SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!', true))
@@ -6,103 +6,127 @@ require 'reek/adapters/spec'
6
6
  include Reek
7
7
  include Reek::Spec
8
8
 
9
- describe ShouldReekOf, 'rdoc demo example' do
10
- it 'works on a common source' do
11
- ruby = 'def double_thing() @other.thing.foo + @other.thing.foo end'
12
- ruby.should reek_of(:Duplication, /@other.thing[^\.]/)
13
- ruby.should reek_of(:Duplication, /@other.thing.foo/)
14
- ruby.should_not reek_of(:FeatureEnvy)
15
- end
16
-
17
- it 'works on a common sniffer' do
18
- ruby = 'def double_thing() @other.thing.foo + @other.thing.foo end'.sniff
19
- ruby.should reek_of(:Duplication, /@other.thing[^\.]/)
20
- ruby.should reek_of(:Duplication, /@other.thing.foo/)
21
- ruby.should_not reek_of(:FeatureEnvy)
22
- end
23
- end
24
-
25
- describe ShouldReekOf, 'checking code in a string' do
26
- before :each do
27
- @clean_code = 'def good() true; end'
9
+ # belongs in its own spec file
10
+ describe ReekMatcher do
11
+ it 'reports quietly' do
28
12
  @smelly_code = 'def x() y = 4; end'
29
- @matcher = ShouldReekOf.new(:UncommunicativeName, [/x/, /y/])
30
- end
31
-
32
- it 'matches a smelly String' do
33
- @matcher.matches?(@smelly_code).should be_true
34
- end
35
-
36
- it 'doesnt match a fragrant String' do
37
- @matcher.matches?(@clean_code).should be_false
38
- end
39
-
40
- it 'reports the smells when should_not fails' do
41
- @matcher.matches?(@smelly_code).should be_true
42
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_code.sniff).quiet_report)
43
13
  end
44
14
  end
45
15
 
46
- describe ShouldReekOf, 'checking code in a Dir' do
47
- before :each do
48
- @clean_dir = Dir['spec/samples/three_clean_files/*.rb']
49
- @smelly_dir = Dir['spec/samples/two_smelly_files/*.rb']
50
- @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
51
- end
52
-
53
- it 'matches a smelly String' do
54
- @matcher.matches?(@smelly_dir).should be_true
55
- end
56
-
57
- it 'doesnt match a fragrant String' do
58
- @matcher.matches?(@clean_dir).should be_false
59
- end
60
-
61
- it 'reports the smells when should_not fails' do
62
- @matcher.matches?(@smelly_dir).should be_true
63
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_dir.sniff.sniffers).quiet_report)
64
- end
65
- end
66
-
67
- describe ShouldReekOf, 'checking code in a File' do
68
- before :each do
69
- @clean_file = File.new(Dir['spec/samples/three_clean_files/*.rb'][0])
70
- @smelly_file = File.new(Dir['spec/samples/two_smelly_files/*.rb'][0])
71
- @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
72
- end
73
-
74
- it 'matches a smelly String' do
75
- @matcher.matches?(@smelly_file).should be_true
76
- end
77
-
78
- it 'doesnt match a fragrant String' do
79
- @matcher.matches?(@clean_file).should be_false
80
- end
81
-
82
- it 'reports the smells when should_not fails' do
83
- @matcher.matches?(@smelly_file).should be_true
84
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_file.sniff).quiet_report)
85
- end
86
- end
87
-
88
- describe ShouldReekOf, 'report formatting' do
89
- before :each do
90
- sn_clean = 'def clean() @thing = 4; end'.sniff
91
- sn_dirty = 'def dirty() thing.cool + thing.cool; end'.sniff
92
- sniffers = SnifferSet.new([sn_clean, sn_dirty], '')
93
- @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
94
- @matcher.matches?(sniffers)
95
- @lines = @matcher.failure_message_for_should_not.split("\n").map {|str| str.chomp}
96
- @error_message = @lines.shift
97
- @smells = @lines.grep(/^ /)
98
- @headers = (@lines - @smells)
99
- end
100
-
101
- it 'mentions every smell in the report' do
102
- @smells.should have(2).warnings
103
- end
104
-
105
- it 'doesnt mention the clean source' do
106
- @headers.should have(1).headers
16
+ describe ShouldReekOf do
17
+ context 'rdoc demo example' do
18
+ before :each do
19
+ @ruby = 'def double_thing() @other.thing.foo + @other.thing.foo end'
20
+ end
21
+
22
+ shared_examples_for 'reek as documented' do
23
+ it 'reports duplicate calls to @other.thing' do
24
+ @ruby.should reek_of(:Duplication, /@other.thing[^\.]/)
25
+ end
26
+ it 'reports duplicate calls to @other.thing.foo' do
27
+ @ruby.should reek_of(:Duplication, /@other.thing.foo/)
28
+ end
29
+ it 'does not report any feature envy' do
30
+ @ruby.should_not reek_of(:FeatureEnvy)
31
+ end
32
+ end
33
+
34
+ context 'using source code' do
35
+ it_should_behave_like 'reek as documented'
36
+ end
37
+
38
+ context 'using a sniffer' do
39
+ before :each do
40
+ @ruby = @ruby.sniff
41
+ end
42
+
43
+ it_should_behave_like 'reek as documented'
44
+ end
45
+ end
46
+
47
+ context 'checking code in a string' do
48
+ before :each do
49
+ @clean_code = 'def good() true; end'
50
+ @smelly_code = 'def x() y = 4; end'
51
+ @expected_report = Reek::Spec::ReekMatcher::create_reporter(@smelly_code.sniff).report
52
+ @matcher = ShouldReekOf.new(:UncommunicativeName, [/x/, /y/])
53
+ end
54
+
55
+ it 'matches a smelly String' do
56
+ @matcher.matches?(@smelly_code).should be_true
57
+ end
58
+
59
+ it 'doesnt match a fragrant String' do
60
+ @matcher.matches?(@clean_code).should be_false
61
+ end
62
+
63
+ it 'reports the smells when should_not fails' do
64
+ @matcher.matches?(@smelly_code).should be_true
65
+ @matcher.failure_message_for_should_not.should include(@expected_report)
66
+ end
67
+ end
68
+
69
+ context 'checking code in a Dir' do
70
+ before :each do
71
+ @clean_dir = Dir['spec/samples/three_clean_files/*.rb']
72
+ @smelly_dir = Dir['spec/samples/two_smelly_files/*.rb']
73
+ @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
74
+ end
75
+
76
+ it 'matches a smelly String' do
77
+ @matcher.matches?(@smelly_dir).should be_true
78
+ end
79
+
80
+ it 'doesnt match a fragrant String' do
81
+ @matcher.matches?(@clean_dir).should be_false
82
+ end
83
+
84
+ it 'reports the smells when should_not fails' do
85
+ @matcher.matches?(@smelly_dir).should be_true
86
+ @matcher.failure_message_for_should_not.should include(QuietReport.new(@smelly_dir.sniff.sniffers, '%m%c %w (%s)').report)
87
+ end
88
+ end
89
+
90
+ context 'checking code in a File' do
91
+ before :each do
92
+ @clean_file = File.new(Dir['spec/samples/three_clean_files/*.rb'][0])
93
+ @smelly_file = File.new(Dir['spec/samples/two_smelly_files/*.rb'][0])
94
+ @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
95
+ end
96
+
97
+ it 'matches a smelly String' do
98
+ @matcher.matches?(@smelly_file).should be_true
99
+ end
100
+
101
+ it 'doesnt match a fragrant String' do
102
+ @matcher.matches?(@clean_file).should be_false
103
+ end
104
+
105
+ it 'reports the smells when should_not fails' do
106
+ @matcher.matches?(@smelly_file).should be_true
107
+ @matcher.failure_message_for_should_not.should include(QuietReport.new(@smelly_file.sniff, '%m%c %w (%s)').report)
108
+ end
109
+ end
110
+
111
+ context 'report formatting' do
112
+ before :each do
113
+ sn_clean = 'def clean() @thing = 4; end'.sniff
114
+ sn_dirty = 'def dirty() thing.cool + thing.cool; end'.sniff
115
+ sniffers = SnifferSet.new([sn_clean, sn_dirty], '')
116
+ @matcher = ShouldReekOf.new(:UncommunicativeName, [/Dirty/, /@s/])
117
+ @matcher.matches?(sniffers)
118
+ @lines = @matcher.failure_message_for_should_not.split("\n").map {|str| str.chomp}
119
+ @error_message = @lines.shift
120
+ @smells = @lines.grep(/^ /)
121
+ @headers = (@lines - @smells)
122
+ end
123
+
124
+ it 'mentions every smell in the report' do
125
+ @smells.should have(2).warnings
126
+ end
127
+
128
+ it 'doesnt mention the clean source' do
129
+ @headers.should have(1).headers
130
+ end
107
131
  end
108
132
  end
@@ -44,7 +44,7 @@ describe ShouldReekOnlyOf, 'checking code in a Dir' do
44
44
 
45
45
  it 'reports the smells when should_not fails' do
46
46
  @matcher.matches?(@smelly_dir).should be_true
47
- @matcher.failure_message_for_should.should include(Report.new(@smelly_dir.sniff.sniffers).quiet_report)
47
+ @matcher.failure_message_for_should.should include(QuietReport.new(@smelly_dir.sniff.sniffers, '%m%c %w (%s)').report)
48
48
  end
49
49
  end
50
50
 
@@ -65,7 +65,7 @@ describe ShouldReekOnlyOf, 'checking code in a File' do
65
65
 
66
66
  it 'reports the smells when should_not fails' do
67
67
  @matcher.matches?(@smelly_file).should be_true
68
- @matcher.failure_message_for_should.should include(Report.new(@smelly_file.sniff).quiet_report)
68
+ @matcher.failure_message_for_should.should include(QuietReport.new(@smelly_file.sniff, '%m%c %w (%s)').report)
69
69
  end
70
70
  end
71
71
 
@@ -23,7 +23,7 @@ describe ShouldReek, 'checking code in a string' do
23
23
 
24
24
  it 'reports the smells when should_not fails' do
25
25
  @matcher.matches?(@smelly_code).should be_true
26
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_code.sniff).quiet_report)
26
+ @matcher.failure_message_for_should_not.should include(QuietReport.new(@smelly_code.sniff, '%m%c %w (%s)').report)
27
27
  end
28
28
  end
29
29
 
@@ -44,7 +44,7 @@ describe ShouldReek, 'checking code in a Dir' do
44
44
 
45
45
  it 'reports the smells when should_not fails' do
46
46
  @matcher.matches?(@smelly_dir).should be_true
47
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_dir.sniff.sniffers).quiet_report)
47
+ @matcher.failure_message_for_should_not.should include(QuietReport.new(@smelly_dir.sniff.sniffers, '%m%c %w (%s)').report)
48
48
  end
49
49
  end
50
50
 
@@ -65,7 +65,7 @@ describe ShouldReek, 'checking code in a File' do
65
65
 
66
66
  it 'reports the smells when should_not fails' do
67
67
  @matcher.matches?(@smelly_file).should be_true
68
- @matcher.failure_message_for_should_not.should include(Report.new(@smelly_file.sniff).quiet_report)
68
+ @matcher.failure_message_for_should_not.should include(QuietReport.new(@smelly_file.sniff, '%m%c %w (%s)').report)
69
69
  end
70
70
  end
71
71
 
@@ -116,16 +116,6 @@ describe CodeContext, 'find class' do
116
116
  @mod2 = ModuleContext.create(@klass1, [0, :Mod2])
117
117
  @klass2 = ClassContext.create(@mod2, [0, :Klass2])
118
118
  end
119
-
120
- describe StopContext do
121
- it 'should not find unqualified class' do
122
- @stop.find_module('Klass2').should == nil
123
- end
124
-
125
- it 'should find unqualified module' do
126
- @stop.find_module('Mod1').name.should == 'Mod1'
127
- end
128
- end
129
119
 
130
120
  describe ModuleContext do
131
121
  it 'should find local name' do
@@ -36,4 +36,108 @@ describe CodeParser do
36
36
  it 'copes with a yield to an ivar' do
37
37
  'def options() ozz.on { |@list| @prompt = !@list } end'.should_not reek
38
38
  end
39
- end
39
+ end
40
+
41
+ describe CodeParser do
42
+ context 'with no class variables' do
43
+ it 'records nothing in the class' do
44
+ klass = ClassContext.from_s('class Fred; end')
45
+ klass.class_variables.should be_empty
46
+ end
47
+ it 'records nothing in the module' do
48
+ ctx = ModuleContext.from_s('module Fred; end')
49
+ ctx.class_variables.should be_empty
50
+ end
51
+ end
52
+
53
+ context 'with one class variable' do
54
+ shared_examples_for 'one variable found' do
55
+ it 'records the class variable' do
56
+ @ctx.class_variables.should include(Name.new(:@@tools))
57
+ end
58
+ it 'records only that class variable' do
59
+ @ctx.class_variables.length.should == 1
60
+ end
61
+ end
62
+
63
+ context 'declared in a class' do
64
+ before :each do
65
+ @ctx = ClassContext.from_s('class Fred; @@tools = {}; end')
66
+ end
67
+
68
+ it_should_behave_like 'one variable found'
69
+ end
70
+
71
+ context 'used in a class' do
72
+ before :each do
73
+ @ctx = ClassContext.from_s('class Fred; def jim() @@tools = {}; end; end')
74
+ end
75
+
76
+ it_should_behave_like 'one variable found'
77
+ end
78
+
79
+ context 'indexed in a class' do
80
+ before :each do
81
+ @ctx = ClassContext.from_s('class Fred; def jim() @@tools[mash] = {}; end; end')
82
+ end
83
+
84
+ it_should_behave_like 'one variable found'
85
+ end
86
+
87
+ context 'declared and used in a class' do
88
+ before :each do
89
+ @ctx = ClassContext.from_s('class Fred; @@tools = {}; def jim() @@tools = {}; end; end')
90
+ end
91
+
92
+ it_should_behave_like 'one variable found'
93
+ end
94
+
95
+ context 'used twice in a class' do
96
+ before :each do
97
+ @ctx = ClassContext.from_s('class Fred; def jeff() @@tools = {}; end; def jim() @@tools = {}; end; end')
98
+ end
99
+
100
+ it_should_behave_like 'one variable found'
101
+ end
102
+
103
+ context 'declared in a module' do
104
+ before :each do
105
+ @ctx = ClassContext.from_s('module Fred; @@tools = {}; end')
106
+ end
107
+
108
+ it_should_behave_like 'one variable found'
109
+ end
110
+
111
+ context 'used in a module' do
112
+ before :each do
113
+ @ctx = ClassContext.from_s('module Fred; def jim() @@tools = {}; end; end')
114
+ end
115
+
116
+ it_should_behave_like 'one variable found'
117
+ end
118
+
119
+ context 'indexed in a module' do
120
+ before :each do
121
+ @ctx = ClassContext.from_s('module Fred; def jim() @@tools[mash] = {}; end; end')
122
+ end
123
+
124
+ it_should_behave_like 'one variable found'
125
+ end
126
+
127
+ context 'declared and used in a module' do
128
+ before :each do
129
+ @ctx = ClassContext.from_s('module Fred; @@tools = {}; def jim() @@tools = {}; end; end')
130
+ end
131
+
132
+ it_should_behave_like 'one variable found'
133
+ end
134
+
135
+ context 'used twice in a module' do
136
+ before :each do
137
+ @ctx = ClassContext.from_s('module Fred; def jeff() @@tools = {}; end; def jim() @@tools = {}; end; end')
138
+ end
139
+
140
+ it_should_behave_like 'one variable found'
141
+ end
142
+ end
143
+ end