tailor 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -23
- data/History.rdoc +14 -0
- data/README.rdoc +42 -2
- data/Rakefile +7 -0
- data/features/continuous_integration.feature +28 -0
- data/lib/tailor/cli.rb +17 -4
- data/lib/tailor/cli/options.rb +6 -0
- data/lib/tailor/configuration.rb +19 -3
- data/lib/tailor/configuration/style.rb +7 -0
- data/lib/tailor/critic.rb +4 -2
- data/lib/tailor/formatters/yaml.rb +51 -0
- data/lib/tailor/lexer.rb +6 -4
- data/lib/tailor/rake_task.rb +44 -6
- data/lib/tailor/reporter.rb +9 -3
- data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +3 -3
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -6
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +2 -2
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -6
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/configuration_spec.rb +37 -0
- data/spec/functional/horizontal_spacing/braces_spec.rb +113 -113
- data/spec/functional/horizontal_spacing/brackets_spec.rb +39 -39
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +27 -27
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +16 -16
- data/spec/functional/horizontal_spacing/parens_spec.rb +48 -48
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +23 -23
- data/spec/functional/horizontal_spacing_spec.rb +11 -11
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +212 -215
- data/spec/functional/indentation_spacing_spec.rb +8 -7
- data/spec/functional/naming/camel_case_methods_spec.rb +16 -16
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +30 -30
- data/spec/functional/naming_spec.rb +5 -4
- data/spec/functional/rake_task_spec.rb +56 -10
- data/spec/functional/vertical_spacing/class_length_spec.rb +16 -16
- data/spec/functional/vertical_spacing/method_length_spec.rb +16 -16
- data/spec/functional/vertical_spacing_spec.rb +5 -4
- data/spec/support/bad_indentation_cases.rb +35 -35
- data/spec/support/good_indentation_cases.rb +108 -108
- data/spec/support/horizontal_spacing_cases.rb +37 -37
- data/spec/support/naming_cases.rb +6 -6
- data/spec/support/vertical_spacing_cases.rb +4 -4
- data/spec/unit/tailor/cli_spec.rb +34 -12
- data/spec/unit/tailor/configuration_spec.rb +18 -0
- data/spec/unit/tailor/formatters/yaml_spec.rb +75 -0
- data/spec/unit/tailor/reporter_spec.rb +23 -4
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +12 -10
- data/spec/unit/tailor/version_spec.rb +3 -2
- metadata +35 -63
@@ -3,6 +3,7 @@ require_relative '../support/good_indentation_cases'
|
|
3
3
|
require 'tailor/critic'
|
4
4
|
require 'tailor/configuration/style'
|
5
5
|
|
6
|
+
|
6
7
|
describe "Indentation spacing problem detection" do
|
7
8
|
before do
|
8
9
|
Tailor::Logger.stub(:log)
|
@@ -25,18 +26,18 @@ describe "Indentation spacing problem detection" do
|
|
25
26
|
|
26
27
|
INDENT_OK.each do |file_name, contents|
|
27
28
|
before do
|
28
|
-
FileUtils.touch file_name
|
29
|
-
File.open(file_name
|
29
|
+
FileUtils.touch file_name
|
30
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
30
31
|
end
|
31
32
|
|
32
33
|
it "should be OK" do
|
33
|
-
critic.check_file(file_name
|
34
|
-
critic.problems.should == { file_name
|
34
|
+
critic.check_file(file_name, style.to_hash)
|
35
|
+
critic.problems.should == { file_name => [] }
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
context "case statement with indented whens" do
|
39
|
-
let(:file_name) {
|
40
|
+
let(:file_name) { 'case_whens_in' }
|
40
41
|
|
41
42
|
let(:contents) do
|
42
43
|
%Q{def my_method
|
@@ -55,7 +56,7 @@ end}
|
|
55
56
|
end
|
56
57
|
|
57
58
|
context "method with rparen on following line" do
|
58
|
-
let(:file_name) {
|
59
|
+
let(:file_name) { 'method_closing_lonely_paren' }
|
59
60
|
|
60
61
|
let(:contents) do
|
61
62
|
%Q{def your_thing(one
|
@@ -69,7 +70,7 @@ end}
|
|
69
70
|
end
|
70
71
|
|
71
72
|
context "lonely rparen and do on the same line" do
|
72
|
-
let(:file_name) {
|
73
|
+
let(:file_name) { 'rparen_and_do_same_line' }
|
73
74
|
|
74
75
|
let(:contents) do
|
75
76
|
%Q{opt.on('-c', '--config-file FILE',
|
@@ -5,11 +5,11 @@ require 'tailor/configuration/style'
|
|
5
5
|
|
6
6
|
CAMEL_CASE_METHODS = {}
|
7
7
|
|
8
|
-
CAMEL_CASE_METHODS[
|
8
|
+
CAMEL_CASE_METHODS['one_caps_camel_case_method'] =
|
9
9
|
%Q{def thingOne
|
10
10
|
end}
|
11
11
|
|
12
|
-
CAMEL_CASE_METHODS[
|
12
|
+
CAMEL_CASE_METHODS['one_caps_camel_case_method_trailing_comment'] =
|
13
13
|
%Q{def thingOne # comment
|
14
14
|
end}
|
15
15
|
|
@@ -18,8 +18,8 @@ describe "Detection of camel case methods" do
|
|
18
18
|
before do
|
19
19
|
Tailor::Logger.stub(:log)
|
20
20
|
FakeFS.activate!
|
21
|
-
File.open(file_name
|
22
|
-
critic.check_file(file_name
|
21
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
22
|
+
critic.check_file(file_name, style.to_hash)
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:critic) do
|
@@ -37,20 +37,20 @@ describe "Detection of camel case methods" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "standard camel case method" do
|
40
|
-
let(:file_name) {
|
41
|
-
specify { critic.problems[file_name
|
42
|
-
specify { critic.problems[file_name
|
43
|
-
specify { critic.problems[file_name
|
44
|
-
specify { critic.problems[file_name
|
45
|
-
specify { critic.problems[file_name
|
40
|
+
let(:file_name) { 'one_caps_camel_case_method' }
|
41
|
+
specify { critic.problems[file_name].size.should be 1 }
|
42
|
+
specify { critic.problems[file_name].first[:type].should == "allow_camel_case_methods" }
|
43
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
44
|
+
specify { critic.problems[file_name].first[:column].should be 4 }
|
45
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
46
46
|
end
|
47
47
|
|
48
48
|
context "standard camel case method, trailing comment" do
|
49
|
-
let(:file_name) {
|
50
|
-
specify { critic.problems[file_name
|
51
|
-
specify { critic.problems[file_name
|
52
|
-
specify { critic.problems[file_name
|
53
|
-
specify { critic.problems[file_name
|
54
|
-
specify { critic.problems[file_name
|
49
|
+
let(:file_name) { 'one_caps_camel_case_method_trailing_comment' }
|
50
|
+
specify { critic.problems[file_name].size.should be 1 }
|
51
|
+
specify { critic.problems[file_name].first[:type].should == "allow_camel_case_methods" }
|
52
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
53
|
+
specify { critic.problems[file_name].first[:column].should be 4 }
|
54
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
55
55
|
end
|
56
56
|
end
|
@@ -5,19 +5,19 @@ require 'tailor/configuration/style'
|
|
5
5
|
|
6
6
|
SCREAMING_SNAKE_CASE_CLASSES = {}
|
7
7
|
|
8
|
-
SCREAMING_SNAKE_CASE_CLASSES[
|
8
|
+
SCREAMING_SNAKE_CASE_CLASSES['one_screaming_snake_case_class'] =
|
9
9
|
%Q{class Thing_One
|
10
10
|
end}
|
11
11
|
|
12
|
-
SCREAMING_SNAKE_CASE_CLASSES[
|
12
|
+
SCREAMING_SNAKE_CASE_CLASSES['one_screaming_snake_case_module'] =
|
13
13
|
%Q{module Thing_One
|
14
14
|
end}
|
15
15
|
|
16
|
-
SCREAMING_SNAKE_CASE_CLASSES[
|
16
|
+
SCREAMING_SNAKE_CASE_CLASSES['double_screaming_snake_case_class'] =
|
17
17
|
%Q{class Thing_One_Again
|
18
18
|
end}
|
19
19
|
|
20
|
-
SCREAMING_SNAKE_CASE_CLASSES[
|
20
|
+
SCREAMING_SNAKE_CASE_CLASSES['double_screaming_snake_case_module'] =
|
21
21
|
%Q{module Thing_One_Again
|
22
22
|
end}
|
23
23
|
|
@@ -27,8 +27,8 @@ describe "Detection of camel case methods" do
|
|
27
27
|
before do
|
28
28
|
Tailor::Logger.stub(:log)
|
29
29
|
FakeFS.activate!
|
30
|
-
File.open(file_name
|
31
|
-
critic.check_file(file_name
|
30
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
31
|
+
critic.check_file(file_name, style.to_hash)
|
32
32
|
end
|
33
33
|
|
34
34
|
let(:critic) do
|
@@ -46,38 +46,38 @@ describe "Detection of camel case methods" do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context "standard screaming snake case class" do
|
49
|
-
let(:file_name) {
|
50
|
-
specify { critic.problems[file_name
|
51
|
-
specify { critic.problems[file_name
|
52
|
-
specify { critic.problems[file_name
|
53
|
-
specify { critic.problems[file_name
|
54
|
-
specify { critic.problems[file_name
|
49
|
+
let(:file_name) { 'one_screaming_snake_case_class' }
|
50
|
+
specify { critic.problems[file_name].size.should be 1 }
|
51
|
+
specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
|
52
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
53
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
54
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
55
55
|
end
|
56
56
|
|
57
57
|
context "standard screaming snake case module" do
|
58
|
-
let(:file_name) {
|
59
|
-
specify { critic.problems[file_name
|
60
|
-
specify { critic.problems[file_name
|
61
|
-
specify { critic.problems[file_name
|
62
|
-
specify { critic.problems[file_name
|
63
|
-
specify { critic.problems[file_name
|
58
|
+
let(:file_name) { 'one_screaming_snake_case_module' }
|
59
|
+
specify { critic.problems[file_name].size.should be 1 }
|
60
|
+
specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
|
61
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
62
|
+
specify { critic.problems[file_name].first[:column].should be 7 }
|
63
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
64
64
|
end
|
65
65
|
|
66
66
|
context "double screaming snake case class" do
|
67
|
-
let(:file_name) {
|
68
|
-
specify { critic.problems[file_name
|
69
|
-
specify { critic.problems[file_name
|
70
|
-
specify { critic.problems[file_name
|
71
|
-
specify { critic.problems[file_name
|
72
|
-
specify { critic.problems[file_name
|
67
|
+
let(:file_name) { 'double_screaming_snake_case_class' }
|
68
|
+
specify { critic.problems[file_name].size.should be 1 }
|
69
|
+
specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
|
70
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
71
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
72
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
73
73
|
end
|
74
74
|
|
75
75
|
context "double screaming snake case module" do
|
76
|
-
let(:file_name) {
|
77
|
-
specify { critic.problems[file_name
|
78
|
-
specify { critic.problems[file_name
|
79
|
-
specify { critic.problems[file_name
|
80
|
-
specify { critic.problems[file_name
|
81
|
-
specify { critic.problems[file_name
|
76
|
+
let(:file_name) { 'double_screaming_snake_case_module' }
|
77
|
+
specify { critic.problems[file_name].size.should be 1 }
|
78
|
+
specify { critic.problems[file_name].first[:type].should == "allow_screaming_snake_case_classes" }
|
79
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
80
|
+
specify { critic.problems[file_name].first[:column].should be 7 }
|
81
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
82
82
|
end
|
83
83
|
end
|
@@ -3,6 +3,7 @@ require_relative '../support/naming_cases'
|
|
3
3
|
require 'tailor/critic'
|
4
4
|
require 'tailor/configuration/style'
|
5
5
|
|
6
|
+
|
6
7
|
describe "Naming problem detection" do
|
7
8
|
before do
|
8
9
|
Tailor::Logger.stub(:log)
|
@@ -23,13 +24,13 @@ describe "Naming problem detection" do
|
|
23
24
|
|
24
25
|
NAMING_OK.each do |file_name, contents|
|
25
26
|
before do
|
26
|
-
FileUtils.touch file_name
|
27
|
-
File.open(file_name
|
27
|
+
FileUtils.touch file_name
|
28
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
28
29
|
end
|
29
30
|
|
30
31
|
it "should be OK" do
|
31
|
-
critic.check_file(file_name
|
32
|
-
critic.problems.should == { file_name
|
32
|
+
critic.check_file(file_name, style.to_hash)
|
33
|
+
critic.problems.should == { file_name => [] }
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tailor/rake_task'
|
3
3
|
|
4
4
|
|
5
5
|
describe Tailor::RakeTask do
|
@@ -13,14 +13,14 @@ describe Tailor::RakeTask do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'rake tailor' do
|
16
|
-
context
|
16
|
+
context 'with problematic files' do
|
17
17
|
subject do
|
18
18
|
Tailor::RakeTask.new do |t|
|
19
19
|
t.config_file = File.expand_path 'spec/support/rake_task_config_problems.rb'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'finds problems' do
|
24
24
|
subject
|
25
25
|
|
26
26
|
expect {
|
@@ -29,14 +29,14 @@ describe Tailor::RakeTask do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
context
|
32
|
+
context 'with OK files' do
|
33
33
|
subject do
|
34
34
|
Tailor::RakeTask.new do |t|
|
35
35
|
t.config_file = File.expand_path 'spec/support/rake_task_config_no_problems.rb'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'does not find problems' do
|
40
40
|
subject
|
41
41
|
|
42
42
|
expect {
|
@@ -46,7 +46,7 @@ describe Tailor::RakeTask do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
context
|
49
|
+
context 'using a custom task name' do
|
50
50
|
subject do
|
51
51
|
Tailor::RakeTask.new(task_name) do |t|
|
52
52
|
t.config_file = File.expand_path 'spec/support/rake_task_config_problems.rb'
|
@@ -55,7 +55,7 @@ describe Tailor::RakeTask do
|
|
55
55
|
|
56
56
|
let(:task_name) { 'my_neat_task' }
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'runs the task' do
|
59
59
|
subject
|
60
60
|
|
61
61
|
expect {
|
@@ -64,7 +64,7 @@ describe Tailor::RakeTask do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
context
|
67
|
+
context 'overriding tailor opts within the task' do
|
68
68
|
subject do
|
69
69
|
Tailor::RakeTask.new do |t|
|
70
70
|
t.config_file = File.expand_path 'spec/support/rake_task_config_problems.rb'
|
@@ -72,7 +72,7 @@ describe Tailor::RakeTask do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
75
|
+
it 'uses the options from the rake task' do
|
76
76
|
subject
|
77
77
|
|
78
78
|
expect {
|
@@ -80,4 +80,50 @@ describe Tailor::RakeTask do
|
|
80
80
|
}.to_not raise_error
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
context 'adding file sets within the task' do
|
85
|
+
let(:test_dir) do
|
86
|
+
File.expand_path(File.dirname(__FILE__) + '/../dir')
|
87
|
+
end
|
88
|
+
|
89
|
+
before do
|
90
|
+
require 'fileutils'
|
91
|
+
|
92
|
+
unless File.exists?(test_dir)
|
93
|
+
FileUtils.mkdir(test_dir)
|
94
|
+
end
|
95
|
+
|
96
|
+
File.directory?(test_dir).should be_true
|
97
|
+
|
98
|
+
File.open(test_dir + '/test.rb', 'w') do |f|
|
99
|
+
f.write <<-CONTENTS
|
100
|
+
puts 'I no have end quote
|
101
|
+
CONTENTS
|
102
|
+
end
|
103
|
+
|
104
|
+
File.exists?(test_dir + '/test.rb').should be_true
|
105
|
+
end
|
106
|
+
|
107
|
+
after do
|
108
|
+
FileUtils.rm_rf test_dir
|
109
|
+
end
|
110
|
+
|
111
|
+
subject do
|
112
|
+
Tailor::RakeTask.new do |t|
|
113
|
+
t.config_file = File.expand_path 'spec/support/rake_task_config_problems.rb'
|
114
|
+
|
115
|
+
t.file_set('dir/**/*.rb', 'dir') do |style|
|
116
|
+
style.max_line_length 1, level: :error
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'uses the options from the rake task' do
|
122
|
+
subject
|
123
|
+
|
124
|
+
expect {
|
125
|
+
rake['tailor'].invoke
|
126
|
+
}.to raise_error
|
127
|
+
end
|
128
|
+
end
|
83
129
|
end
|
@@ -4,7 +4,7 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
CLASS_LENGTH = {}
|
7
|
-
CLASS_LENGTH[
|
7
|
+
CLASS_LENGTH['class_too_long'] =
|
8
8
|
%Q{class Party
|
9
9
|
include Clowns
|
10
10
|
include Pizza
|
@@ -14,7 +14,7 @@ CLASS_LENGTH[:class_too_long] =
|
|
14
14
|
end
|
15
15
|
end}
|
16
16
|
|
17
|
-
CLASS_LENGTH[
|
17
|
+
CLASS_LENGTH['parent_class_too_long'] =
|
18
18
|
%Q{class Party
|
19
19
|
|
20
20
|
class Pizza
|
@@ -28,8 +28,8 @@ describe "Detection of class length" do
|
|
28
28
|
before do
|
29
29
|
Tailor::Logger.stub(:log)
|
30
30
|
FakeFS.activate!
|
31
|
-
File.open(file_name
|
32
|
-
critic.check_file(file_name
|
31
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
32
|
+
critic.check_file(file_name, style.to_hash)
|
33
33
|
end
|
34
34
|
|
35
35
|
let(:critic) do
|
@@ -48,20 +48,20 @@ describe "Detection of class length" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
context "single class" do
|
51
|
-
let(:file_name) {
|
52
|
-
specify { critic.problems[file_name
|
53
|
-
specify { critic.problems[file_name
|
54
|
-
specify { critic.problems[file_name
|
55
|
-
specify { critic.problems[file_name
|
56
|
-
specify { critic.problems[file_name
|
51
|
+
let(:file_name) { 'class_too_long' }
|
52
|
+
specify { critic.problems[file_name].size.should be 1 }
|
53
|
+
specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_class" }
|
54
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
55
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
56
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
57
57
|
end
|
58
58
|
|
59
59
|
context "class in a class" do
|
60
|
-
let(:file_name) {
|
61
|
-
specify { critic.problems[file_name
|
62
|
-
specify { critic.problems[file_name
|
63
|
-
specify { critic.problems[file_name
|
64
|
-
specify { critic.problems[file_name
|
65
|
-
specify { critic.problems[file_name
|
60
|
+
let(:file_name) { 'parent_class_too_long' }
|
61
|
+
specify { critic.problems[file_name].size.should be 1 }
|
62
|
+
specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_class" }
|
63
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
64
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
65
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
66
66
|
end
|
67
67
|
end
|
@@ -4,13 +4,13 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
METHOD_LENGTH = {}
|
7
|
-
METHOD_LENGTH[
|
7
|
+
METHOD_LENGTH['method_too_long'] =
|
8
8
|
%Q{def thing
|
9
9
|
puts
|
10
10
|
puts
|
11
11
|
end}
|
12
12
|
|
13
|
-
METHOD_LENGTH[
|
13
|
+
METHOD_LENGTH['parent_method_too_long'] =
|
14
14
|
%Q{def thing
|
15
15
|
puts
|
16
16
|
def inner_thing; print '1'; end
|
@@ -22,8 +22,8 @@ describe "Detection of method length" do
|
|
22
22
|
before do
|
23
23
|
Tailor::Logger.stub(:log)
|
24
24
|
FakeFS.activate!
|
25
|
-
File.open(file_name
|
26
|
-
critic.check_file(file_name
|
25
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
26
|
+
critic.check_file(file_name, style.to_hash)
|
27
27
|
end
|
28
28
|
|
29
29
|
let(:critic) do
|
@@ -42,20 +42,20 @@ describe "Detection of method length" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "single class too long" do
|
45
|
-
let(:file_name) {
|
46
|
-
specify { critic.problems[file_name
|
47
|
-
specify { critic.problems[file_name
|
48
|
-
specify { critic.problems[file_name
|
49
|
-
specify { critic.problems[file_name
|
50
|
-
specify { critic.problems[file_name
|
45
|
+
let(:file_name) { 'method_too_long' }
|
46
|
+
specify { critic.problems[file_name].size.should be 1 }
|
47
|
+
specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_method" }
|
48
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
49
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
50
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
51
51
|
end
|
52
52
|
|
53
53
|
context "method in a method" do
|
54
|
-
let(:file_name) {
|
55
|
-
specify { critic.problems[file_name
|
56
|
-
specify { critic.problems[file_name
|
57
|
-
specify { critic.problems[file_name
|
58
|
-
specify { critic.problems[file_name
|
59
|
-
specify { critic.problems[file_name
|
54
|
+
let(:file_name) { 'method_too_long' }
|
55
|
+
specify { critic.problems[file_name].size.should be 1 }
|
56
|
+
specify { critic.problems[file_name].first[:type].should == "max_code_lines_in_method" }
|
57
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
58
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
59
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
60
60
|
end
|
61
61
|
end
|