tailor 0.1.5 → 1.0.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,206 @@
|
|
1
|
+
@indentation
|
2
|
+
Feature: Indentation check on good files without trailing newlines
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given my configuration file ".tailor" looks like:
|
6
|
+
"""
|
7
|
+
Tailor.config do |config|
|
8
|
+
config.file_set do
|
9
|
+
trailing_newlines 0
|
10
|
+
end
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
|
14
|
+
@good_files
|
15
|
+
Scenario Outline: Don't detect problems on properly indented files with no newlines at the end
|
16
|
+
Given <File> exists without a newline at the end
|
17
|
+
When I successfully run `tailor -d -c .tailor <File>`
|
18
|
+
Then the output should match /Total Problems.*0/
|
19
|
+
And the exit status should be 0
|
20
|
+
|
21
|
+
Scenarios: Good class uses
|
22
|
+
| File |
|
23
|
+
| indent/ok/class |
|
24
|
+
| indent/ok/nested_class |
|
25
|
+
| indent/ok/class_empty |
|
26
|
+
| indent/ok/class_empty_trailing_comment |
|
27
|
+
| indent/ok/one_line_class |
|
28
|
+
| indent/ok/one_line_subclass |
|
29
|
+
| indent/ok/one_line_subclass_with_inheritance |
|
30
|
+
|
31
|
+
Scenarios: Good single-line statement uses
|
32
|
+
| File |
|
33
|
+
| indent/ok/class_singlestatement |
|
34
|
+
| indent/ok/require_class_singlestatement |
|
35
|
+
|
36
|
+
@multi_line
|
37
|
+
Scenarios: Good multi-line statement uses
|
38
|
+
| File |
|
39
|
+
| indent/ok/assignment_addition_multistatement |
|
40
|
+
| indent/ok/assignment_addition_multistatement_trailing_comment |
|
41
|
+
| indent/ok/assignment_hash_multistatement |
|
42
|
+
| indent/ok/assignment_hash_multistatement_trailing_comment |
|
43
|
+
| indent/ok/assignment_array_multistatement |
|
44
|
+
| indent/ok/assignment_array_multistatement_trailing_comment |
|
45
|
+
| indent/ok/assignment_paren_multistatement |
|
46
|
+
| indent/ok/assignment_paren_multistatement_trailing_comment |
|
47
|
+
| indent/ok/assignment_twolevel_hash_multistatement |
|
48
|
+
| indent/ok/assignment_twolevel_array_multistatement |
|
49
|
+
| indent/ok/assignment_twolevel_paren_multistatement |
|
50
|
+
| indent/ok/method_call_multistatement |
|
51
|
+
| indent/ok/method_call_multistatement_trailing_comment |
|
52
|
+
| indent/ok/method_call_multistatement_lonely_paren |
|
53
|
+
| indent/ok/method_call_multistatement_lonely_paren_trailing_comment |
|
54
|
+
| indent/ok/rescue_ending_with_comma |
|
55
|
+
| indent/ok/rescue_ending_with_comma_trailing_comment |
|
56
|
+
| indent/ok/keyword_ending_with_period |
|
57
|
+
| indent/ok/keyword_ending_with_period_trailing_comment |
|
58
|
+
|
59
|
+
Scenarios: Good def uses
|
60
|
+
| File |
|
61
|
+
| indent/ok/def |
|
62
|
+
| indent/ok/def_empty |
|
63
|
+
| indent/ok/nested_def |
|
64
|
+
| indent/ok/require_class_singlestatement_def |
|
65
|
+
| indent/ok/require_class_singlestatement_def_content |
|
66
|
+
|
67
|
+
@single_line
|
68
|
+
Scenarios: Good single-line modifiers
|
69
|
+
| File |
|
70
|
+
| indent/ok/if_modifier |
|
71
|
+
| indent/ok/if_modifier2 |
|
72
|
+
| indent/ok/def_return_if_modifier |
|
73
|
+
| indent/ok/unless_modifier |
|
74
|
+
| indent/ok/def_return_unless_modifier |
|
75
|
+
| indent/ok/while_within_single_line_block |
|
76
|
+
|
77
|
+
@multi_line
|
78
|
+
Scenarios: Good multi-line modifiers
|
79
|
+
| File |
|
80
|
+
| indent/ok/multi_line_if_with_trailing_andop |
|
81
|
+
|
82
|
+
@case
|
83
|
+
Scenarios: Good case statements
|
84
|
+
| File |
|
85
|
+
| indent/ok/case_whens_level |
|
86
|
+
| indent/ok/case_strings_in_strings |
|
87
|
+
|
88
|
+
Scenarios: Good 'do' loops
|
89
|
+
| File |
|
90
|
+
| indent/ok/while_do_loop |
|
91
|
+
| indent/ok/while_do_loop2 |
|
92
|
+
| indent/ok/until_do_loop |
|
93
|
+
| indent/ok/until_do_loop2 |
|
94
|
+
| indent/ok/for_do_loop |
|
95
|
+
| indent/ok/loop_do_loop |
|
96
|
+
|
97
|
+
Scenarios: Good non-'do' loops
|
98
|
+
| File |
|
99
|
+
| indent/ok/while_as_modifier_loop |
|
100
|
+
| indent/ok/until_as_modifier_loop |
|
101
|
+
| indent/ok/for_with_break_loop |
|
102
|
+
| indent/ok/for_with_next_loop |
|
103
|
+
| indent/ok/for_with_redo_loop |
|
104
|
+
| indent/ok/for_with_retry_loop |
|
105
|
+
| indent/ok/loop_with_braces |
|
106
|
+
|
107
|
+
@single_line @braces
|
108
|
+
Scenarios: Good single-line brace uses
|
109
|
+
| File |
|
110
|
+
| indent/ok/single_line_braces |
|
111
|
+
| indent/ok/single_line_braces_as_t_string |
|
112
|
+
|
113
|
+
@multi_line @braces
|
114
|
+
Scenarios: Good multi-line brace uses
|
115
|
+
| File |
|
116
|
+
| indent/ok/multi_line_braces |
|
117
|
+
| indent/ok/multi_line_braces_as_t_string |
|
118
|
+
| indent/ok/multi_line_lonely_braces |
|
119
|
+
| indent/ok/multi_line_lonely_braces_as_t_string |
|
120
|
+
| indent/ok/multi_line_braces_embedded_arrays |
|
121
|
+
| indent/ok/braces_combo |
|
122
|
+
|
123
|
+
@single_line @brackets
|
124
|
+
Scenarios: Good single-line bracket uses
|
125
|
+
| File |
|
126
|
+
| indent/ok/single_line_brackets |
|
127
|
+
| indent/ok/single_line_brackets_as_t_string |
|
128
|
+
|
129
|
+
@multi_line @brackets
|
130
|
+
Scenarios: Good multi-line bracket uses
|
131
|
+
| File |
|
132
|
+
| indent/ok/multi_line_brackets |
|
133
|
+
| indent/ok/multi_line_brackets_as_t_string |
|
134
|
+
| indent/ok/multi_line_lonely_brackets |
|
135
|
+
| indent/ok/multi_line_lonely_brackets_as_t_string |
|
136
|
+
| indent/ok/multi_line_brackets_embedded_hashes |
|
137
|
+
| indent/ok/brackets_combo |
|
138
|
+
|
139
|
+
@single_line @parens
|
140
|
+
Scenarios: Good single-line paren uses
|
141
|
+
| File |
|
142
|
+
| indent/ok/single_line_parens |
|
143
|
+
| indent/ok/single_line_parens_as_t_string |
|
144
|
+
|
145
|
+
@multi_line @parens
|
146
|
+
Scenarios: Good multi-line paren uses
|
147
|
+
| File |
|
148
|
+
| indent/ok/multi_line_parens |
|
149
|
+
| indent/ok/multi_line_parens_as_t_string |
|
150
|
+
| indent/ok/multi_line_lonely_parens |
|
151
|
+
| indent/ok/multi_line_lonely_parens_with_commas |
|
152
|
+
| indent/ok/multi_line_lonely_parens_as_t_string |
|
153
|
+
| indent/ok/parens_combo |
|
154
|
+
|
155
|
+
@multi_line @ops
|
156
|
+
Scenarios: Good multi-line operator uses
|
157
|
+
| File |
|
158
|
+
| indent/ok/multi_line_ops |
|
159
|
+
| indent/ok/multi_line_andop_in_method |
|
160
|
+
| indent/ok/multi_line_rshift_in_method |
|
161
|
+
| indent/ok/multi_line_string_concat_with_plus |
|
162
|
+
| indent/ok/multi_line_string_concat_with_plus_in_parens |
|
163
|
+
| indent/ok/multi_line_string_concat_twice |
|
164
|
+
|
165
|
+
@multi_line
|
166
|
+
Scenarios: Good multi-line method calls
|
167
|
+
| File |
|
168
|
+
| indent/ok/multi_line_method_call |
|
169
|
+
| indent/ok/multi_line_method_call_ends_with_period |
|
170
|
+
| indent/ok/multi_line_method_call_ends_with_many_periods |
|
171
|
+
|
172
|
+
@multi_line @ops
|
173
|
+
Scenarios: Good multi-line if + logical operators
|
174
|
+
| File |
|
175
|
+
| indent/ok/multi_line_if_logical_and |
|
176
|
+
|
177
|
+
@multi_line @blocks
|
178
|
+
Scenarios: Good multi-line blocks
|
179
|
+
| File |
|
180
|
+
| indent/ok/multi_line_each_block |
|
181
|
+
| indent/ok/multi_line_each_block_with_op_and_parens |
|
182
|
+
| indent/ok/do_end_block_in_parens |
|
183
|
+
|
184
|
+
@single_line @keywords
|
185
|
+
Scenarios: Good use of single-line keyword statements
|
186
|
+
| File |
|
187
|
+
| indent/ok/single_line_begin_rescue_end |
|
188
|
+
|
189
|
+
@multi_line @combos
|
190
|
+
Scenarios: Good combinations of many things
|
191
|
+
| File |
|
192
|
+
| indent/ok/combo1 |
|
193
|
+
| indent/ok/combo2 |
|
194
|
+
| indent/ok/combo3 |
|
195
|
+
| indent/ok/brace_bracket_paren_combo1 |
|
196
|
+
| indent/ok/paren_comma_combo1 |
|
197
|
+
|
198
|
+
@wip
|
199
|
+
Scenarios: WIPs
|
200
|
+
| File |
|
201
|
+
| indent/ok/case_whens_in |
|
202
|
+
| indent/ok/method_closing_lonely_paren |
|
203
|
+
| indent/ok/method_lonely_args |
|
204
|
+
| indent/ok/line_ends_with_label |
|
205
|
+
| indent/ok/rparen_and_do_same_line |
|
206
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Feature: Name detection
|
2
|
+
As a Ruby developer, I want to be able to detect improper class and method
|
3
|
+
names so that I can fix them.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given my configuration file ".tailor" looks like:
|
7
|
+
"""
|
8
|
+
Tailor.config do |config|
|
9
|
+
config.file_set do
|
10
|
+
trailing_newlines 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
|
15
|
+
@method_naming @good_files
|
16
|
+
Scenario Outline: Method naming
|
17
|
+
Given <File> exists without a newline at the end
|
18
|
+
When I run `tailor -d -c .tailor <File>`
|
19
|
+
Then the output should match /Total Problems.*0/
|
20
|
+
And the exit status should be 0
|
21
|
+
|
22
|
+
Scenarios: Good method naming
|
23
|
+
| File |
|
24
|
+
| naming/ok/single_word_method |
|
25
|
+
| naming/ok/two_word_method |
|
26
|
+
|
27
|
+
@method_naming @bad_files
|
28
|
+
|
29
|
+
Scenario Outline: Bad method naming
|
30
|
+
Given <File> exists without a newline at the end
|
31
|
+
When I run `tailor -d -c .tailor <File>`
|
32
|
+
Then the output should match /Total Problems.*<Count>/
|
33
|
+
And the output should match /position: <Position>/
|
34
|
+
And the exit status should be 1
|
35
|
+
|
36
|
+
Scenarios: Bad method naming
|
37
|
+
| File | Count | Position |
|
38
|
+
| naming/1/one_caps_camel_case_method | 1 | 1:4 |
|
39
|
+
| naming/1/one_caps_camel_case_method_trailing_comment | 1 | 1:4 |
|
40
|
+
|
41
|
+
@class_naming @good_files
|
42
|
+
|
43
|
+
Scenario Outline: Good class naming
|
44
|
+
Given <File> exists without a newline at the end
|
45
|
+
When I run `tailor -d -c .tailor <File>`
|
46
|
+
Then the output should match /Total Problems.*0/
|
47
|
+
And the exit status should be 0
|
48
|
+
|
49
|
+
Scenarios: Good class/module naming
|
50
|
+
| File |
|
51
|
+
| naming/ok/single_word_class |
|
52
|
+
| naming/ok/single_word_module |
|
53
|
+
| naming/ok/two_word_class |
|
54
|
+
| naming/ok/two_word_module |
|
55
|
+
|
56
|
+
@class_naming @bad_files
|
57
|
+
|
58
|
+
Scenario Outline: Bad class/module naming
|
59
|
+
Given <File> exists without a newline at the end
|
60
|
+
When I run `tailor -d -c .tailor <File>`
|
61
|
+
Then the output should match /Total Problems.*<Count>/
|
62
|
+
And the output should match /position: <Position>/
|
63
|
+
And the exit status should be 1
|
64
|
+
|
65
|
+
Scenarios: Bad method naming
|
66
|
+
| File | Count | Position |
|
67
|
+
| naming/1/one_screaming_snake_case_class | 1 | 1:6 |
|
68
|
+
| naming/1/one_screaming_snake_module_class | 1 | 1:7 |
|
69
|
+
| naming/1/two_screaming_snake_case_class | 1 | 1:6 |
|
70
|
+
| naming/1/two_screaming_snake_module_class | 1 | 1:7 |
|
71
|
+
|
72
|
+
|
@@ -1,139 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Given /^(.+) exists with(\w*) a newline at the end$/ do |file_name, no_newline|
|
2
|
+
file_contents = get_file_contents(file_name)
|
3
|
+
file_contents.should_not be_nil
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
file_path = Pathname.new(File.expand_path(@file_list[0]))
|
9
|
-
|
10
|
-
current_level = 0.0
|
11
|
-
problem_count = 0
|
12
|
-
next_proper_level = 0.0
|
13
|
-
|
14
|
-
check_file do |line|
|
15
|
-
line = Tailor::FileLine.new(line, file_path, current_line)
|
16
|
-
|
17
|
-
puts '----'
|
18
|
-
puts "line = #{current_line}"
|
19
|
-
puts "current = #{current_level}"
|
20
|
-
actual_level = line.is_at_level
|
21
|
-
puts "actual = #{actual_level}"
|
22
|
-
should_be_at = line.should_be_at_level(current_level)
|
23
|
-
puts "should = #{should_be_at}"
|
24
|
-
|
25
|
-
problem_count += 1 if line.at_proper_level?(actual_level, should_be_at)
|
26
|
-
next_proper_level = line.next_line_should_be_at_level current_level
|
27
|
-
puts "next proper = #{next_proper_level}"
|
28
|
-
current_level = next_proper_level
|
29
|
-
|
30
|
-
current_line += 1
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
Given /^the indentation of that file starts at level (\d*)$/ do |level|
|
35
|
-
current_line = 1
|
36
|
-
result = nil
|
37
|
-
|
38
|
-
file_path = Pathname.new(File.expand_path(@file_list[0]))
|
39
|
-
|
40
|
-
check_file do |line|
|
41
|
-
line = FileLine.new(line, file_path, current_line)
|
42
|
-
result = line.is_at_level
|
43
|
-
break line
|
44
|
-
end
|
45
|
-
|
46
|
-
result.should == 0
|
47
|
-
end
|
48
|
-
|
49
|
-
Given /^the line (\d*) is a "([^\"]*)" statement$/ do |line_num, statement_type|
|
50
|
-
current_line = 1
|
51
|
-
result = nil
|
52
|
-
|
53
|
-
check_file do |line|
|
54
|
-
result = line.strip =~ /^#{statement_type}/
|
55
|
-
current_line == line_num.to_i ? (break line) : current_line += 1
|
56
|
-
end
|
57
|
-
result.should_not be_nil
|
58
|
-
end
|
59
|
-
|
60
|
-
Then "the checker should tell me my indentation is OK" do
|
61
|
-
pending
|
62
|
-
end
|
63
|
-
|
64
|
-
=begin
|
65
|
-
Then /^the level of line 1 should be 0.0$/ do
|
66
|
-
file_path = Pathname.new(File.expand_path(@file_list[0]))
|
67
|
-
@current_level = nil
|
68
|
-
|
69
|
-
check_file do |line|
|
70
|
-
line = FileLine.new(line, file_path, 1)
|
71
|
-
|
72
|
-
@current_level = line.is_at_level
|
73
|
-
@level_change = @current_level + line.next_line_level_change
|
74
|
-
break line
|
5
|
+
if no_newline.empty?
|
6
|
+
file_contents << "\n" unless file_contents[-1] == "\n"
|
7
|
+
else
|
8
|
+
file_contents[-1] = '' if file_contents[-1] == "\n"
|
75
9
|
end
|
76
|
-
@current_level.should.eql? 0.0
|
77
|
-
end
|
78
|
-
=end
|
79
|
-
|
80
|
-
|
81
|
-
Then /^the level of line (\d*) should be (\d+\.\d+)$/ do |line_num_to_check, level_to_check|
|
82
|
-
file_path = Pathname.new(File.expand_path(@file_list[0]))
|
83
|
-
current_line_num = 1
|
84
|
-
next_proper_level = 0.0
|
85
|
-
current_proper_level = 0.0
|
86
|
-
|
87
|
-
check_file do |line|
|
88
|
-
line = FileLine.new(line, file_path, current_line_num)
|
89
10
|
|
90
|
-
|
91
|
-
line.is_at_level.should == level_to_check.to_f
|
92
|
-
|
93
|
-
# Determine what the next line's level should be at, based on the current line's
|
94
|
-
# level.
|
95
|
-
next_proper_level = current_proper_level + line.indent_next_line_by
|
96
|
-
end
|
97
|
-
|
98
|
-
current_line_num += 1
|
99
|
-
end
|
11
|
+
write_file(file_name, file_contents)
|
100
12
|
end
|
101
13
|
|
102
|
-
|
103
|
-
|
104
|
-
file_path = Pathname.new(File.expand_path(@file_list[0]))
|
105
|
-
current_line = 1
|
106
|
-
actual_level = nil
|
107
|
-
current_level = 0.0 # new
|
108
|
-
level_change = nil # new
|
109
|
-
|
110
|
-
check_file do |line|
|
111
|
-
line = FileLine.new(line, file_path, current_line)
|
112
|
-
|
113
|
-
# If the first line of the file,
|
114
|
-
if current_line == 1 # new
|
115
|
-
level_change = current_level + line.next_line_level_change #new
|
116
|
-
break line #new
|
117
|
-
else # new
|
118
|
-
actual_level = line.is_at_level
|
119
|
-
end # new
|
120
|
-
|
121
|
-
# Only check the line specified; skip if it's the first line.
|
122
|
-
if (current_line == line_num_to_check) and (line_num_to_check > 1)
|
123
|
-
this_level = current_level + level_change # new
|
124
|
-
this_level < 0.0 ? (this_level = 0.0) : this_level # new
|
125
|
-
this_level.should == level_to_check # new
|
126
|
-
actual_level.should == this_level
|
127
|
-
level_change = line.next_line_level_change
|
128
|
-
break line
|
129
|
-
else
|
130
|
-
current_line += 1
|
131
|
-
end
|
132
|
-
end
|
133
|
-
if current_line == 1
|
134
|
-
current_level.should.eql? level_to_check
|
135
|
-
else
|
136
|
-
current_level += level_change #new
|
137
|
-
end
|
14
|
+
Given /^my configuration file "([^"]*)" looks like:$/ do |file_name, string|
|
15
|
+
write_file(file_name, string)
|
138
16
|
end
|
139
|
-
=end
|
data/features/support/env.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'simplecov'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require 'rspec'
|
8
|
-
|
9
|
-
Before do
|
10
|
-
@tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
11
|
-
@home_path = File.expand_path(File.join(@tmp_root, "home"))
|
12
|
-
@lib_path = File.expand_path(File.dirname(__FILE__) + "/../../lib")
|
13
|
-
@features_path = File.dirname(__FILE__) + "/../"
|
14
|
-
FileUtils.rm_rf @tmp_root
|
15
|
-
FileUtils.mkdir_p @home_path
|
16
|
-
ENV['HOME'] = @home_path
|
4
|
+
SimpleCov.start do
|
5
|
+
add_group "Features", "features/"
|
6
|
+
add_group "Lib", "lib"
|
17
7
|
end
|
8
|
+
|
9
|
+
|