tailor 0.1.5 → 1.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -1
- data/.rspec +2 -1
- data/.tailor +6 -0
- data/Gemfile.lock +47 -78
- data/{ChangeLog.rdoc → History.rdoc} +0 -0
- data/README.rdoc +157 -24
- data/Rakefile +0 -9
- data/bin/tailor +16 -69
- data/features/configurable.feature +78 -0
- data/features/horizontal_spacing.feature +262 -0
- data/features/indentation.feature +17 -21
- data/features/indentation/bad_files_with_no_trailing_newline.feature +90 -0
- data/features/indentation/good_files_with_no_trailing_newline.feature +206 -0
- data/features/name_detection.feature +72 -0
- data/features/step_definitions/indentation_steps.rb +10 -133
- data/features/support/env.rb +7 -15
- data/features/support/file_cases/horizontal_spacing_cases.rb +265 -0
- data/features/support/file_cases/indentation_cases.rb +972 -0
- data/features/support/file_cases/naming_cases.rb +52 -0
- data/features/support/file_cases/vertical_spacing_cases.rb +70 -0
- data/features/support/hooks.rb +8 -0
- data/features/support/{1_file_with_bad_operator_spacing → legacy}/bad_op_spacing.rb +0 -0
- data/features/support/{1_file_with_bad_ternary_colon_spacing → legacy}/bad_ternary_colon_spacing.rb +0 -0
- data/features/support/{1_long_file_with_indentation/my_project.rb → legacy/long_file_with_indentation.rb} +1 -1
- data/features/support/world.rb +14 -0
- data/features/vertical_spacing.feature +114 -0
- data/lib/ext/string_ext.rb +5 -0
- data/lib/tailor.rb +6 -252
- data/lib/tailor/cli.rb +49 -0
- data/lib/tailor/cli/options.rb +251 -0
- data/lib/tailor/composite_observable.rb +56 -0
- data/lib/tailor/configuration.rb +263 -0
- data/lib/tailor/critic.rb +162 -0
- data/lib/tailor/formatters/text.rb +126 -0
- data/lib/tailor/lexed_line.rb +246 -0
- data/lib/tailor/lexer.rb +428 -0
- data/lib/tailor/lexer/token.rb +103 -0
- data/lib/tailor/lexer_constants.rb +75 -0
- data/lib/tailor/logger.rb +28 -0
- data/lib/tailor/problem.rb +100 -0
- data/lib/tailor/reporter.rb +48 -0
- data/lib/tailor/ruler.rb +39 -0
- data/lib/tailor/rulers.rb +7 -0
- data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +30 -0
- data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +22 -0
- data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +32 -0
- data/lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb +33 -0
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +199 -0
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +362 -0
- data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +84 -0
- data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +84 -0
- data/lib/tailor/rulers/max_line_length_ruler.rb +31 -0
- data/lib/tailor/rulers/spaces_after_comma_ruler.rb +83 -0
- data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +114 -0
- data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +123 -0
- data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +116 -0
- data/lib/tailor/rulers/spaces_before_comma_ruler.rb +67 -0
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +93 -0
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +98 -0
- data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +70 -0
- data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +70 -0
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +94 -0
- data/lib/tailor/rulers/trailing_newlines_ruler.rb +36 -0
- data/lib/tailor/runtime_error.rb +3 -0
- data/lib/tailor/tailorrc.erb +88 -0
- data/lib/tailor/version.rb +2 -2
- data/spec/spec_helper.rb +7 -5
- data/spec/tailor/cli_spec.rb +94 -0
- data/spec/tailor/configuration_spec.rb +147 -0
- data/spec/tailor/critic_spec.rb +63 -0
- data/spec/tailor/lexed_line_spec.rb +569 -0
- data/spec/tailor/lexer/token_spec.rb +46 -0
- data/spec/tailor/lexer_spec.rb +181 -0
- data/spec/tailor/options_spec.rb +6 -0
- data/spec/tailor/problem_spec.rb +74 -0
- data/spec/tailor/reporter_spec.rb +53 -0
- data/spec/tailor/ruler_spec.rb +56 -0
- data/spec/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +454 -0
- data/spec/tailor/rulers/indentation_spaces_ruler_spec.rb +128 -0
- data/spec/tailor/rulers/spaces_after_comma_spec.rb +31 -0
- data/spec/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +145 -0
- data/spec/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +63 -0
- data/spec/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +63 -0
- data/spec/tailor/rulers_spec.rb +9 -0
- data/spec/tailor/version_spec.rb +6 -0
- data/spec/tailor_spec.rb +9 -21
- data/tailor.gemspec +22 -35
- data/tasks/features.rake +7 -0
- data/tasks/roodi.rake +9 -0
- data/tasks/roodi_config.yaml +14 -0
- data/tasks/spec.rake +16 -0
- data/tasks/yard.rake +14 -0
- metadata +224 -77
- data/features/case_checking.feature +0 -38
- data/features/spacing.feature +0 -97
- data/features/spacing/commas.feature +0 -44
- data/features/step_definitions/case_checking_steps.rb +0 -42
- data/features/step_definitions/spacing_steps.rb +0 -156
- data/features/support/1_file_with_bad_comma_spacing/bad_comma_spacing.rb +0 -43
- data/features/support/1_file_with_bad_curly_brace_spacing/bad_curly_brace_spacing.rb +0 -60
- data/features/support/1_file_with_bad_parenthesis/bad_parenthesis.rb +0 -4
- data/features/support/1_file_with_bad_square_brackets/bad_square_brackets.rb +0 -62
- data/features/support/1_file_with_camel_case_class/camel_case_class.rb +0 -5
- data/features/support/1_file_with_camel_case_method/camel_case_method.rb +0 -3
- data/features/support/1_file_with_hard_tabs/hard_tab.rb +0 -3
- data/features/support/1_file_with_long_lines/long_lines.rb +0 -5
- data/features/support/1_file_with_snake_case_class/snake_case_class.rb +0 -5
- data/features/support/1_file_with_snake_case_method/snake_case_method.rb +0 -3
- data/features/support/1_file_with_trailing_whitespace/trailing_whitespace.rb +0 -5
- data/features/support/1_good_simple_file/simple_project.rb +0 -5
- data/features/support/common.rb +0 -102
- data/features/support/matchers.rb +0 -11
- data/lib/tailor/file_line.rb +0 -220
- data/lib/tailor/indentation.rb +0 -245
- data/lib/tailor/spacing.rb +0 -237
- data/spec/file_line_spec.rb +0 -70
- data/spec/indentation_spec.rb +0 -259
- data/spec/spacing/colon_spacing_spec.rb +0 -71
- data/spec/spacing/comma_spacing_spec.rb +0 -159
- data/spec/spacing/curly_brace_spacing_spec.rb +0 -257
- data/spec/spacing/parentheses_spacing_spec.rb +0 -28
- data/spec/spacing/square_bracket_spacing_spec.rb +0 -116
- data/spec/spacing_spec.rb +0 -167
- data/tasks/metrics.rake +0 -23
@@ -0,0 +1,128 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/rulers/indentation_spaces_ruler'
|
3
|
+
require 'ripper'
|
4
|
+
|
5
|
+
describe Tailor::Rulers::IndentationSpacesRuler do
|
6
|
+
let!(:spaces) { 5 }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
Tailor::Rulers::IndentationSpacesRuler.new(spaces)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#initialize" do
|
13
|
+
it "sets @proper to an Hash with :this_line and :next_line keys = 0" do
|
14
|
+
proper_indentation = subject.instance_variable_get(:@proper)
|
15
|
+
proper_indentation.should be_a Hash
|
16
|
+
proper_indentation[:this_line].should be_zero
|
17
|
+
proper_indentation[:next_line].should be_zero
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
describe "#comment_update" do
|
23
|
+
pending
|
24
|
+
context "token does not contain a trailing newline" do
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "token contains a trailing newline" do
|
29
|
+
context "lexed_line is spaces then a comment" do
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context "lexed_line is no spaces and a comment" do
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
context "lexed_line ends with an operator" do
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "lexed_line ends with a comma" do
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#embexpr_beg_update" do
|
48
|
+
it "sets @embexpr_beg to true" do
|
49
|
+
subject.instance_variable_set(:@embexpr_beg, false)
|
50
|
+
subject.embexpr_beg_update
|
51
|
+
subject.instance_variable_get(:@embexpr_beg).should be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe "#embexpr_end_update" do
|
57
|
+
it "sets @embexpr_beg to false" do
|
58
|
+
subject.instance_variable_set(:@embexpr_beg, true)
|
59
|
+
subject.embexpr_end_update
|
60
|
+
subject.instance_variable_get(:@embexpr_beg).should be_false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#ignored_nl_update" do
|
65
|
+
pending
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#kw_update" do
|
69
|
+
pending
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#lbrace_update" do
|
73
|
+
pending
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#lbracket_update" do
|
77
|
+
pending
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#lparen_update" do
|
81
|
+
pending
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#nl_update" do
|
85
|
+
pending
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#period_update" do
|
89
|
+
pending
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#rbrace_update" do
|
93
|
+
pending
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#rbracket_update" do
|
97
|
+
pending
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#rparen_update" do
|
101
|
+
pending
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#tstring_beg_update" do
|
105
|
+
it "calls #stop" do
|
106
|
+
subject.should_receive(:stop)
|
107
|
+
subject.tstring_beg_update 1
|
108
|
+
end
|
109
|
+
|
110
|
+
it "adds the lineno to @tstring_nesting" do
|
111
|
+
subject.tstring_beg_update 1
|
112
|
+
subject.instance_variable_get(:@tstring_nesting).should == [1]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#tstring_end_update" do
|
117
|
+
it "calls #start" do
|
118
|
+
subject.should_receive(:start)
|
119
|
+
subject.tstring_end_update
|
120
|
+
end
|
121
|
+
|
122
|
+
it "removes the lineno to @tstring_nesting" do
|
123
|
+
subject.instance_variable_set(:@tstring_nesting, [1])
|
124
|
+
subject.tstring_end_update
|
125
|
+
subject.instance_variable_get(:@tstring_nesting).should be_empty
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/rulers/spaces_after_comma_ruler'
|
3
|
+
|
4
|
+
describe Tailor::Rulers::SpacesAfterCommaRuler do
|
5
|
+
subject { Tailor::Rulers::SpacesAfterCommaRuler.new({}) }
|
6
|
+
|
7
|
+
describe "#comma_update" do
|
8
|
+
it "adds the column number to @comma_columns" do
|
9
|
+
subject.comma_update(",", 2, 1)
|
10
|
+
subject.instance_variable_get(:@comma_columns).should == [1]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#check_spaces_after_comma" do
|
15
|
+
context "no event after comma" do
|
16
|
+
let(:lexed_line) do
|
17
|
+
l = double "LexedLine"
|
18
|
+
l.stub(:event_at)
|
19
|
+
l.stub(:index)
|
20
|
+
|
21
|
+
l
|
22
|
+
end
|
23
|
+
|
24
|
+
it "doesn't detect any problems" do
|
25
|
+
Tailor::Problem.should_not_receive(:new)
|
26
|
+
expect { subject.check_spaces_after_comma(lexed_line, 1) }.
|
27
|
+
to_not raise_error
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/rulers/spaces_after_lbrace_ruler'
|
3
|
+
|
4
|
+
describe Tailor::Rulers::SpacesAfterLbraceRuler do
|
5
|
+
subject { Tailor::Rulers::SpacesAfterLbraceRuler.new('')}
|
6
|
+
|
7
|
+
describe "#comment_update" do
|
8
|
+
context "token has a trailing newline" do
|
9
|
+
it "calls #ignored_nl_update" do
|
10
|
+
subject.should_receive(:ignored_nl_update)
|
11
|
+
subject.comment_update("\n", '', '', 1, 1)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "token does not have a trailing newline" do
|
16
|
+
it "does not call #ignored_nl_update" do
|
17
|
+
subject.should_not_receive(:ignored_nl_update)
|
18
|
+
subject.comment_update("# comment", '', '', 1, 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#ignored_nl_update" do
|
24
|
+
it "calls #check_spaces_after_lbrace" do
|
25
|
+
subject.should_receive(:check_spaces_after_lbrace)
|
26
|
+
subject.ignored_nl_update('', 1, 1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#lbrace_update" do
|
31
|
+
it "adds column to @lbrace_columns" do
|
32
|
+
subject.lbrace_update('', 1, 1)
|
33
|
+
subject.instance_variable_get(:@lbrace_columns).should == [1]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#nl_update" do
|
38
|
+
it "calls #ignored_nl_update" do
|
39
|
+
subject.should_receive(:ignored_nl_update)
|
40
|
+
subject.nl_update('', 1, 1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#count_spaces" do
|
45
|
+
context "lexed_line.event_index returns nil" do
|
46
|
+
let(:lexed_line) do
|
47
|
+
l = double "LexedLine"
|
48
|
+
l.stub(:event_index).and_return nil
|
49
|
+
|
50
|
+
l
|
51
|
+
end
|
52
|
+
|
53
|
+
it "breaks from the loop and returns nil" do
|
54
|
+
lexed_line.should_not_receive(:at)
|
55
|
+
subject.count_spaces(lexed_line, 1).should be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "lexed_line.at returns nil" do
|
60
|
+
let(:lexed_line) do
|
61
|
+
l = double "LexedLine"
|
62
|
+
l.stub(:event_index).and_return 1
|
63
|
+
l.stub(:at).and_return nil
|
64
|
+
|
65
|
+
l
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns 0" do
|
69
|
+
subject.count_spaces(lexed_line, 1).should be_zero
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "next_event is a :on_nl" do
|
74
|
+
let!(:next_event) do
|
75
|
+
[[1,1], :on_nl, "\n"]
|
76
|
+
end
|
77
|
+
|
78
|
+
let(:lexed_line) do
|
79
|
+
l = double "LexedLine"
|
80
|
+
l.stub(:event_index).and_return 1
|
81
|
+
l.should_receive(:at).with(2).and_return next_event
|
82
|
+
|
83
|
+
l
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns 0" do
|
87
|
+
subject.count_spaces(lexed_line, 1).should be_zero
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "next_event is a :on_ignored_nl" do
|
92
|
+
let!(:next_event) do
|
93
|
+
[[1,1], :on_ignored_nl, "\n"]
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:lexed_line) do
|
97
|
+
l = double "LexedLine"
|
98
|
+
l.stub(:event_index).and_return 1
|
99
|
+
l.should_receive(:at).with(2).and_return next_event
|
100
|
+
|
101
|
+
l
|
102
|
+
end
|
103
|
+
|
104
|
+
it "breaks from the loop and returns nil" do
|
105
|
+
subject.count_spaces(lexed_line, 1)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "next_event is a non-space event" do
|
110
|
+
let!(:next_event) do
|
111
|
+
[[1,1], :on_kw, "def"]
|
112
|
+
end
|
113
|
+
|
114
|
+
let(:lexed_line) do
|
115
|
+
l = double "LexedLine"
|
116
|
+
l.stub(:event_index).and_return 1
|
117
|
+
l.stub(:at).and_return next_event
|
118
|
+
|
119
|
+
l
|
120
|
+
end
|
121
|
+
|
122
|
+
it "returns 0" do
|
123
|
+
subject.count_spaces(lexed_line, 1).should be_zero
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "next_event is :on_sp" do
|
128
|
+
let!(:next_event) do
|
129
|
+
[[1,1], :on_sp, " "]
|
130
|
+
end
|
131
|
+
|
132
|
+
let(:lexed_line) do
|
133
|
+
l = double "LexedLine"
|
134
|
+
l.stub(:event_index).and_return 1
|
135
|
+
l.stub(:at).and_return next_event
|
136
|
+
|
137
|
+
l
|
138
|
+
end
|
139
|
+
|
140
|
+
it "returns 2" do
|
141
|
+
subject.count_spaces(lexed_line, 1).should == 2
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/rulers/spaces_before_lbrace_ruler'
|
3
|
+
|
4
|
+
describe Tailor::Rulers::SpacesBeforeLbraceRuler do
|
5
|
+
subject { Tailor::Rulers::SpacesBeforeLbraceRuler.new 1 }
|
6
|
+
before { Tailor::Logger.stub(:log) }
|
7
|
+
|
8
|
+
describe "#count_spaces" do
|
9
|
+
context "lexed_line.event_index is 0" do
|
10
|
+
let(:lexed_line) do
|
11
|
+
l = double "LexedLine"
|
12
|
+
l.stub(:event_index).and_return 0
|
13
|
+
l.stub(:at).and_return nil
|
14
|
+
|
15
|
+
l
|
16
|
+
end
|
17
|
+
|
18
|
+
specify { subject.count_spaces(lexed_line, 1).should be_zero }
|
19
|
+
|
20
|
+
it "sets @do_measurement to false" do
|
21
|
+
expect { subject.count_spaces(lexed_line, 1) }.
|
22
|
+
to change{subject.instance_variable_get(:@do_measurement)}.from(true).
|
23
|
+
to(false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "no space before lbrace" do
|
28
|
+
let(:lexed_line) do
|
29
|
+
l = double "LexedLine"
|
30
|
+
l.stub(:event_index).and_return 1
|
31
|
+
l.stub(:at).and_return [[10, 0], :on_const, "HI"]
|
32
|
+
|
33
|
+
l
|
34
|
+
end
|
35
|
+
|
36
|
+
specify { subject.count_spaces(lexed_line, 1).should be_zero }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "1 space before lbrace" do
|
40
|
+
let(:lexed_line) do
|
41
|
+
l = double "LexedLine"
|
42
|
+
l.stub(:event_index).and_return 1
|
43
|
+
l.stub(:at).and_return [[10, 0], :on_sp, " "]
|
44
|
+
|
45
|
+
l
|
46
|
+
end
|
47
|
+
|
48
|
+
specify { subject.count_spaces(lexed_line, 1).should == 1 }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "> 1 space before lbrace" do
|
52
|
+
let(:lexed_line) do
|
53
|
+
l = double "LexedLine"
|
54
|
+
l.stub(:event_index).and_return 1
|
55
|
+
l.stub(:at).and_return [[10, 1], :on_sp, " "]
|
56
|
+
|
57
|
+
l
|
58
|
+
end
|
59
|
+
|
60
|
+
specify { subject.count_spaces(lexed_line, 3).should == 2 }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/rulers/spaces_before_rbrace_ruler'
|
3
|
+
|
4
|
+
describe Tailor::Rulers::SpacesBeforeRbraceRuler do
|
5
|
+
subject { Tailor::Rulers::SpacesBeforeRbraceRuler.new 1 }
|
6
|
+
before { Tailor::Logger.stub(:log) }
|
7
|
+
|
8
|
+
describe "#count_spaces" do
|
9
|
+
context "lexed_line.event_index is 0" do
|
10
|
+
let(:lexed_line) do
|
11
|
+
l = double "LexedLine"
|
12
|
+
l.stub(:event_index).and_return 0
|
13
|
+
l.stub(:at).and_return nil
|
14
|
+
|
15
|
+
l
|
16
|
+
end
|
17
|
+
|
18
|
+
specify { subject.count_spaces(lexed_line, 1).should be_zero }
|
19
|
+
|
20
|
+
it "sets @do_measurement to false" do
|
21
|
+
expect { subject.count_spaces(lexed_line, 1) }.
|
22
|
+
to change{subject.instance_variable_get(:@do_measurement)}.from(true).
|
23
|
+
to(false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "no space before rbrace" do
|
28
|
+
let(:lexed_line) do
|
29
|
+
l = double "LexedLine"
|
30
|
+
l.stub(:event_index).and_return 1
|
31
|
+
l.stub(:at).and_return [[10, 0], :on_const, "HI"]
|
32
|
+
|
33
|
+
l
|
34
|
+
end
|
35
|
+
|
36
|
+
specify { subject.count_spaces(lexed_line, 1).should be_zero }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "1 space before rbrace" do
|
40
|
+
let(:lexed_line) do
|
41
|
+
l = double "LexedLine"
|
42
|
+
l.stub(:event_index).and_return 1
|
43
|
+
l.stub(:at).and_return [[10, 0], :on_sp, " "]
|
44
|
+
|
45
|
+
l
|
46
|
+
end
|
47
|
+
|
48
|
+
specify { subject.count_spaces(lexed_line, 1).should == 1 }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "> 1 space before rbrace" do
|
52
|
+
let(:lexed_line) do
|
53
|
+
l = double "LexedLine"
|
54
|
+
l.stub(:event_index).and_return 1
|
55
|
+
l.stub(:at).and_return [[10, 0], :on_sp, " "]
|
56
|
+
|
57
|
+
l
|
58
|
+
end
|
59
|
+
|
60
|
+
specify { subject.count_spaces(lexed_line, 1).should == 2 }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|